mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added theme files support with /theme command
This commit is contained in:
parent
e8b2b7196c
commit
cd4465394b
@ -1,17 +1,17 @@
|
|||||||
.TH Profanity 1 "August 2012" "Profanity XMPP client"
|
.TH Profanity 1 "August 2012" "Profanity XMPP client"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Profanity \- a simple console based XMPP chat client for Linux.
|
Profanity \- a simple console based XMPP chat client.
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B profanity
|
.B profanity
|
||||||
[-vhd] [-l level]
|
[-vhd] [-l level]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B Profanity
|
.B Profanity
|
||||||
is a simple lightweight console based XMPP chat client. It's emphasis is
|
is a simple lightweight console based XMPP chat client. It's emphasis is
|
||||||
on having a simple and configurable UI, see the homepage
|
on having a simple and configurable command driven UI, see the homepage
|
||||||
at:
|
at:
|
||||||
.br
|
.br
|
||||||
.PP
|
.PP
|
||||||
<http://www.boothj5.com/profanity.shtml>
|
<http://www.profanity.im>
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.BI "\-v, \-\-version"
|
.BI "\-v, \-\-version"
|
||||||
@ -66,6 +66,8 @@ beep=false
|
|||||||
.br
|
.br
|
||||||
flash=false
|
flash=false
|
||||||
.br
|
.br
|
||||||
|
theme=mytheme
|
||||||
|
.br
|
||||||
showsplash=false
|
showsplash=false
|
||||||
.br
|
.br
|
||||||
notify=true
|
notify=true
|
||||||
@ -81,6 +83,26 @@ remind=15
|
|||||||
vercheck=true
|
vercheck=true
|
||||||
.br
|
.br
|
||||||
.PP
|
.PP
|
||||||
|
[connections]
|
||||||
|
.br
|
||||||
|
logins=user1@server1.org;myuser@server2.com;
|
||||||
|
.PP
|
||||||
|
.RE
|
||||||
|
The [ui] section contains basic preferences, you can find more help on these
|
||||||
|
settings by typing "/help beep" for example in Profanity.
|
||||||
|
.PP
|
||||||
|
The [connections] section is the list of users that will appear in tab
|
||||||
|
completion for the /connect command. This list is automatically populated
|
||||||
|
when you successfully log in as a user.
|
||||||
|
.SH THEMES
|
||||||
|
Themes files for
|
||||||
|
.B Profanity
|
||||||
|
are stored in
|
||||||
|
.I ~/.profanity/themes
|
||||||
|
, see the following example:
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
.PP
|
||||||
[colours]
|
[colours]
|
||||||
.br
|
.br
|
||||||
bkgnd=default
|
bkgnd=default
|
||||||
@ -117,23 +139,27 @@ xa=cyan
|
|||||||
.br
|
.br
|
||||||
offline=red
|
offline=red
|
||||||
.br
|
.br
|
||||||
.PP
|
typing=yellow
|
||||||
[connections]
|
.br
|
||||||
|
gone=red
|
||||||
|
.br
|
||||||
|
error=red
|
||||||
|
.br
|
||||||
|
incoming=yellow
|
||||||
|
.br
|
||||||
|
roominfo=yellow
|
||||||
|
.br
|
||||||
|
me=yellow
|
||||||
|
.br
|
||||||
|
them=green
|
||||||
.br
|
.br
|
||||||
logins=user1@server1.org;myuser@server2.com;
|
|
||||||
.PP
|
.PP
|
||||||
.RE
|
.RE
|
||||||
The [ui] section contains basic preferences, you can find more help on these
|
|
||||||
settings by typing "/help beep" for example in Profanity.
|
|
||||||
.PP
|
|
||||||
The [colours] section allows you to tailor the colours used in Profanity to
|
The [colours] section allows you to tailor the colours used in Profanity to
|
||||||
suit your terminal preferences. Available colours are black, white, red,
|
suit your terminal preferences. Available colours are black, white, red,
|
||||||
green, blue, yellow, cyan, magenta and default, where default is the default
|
green, blue, yellow, cyan, magenta and default, where default is the default
|
||||||
forground or background colour on your terminal.
|
forground or background colour on your terminal.
|
||||||
.PP
|
.PP
|
||||||
The [connections] section is the list of users that will appear in tab
|
|
||||||
completion for the /connect command. This list is automatically populated
|
|
||||||
when you successfully log in as a user.
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Bugs can either be reported by sending a mail directly to:
|
Bugs can either be reported by sending a mail directly to:
|
||||||
.br
|
.br
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "prof_autocomplete.h"
|
#include "prof_autocomplete.h"
|
||||||
#include "profanity.h"
|
#include "profanity.h"
|
||||||
|
#include "theme.h"
|
||||||
#include "tinyurl.h"
|
#include "tinyurl.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
@ -124,6 +125,7 @@ static gboolean _cmd_xa(gchar **args, struct cmd_help_t help);
|
|||||||
static gboolean _cmd_info(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_info(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_wins(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_wins(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_nick(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_nick(gchar **args, struct cmd_help_t help);
|
||||||
|
static gboolean _cmd_theme(gchar **args, struct cmd_help_t help);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The commands are broken down into three groups:
|
* The commands are broken down into three groups:
|
||||||
@ -191,6 +193,18 @@ static struct cmd_t main_commands[] =
|
|||||||
"you will need to restart Profanity for config file edits to take effect.",
|
"you will need to restart Profanity for config file edits to take effect.",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
|
{ "/theme",
|
||||||
|
_cmd_theme, parse_args, 1, 1,
|
||||||
|
{ "/theme [theme-name]", "Change colour theme.",
|
||||||
|
{ "/theme [theme-name]",
|
||||||
|
"--------------",
|
||||||
|
"Change the colour setting as defined in:",
|
||||||
|
"",
|
||||||
|
" ~/.profanity/themes/theme-name",
|
||||||
|
"",
|
||||||
|
"Using \"default\" as the theme name will reset to the default colours.",
|
||||||
|
NULL } } },
|
||||||
|
|
||||||
{ "/msg",
|
{ "/msg",
|
||||||
_cmd_msg, parse_args_with_freetext, 2, 2,
|
_cmd_msg, parse_args_with_freetext, 2, 2,
|
||||||
{ "/msg user@host mesg", "Send mesg to user.",
|
{ "/msg user@host mesg", "Send mesg to user.",
|
||||||
@ -1077,6 +1091,20 @@ _cmd_prefs(gchar **args, struct cmd_help_t help)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cmd_theme(gchar **args, struct cmd_help_t help)
|
||||||
|
{
|
||||||
|
if (theme_change(args[0])) {
|
||||||
|
win_load_colours();
|
||||||
|
prefs_set_theme(args[0]);
|
||||||
|
cons_show("Loaded theme: %s", args[0]);
|
||||||
|
} else {
|
||||||
|
cons_show("Couldn't find theme: %s", args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_who(gchar **args, struct cmd_help_t help)
|
_cmd_who(gchar **args, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
|
44
src/theme.c
44
src/theme.c
@ -106,6 +106,41 @@ theme_load(const char * const theme_name)
|
|||||||
_load_colours();
|
_load_colours();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
theme_change(const char * const theme_name)
|
||||||
|
{
|
||||||
|
// use default theme
|
||||||
|
if (strcmp(theme_name, "default") == 0) {
|
||||||
|
g_key_file_free(theme);
|
||||||
|
theme = g_key_file_new();
|
||||||
|
_load_colours();
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
GString *new_theme_file = g_string_new(getenv("HOME"));
|
||||||
|
g_string_append(new_theme_file, "/.profanity/themes/");
|
||||||
|
g_string_append(new_theme_file, theme_name);
|
||||||
|
|
||||||
|
// no theme file found
|
||||||
|
if (!g_file_test(new_theme_file->str, G_FILE_TEST_EXISTS)) {
|
||||||
|
log_info("Theme does not exist \"%s\"", theme_name);
|
||||||
|
g_string_free(new_theme_file, TRUE);
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// load from theme file
|
||||||
|
} else {
|
||||||
|
g_string_free(theme_loc, TRUE);
|
||||||
|
theme_loc = new_theme_file;
|
||||||
|
log_info("Changing theme to \"%s\"", theme_name);
|
||||||
|
g_key_file_free(theme);
|
||||||
|
theme = g_key_file_new();
|
||||||
|
g_key_file_load_from_file(theme, theme_loc->str, G_KEY_FILE_KEEP_COMMENTS,
|
||||||
|
NULL);
|
||||||
|
_load_colours();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
theme_close(void)
|
theme_close(void)
|
||||||
{
|
{
|
||||||
@ -216,15 +251,6 @@ _load_colours(void)
|
|||||||
gchar *them_val = g_key_file_get_string(theme, "colours", "them", NULL);
|
gchar *them_val = g_key_file_get_string(theme, "colours", "them", NULL);
|
||||||
_set_colour(them_val, &colour_prefs.them, COLOR_GREEN);
|
_set_colour(them_val, &colour_prefs.them, COLOR_GREEN);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
static void
|
|
||||||
_save_prefs(void)
|
|
||||||
{
|
|
||||||
gsize g_data_size;
|
|
||||||
char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
|
|
||||||
g_file_set_contents(prefs_loc->str, g_prefs_data, g_data_size, NULL);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
NCURSES_COLOR_T
|
NCURSES_COLOR_T
|
||||||
theme_get_bkgnd()
|
theme_get_bkgnd()
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void theme_load(const char * const theme_name);
|
void theme_load(const char * const theme_name);
|
||||||
|
gboolean theme_change(const char * const theme_name);
|
||||||
void theme_close(void);
|
void theme_close(void);
|
||||||
|
|
||||||
NCURSES_COLOR_T theme_get_bkgnd();
|
NCURSES_COLOR_T theme_get_bkgnd();
|
||||||
|
1
src/ui.h
1
src/ui.h
@ -147,6 +147,7 @@ void win_show_room_member_nick_change(const char * const room,
|
|||||||
void win_show_room_nick_change(const char * const room, const char * const nick);
|
void win_show_room_nick_change(const char * const room, const char * const nick);
|
||||||
void win_show_room_member_presence(const char * const room,
|
void win_show_room_member_presence(const char * const room,
|
||||||
const char * const nick, const char * const show, const char * const status);
|
const char * const nick, const char * const show, const char * const status);
|
||||||
|
void win_load_colours(void);
|
||||||
|
|
||||||
// console window actions
|
// console window actions
|
||||||
void cons_about(void);
|
void cons_about(void);
|
||||||
|
@ -109,6 +109,21 @@ gui_init(void)
|
|||||||
cbreak();
|
cbreak();
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
|
|
||||||
|
win_load_colours();
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
create_title_bar();
|
||||||
|
create_status_bar();
|
||||||
|
create_input_window();
|
||||||
|
_create_windows();
|
||||||
|
|
||||||
|
dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
win_load_colours(void)
|
||||||
|
{
|
||||||
if (has_colors()) {
|
if (has_colors()) {
|
||||||
use_default_colors();
|
use_default_colors();
|
||||||
start_color();
|
start_color();
|
||||||
@ -148,15 +163,6 @@ gui_init(void)
|
|||||||
init_pair(60, theme_get_typing(), theme_get_bkgnd());
|
init_pair(60, theme_get_typing(), theme_get_bkgnd());
|
||||||
init_pair(61, theme_get_gone(), theme_get_bkgnd());
|
init_pair(61, theme_get_gone(), theme_get_bkgnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
create_title_bar();
|
|
||||||
create_status_bar();
|
|
||||||
create_input_window();
|
|
||||||
_create_windows();
|
|
||||||
|
|
||||||
dirty = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user