diff options
Diffstat (limited to 'src/fe-common/core')
-rw-r--r-- | src/fe-common/core/module-formats.c | 150 | ||||
-rw-r--r-- | src/fe-common/core/printtext.c | 23 | ||||
-rw-r--r-- | src/fe-common/core/themes.c | 64 |
3 files changed, 124 insertions, 113 deletions
diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index ec555ecb..91c7c1e7 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -27,12 +27,12 @@ FORMAT_REC fecommon_core_formats[] = { /* ---- */ { NULL, "Windows", 0 }, - { "line_start", "%B-%W!%B-%n ", 0 }, - { "line_start_irssi", "%B-%W!%B- %WIrssi:%n ", 0 }, - { "timestamp", "[$[-2.0]3:$[-2.0]4] ", 6, { 1, 1, 1, 1, 1, 1 } }, + { "line_start", "{line_start} ", 0 }, + { "line_start_irssi", "{line_start} {hilight Irssi:} ", 0 }, + { "timestamp", "$[-2.0]3:$[-2.0]4 ", 6, { 1, 1, 1, 1, 1, 1 } }, { "servertag", "[$0] ", 1, { 0 } }, { "daychange", "Day changed to $[-2.0]{0} $3 $2", 4, { 1, 1, 1, 0 } }, - { "talking_with", "You are now talking with %_$0%_", 1, { 0 } }, + { "talking_with", "You are now talking with {nick $0}", 1, { 0 } }, { "refnum_too_low", "Window number must be greater than 1", 0 }, { "windowlist_header", "Ref Name Active item Server Level", 0 }, { "windowlist_line", "$[3]0 %|$[20]1 $[15]2 $[15]3 $4", 5, { 1, 0, 0, 0, 0 } }, @@ -41,74 +41,74 @@ FORMAT_REC fecommon_core_formats[] = { /* ---- */ { NULL, "Server", 0 }, - { "looking_up", "Looking up %_$0%_", 1, { 0 } }, - { "connecting", "Connecting to %_$0%_ %K[%n$1%K]%n port %_$2%_", 3, { 0, 0, 1 } }, - { "connection_established", "Connection to %_$0%_ established", 1, { 0 } }, - { "cant_connect", "Unable to connect server %_$0%_ port %_$1%_ %K[%n$2%K]", 3, { 0, 1, 0 } }, - { "connection_lost", "Connection lost to %_$0%_", 1, { 0 } }, - { "lag_disconnected", "No PONG reply from server %_$0%_ in $1 seconds, disconnecting", 2, { 0, 1 } }, - { "disconnected", "Disconnected from %_$0%_ %K[%n$1%K]", 2, { 0, 0 } }, - { "server_quit", "Disconnecting from server $0: %K[%n$1%K]", 2, { 0, 0 } }, - { "server_changed", "Changed to %_$2%_ server %_$1%_", 3, { 0, 0, 0 } }, - { "unknown_server_tag", "Unknown server tag %_$0%_", 1, { 0 } }, - { "server_list", "%_$0%_: $1:$2 ($3)", 5, { 0, 0, 1, 0, 0 } }, - { "server_lookup_list", "%_$0%_: $1:$2 ($3) (connecting...)", 5, { 0, 0, 1, 0, 0 } }, - { "server_reconnect_list", "%_$0%_: $1:$2 ($3) ($5 left before reconnecting)", 6, { 0, 0, 1, 0, 0, 0 } }, - { "server_reconnect_removed", "Removed reconnection to server %_$0%_ port %_$1%_", 3, { 0, 1, 0 } }, - { "server_reconnect_not_found", "Reconnection tag %_$0%_ not found", 1, { 0 } }, - { "setupserver_added", "Server $0 saved", 2, { 0, 1 } }, - { "setupserver_removed", "Server $0 removed", 2, { 0, 1 } }, - { "setupserver_not_found", "Server $0 not found", 2, { 0, 1 } }, + { "looking_up", "Looking up {server $0}", 1, { 0 } }, + { "connecting", "Connecting to {server $0} [$1] port {hilight $2}", 3, { 0, 0, 1 } }, + { "connection_established", "Connection to {server $0} established", 1, { 0 } }, + { "cant_connect", "Unable to connect server {server $0} port {hilight $1} {reason $2}", 3, { 0, 1, 0 } }, + { "connection_lost", "Connection lost to {server $0}", 1, { 0 } }, + { "lag_disconnected", "No PONG reply from server {server $0} in $1 seconds, disconnecting", 2, { 0, 1 } }, + { "disconnected", "Disconnected from {server $0} {reason $1}", 2, { 0, 0 } }, + { "server_quit", "Disconnecting from server {server $0}: {reason $1}", 2, { 0, 0 } }, + { "server_changed", "Changed to {hilight $2} server {server $1}", 3, { 0, 0, 0 } }, + { "unknown_server_tag", "Unknown server tag {server $0}", 1, { 0 } }, + { "server_list", "{server $0}: $1:$2 ($3)", 5, { 0, 0, 1, 0, 0 } }, + { "server_lookup_list", "{server $0}: $1:$2 ($3) (connecting...)", 5, { 0, 0, 1, 0, 0 } }, + { "server_reconnect_list", "{server $0}: $1:$2 ($3) ($5 left before reconnecting)", 6, { 0, 0, 1, 0, 0, 0 } }, + { "server_reconnect_removed", "Removed reconnection to server {server $0} port {hilight $1}", 3, { 0, 1, 0 } }, + { "server_reconnect_not_found", "Reconnection tag {server $0} not found", 1, { 0 } }, + { "setupserver_added", "Server {server $0} saved", 2, { 0, 1 } }, + { "setupserver_removed", "Server {server $0} removed", 2, { 0, 1 } }, + { "setupserver_not_found", "Server {server $0} not found", 2, { 0, 1 } }, /* ---- */ { NULL, "Channels", 0 }, - { "join", "%c%_$0%_ %K[%c$1%K]%n has joined %_$2", 3, { 0, 0, 0 } }, - { "part", "%c$0 %K[%n$1%K]%n has left %_$2%_ %K[%n$3%n%K]", 4, { 0, 0, 0, 0 } }, - { "kick", "%c$0%n was kicked from %_$1%_ by %_$2%_ %K[%n$3%K]", 4, { 0, 0, 0, 0 } }, - { "quit", "%c$0 %K[%n$1%K]%n has quit IRC %K[%n$2%n%K]", 3, { 0, 0, 0 } }, - { "quit_once", "%_$3%_ %c$0 %K[%n$1%K]%n has quit IRC %K[%n$2%K]", 4, { 0, 0, 0, 0 } }, - { "invite", "%_$0%_ invites you to %_$1", 2, { 0, 0 } }, - { "new_topic", "%_$0%_ changed the topic of %c$1%n to%K:%n $2", 3, { 0, 0, 0 } }, - { "topic_unset", "Topic unset by %_$0%_ on %c$1", 2, { 0, 0 } }, - { "your_nick_changed", "You're now known as %c$1", 2, { 0, 0 } }, - { "nick_changed", "%_$0%_ is now known as %c$1", 2, { 0, 0 } }, - { "talking_in", "You are now talking in %_$0%_", 1, { 0 } }, + { "join", "{channick_hilight $0} {chanhost_hilight $1} has joined {channel $2}", 3, { 0, 0, 0 } }, + { "part", "{channick $0} {chanhost $1} has left {channel $2} {reason $3}", 4, { 0, 0, 0, 0 } }, + { "kick", "{channick $0} was kicked from {channel $1} by {nick $2} {reason $3}", 4, { 0, 0, 0, 0 } }, + { "quit", "{channick $0} {chanhost $1} has quit {reason $2}", 3, { 0, 0, 0 } }, + { "quit_once", "{channel $3} {channick $0} {chanhost $1} has quit {reason $2}", 4, { 0, 0, 0, 0 } }, + { "invite", "{nick $0} invites you to {channel $1}", 2, { 0, 0 } }, + { "new_topic", "{nick $0} changed the topic of {channel $1} to: $2", 3, { 0, 0, 0 } }, + { "topic_unset", "Topic unset by {nick $0} on {channel $1}", 2, { 0, 0 } }, + { "your_nick_changed", "You're now known as {nick $1}", 2, { 0, 0 } }, + { "nick_changed", "{channick $0} is now known as {channick_hilight $1}", 2, { 0, 0 } }, + { "talking_in", "You are now talking in {channel $0}", 1, { 0 } }, { "not_in_channels", "You are not on any channels", 0 }, - { "current_channel", "Current channel $0", 1, { 0 } }, + { "current_channel", "Current channel {channel $0}", 1, { 0 } }, { "chanlist_header", "You are on the following channels:", 0 }, - { "chanlist_line", "$[-10]0 %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } }, - { "chansetup_not_found", "Channel $0 not found", 2, { 0, 0 } }, - { "chansetup_added", "Channel $0 saved", 2, { 0, 0 } }, - { "chansetup_removed", "Channel $0 removed", 2, { 0, 0 } }, + { "chanlist_line", "{channel $[-10]0} %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } }, + { "chansetup_not_found", "Channel {channel $0} not found", 2, { 0, 0 } }, + { "chansetup_added", "Channel {channel $0} saved", 2, { 0, 0 } }, + { "chansetup_removed", "Channel {channel $0} removed", 2, { 0, 0 } }, { "chansetup_header", "Channel IRC net Password Settings", 0 }, - { "chansetup_line", "$[15]0 %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } }, + { "chansetup_line", "{channel $[15]0} %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } }, { "chansetup_footer", "", 0 }, /* ---- */ { NULL, "Messages", 0 }, - { "own_msg", "%K<%n$2%W$0%K>%n %|$1", 3, { 0, 0, 0 } }, - { "own_msg_channel", "%K<%n$3%W$0%K:%c$1%K>%n %|$2", 4, { 0, 0, 0, 0 } }, - { "own_msg_private", "%K[%rmsg%K(%R$0%K)]%n $1", 2, { 0, 0 } }, - { "own_msg_private_query", "%K<%W$2%K>%n %|$1", 3, { 0, 0, 0 } }, - { "pubmsg_me", "%K<%n$2%Y$0%K>%n %|$1", 3, { 0, 0, 0 } }, - { "pubmsg_me_channel", "%K<%n$3%Y$0%K:%c$1%K>%n %|$2", 4, { 0, 0, 0, 0 } }, - { "pubmsg_hilight", "%K<%n$3$0$1%K>%n %|$2", 4, { 0, 0, 0, 0 } }, - { "pubmsg_hilight_channel", "%K<%n$4$0$1%K:%c$2%K>%n %|$3", 5, { 0, 0, 0, 0, 0 } }, - { "pubmsg", "%K<%n$2$0%K>%n %|$1", 3, { 0, 0, 0 } }, - { "pubmsg_channel", "%K<%n$3$0%K:%c$1%K>%n %|$2", 4, { 0, 0, 0, 0 } }, - { "msg_private", "%K[%R$0%K(%r$1%K)]%n $2", 3, { 0, 0, 0 } }, - { "msg_private_query", "%K<%R$0%K>%n %|$2", 3, { 0, 0, 0 } }, + { "own_msg", "{msgnick $2{msgownnick $0}}$1", 3, { 0, 0, 0 } }, + { "own_msg_channel", "{msgnick $3{msgownnick $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } }, + { "own_msg_private", "{ownprivmsg msg{ownprivmsgdest $0}}$1", 2, { 0, 0 } }, + { "own_msg_private_query", "{msgnick {msgownnick $2}}$1", 3, { 0, 0, 0 } }, + { "pubmsg_me", "{msgnick $2{msgme $0}}$1", 3, { 0, 0, 0 } }, + { "pubmsg_me_channel", "{msgnick $3{msgme $0}{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } }, + { "pubmsg_hilight", "{msgnick $3$0$1}$2", 4, { 0, 0, 0, 0 } }, + { "pubmsg_hilight_channel", "{msgnick $4$0$1{msgchannel 2}}$3", 5, { 0, 0, 0, 0, 0 } }, + { "pubmsg", "{msgnick $2$0}$1", 3, { 0, 0, 0 } }, + { "pubmsg_channel", "{msgnick $3$0{msgchannel $1}}$2", 4, { 0, 0, 0, 0 } }, + { "msg_private", "{privmsgnick $0{privmsghost $1}}$2", 3, { 0, 0, 0 } }, + { "msg_private_query", "{msgnick {privmsgnick $0}}$2", 3, { 0, 0, 0 } }, { "no_msgs_got", "You have not received a message from anyone yet", 0 }, { "no_msgs_sent", "You have not sent a message to anyone yet", 0 }, /* ---- */ { NULL, "Queries", 0 }, - { "query_start", "Starting query with %_$0%_", 1, { 0 } }, - { "no_query", "No query with %_$0%_", 1, { 0 } }, - { "query_server_changed", "Query with %_$2%_ changed to server %_$1%_", 3, { 0, 0, 0 } }, + { "query_start", "Starting query with {nick $0}", 1, { 0 } }, + { "no_query", "No query with {nick $0}", 1, { 0 } }, + { "query_server_changed", "Query with {nick $2} changed to server {server $1}", 3, { 0, 0, 0 } }, /* ---- */ { NULL, "Highlighting", 0 }, @@ -132,29 +132,29 @@ FORMAT_REC fecommon_core_formats[] = { /* ---- */ { NULL, "Logging", 0 }, - { "log_opened", "Log file %_$0%_ opened", 1, { 0 } }, - { "log_closed", "Log file %_$0%_ closed", 1, { 0 } }, - { "log_create_failed", "Couldn't create log file %_$0%_: $1", 2, { 0, 0 } }, - { "log_locked", "Log file %_$0%_ is locked, probably by another running Irssi", 1, { 0 } }, - { "log_not_open", "Log file %_$0%_ not open", 1, { 0 } }, - { "log_started", "Started logging to file %_$0", 1, { 0 } }, - { "log_stopped", "Stopped logging to file %_$0", 1, { 0 } }, + { "log_opened", "Log file {hilight $0} opened", 1, { 0 } }, + { "log_closed", "Log file {hilight $0} closed", 1, { 0 } }, + { "log_create_failed", "Couldn't create log file {hilight $0}: $1", 2, { 0, 0 } }, + { "log_locked", "Log file {hilight $0} is locked, probably by another running Irssi", 1, { 0 } }, + { "log_not_open", "Log file {hilight $0} not open", 1, { 0 } }, + { "log_started", "Started logging to file {hilight $0}", 1, { 0 } }, + { "log_stopped", "Stopped logging to file {hilight $0}", 1, { 0 } }, { "log_list_header", "Logs:", 0 }, { "log_list", "$0 $1: $2 $3$4", 5, { 1, 0, 0, 0, 0, 0 } }, { "log_list_footer", "", 0 }, { "windowlog_file", "Window LOGFILE set to $0", 1, { 0 } }, { "windowlog_file_logging", "Can't change window's logfile while log is on", 0 }, { "no_away_msgs", "No new messages in awaylog", 1, { 0 } }, - { "away_msgs", "$1 new messages in awaylog:", 2, { 0, 1 } }, + { "away_msgs", "{hilight $1} new messages in awaylog:", 2, { 0, 1 } }, /* ---- */ { NULL, "Modules", 0 }, - { "module_already_loaded", "Module %_$0%_ already loaded", 1, { 0 } }, - { "module_load_error", "Error loading module %_$0%_: $1", 2, { 0, 0 } }, - { "module_invalid", "%_$0%_ isn't Irssi module", 1, { 0 } }, - { "module_loaded", "Loaded module %_$0", 1, { 0 } }, - { "module_unloaded", "Unloaded module %_$0", 1, { 0 } }, + { "module_already_loaded", "Module {hilight $0} already loaded", 1, { 0 } }, + { "module_load_error", "Error loading module {hilight $0}: $1", 2, { 0, 0 } }, + { "module_invalid", "{hilight $0} isn't Irssi module", 1, { 0 } }, + { "module_loaded", "Loaded module {hilight $0}", 1, { 0 } }, + { "module_unloaded", "Unloaded module {hilight $0}", 1, { 0 } }, /* ---- */ { NULL, "Commands", 0 }, @@ -176,18 +176,18 @@ FORMAT_REC fecommon_core_formats[] = { { "theme_saved", "Theme saved to $0", 1, { 0 } }, { "theme_save_failed", "Error saving theme to $0", 1, { 0 } }, - { "theme_not_found", "Theme %_$0%_ not found", 1, { 0 } }, - { "window_theme_changed", "Using theme %_$0%_ in this window", 1, { 0 } }, - { "format_title", "%:%K[%W$0%K] - [%W$1%K]%:%:", 2, { 0, 0 } }, - { "format_subtitle", "%K[%W$0%K]", 1, { 0 } }, - { "format_item", "$0 %K=%n $1", 2, { 0, 0 } }, + { "theme_not_found", "Theme {hilight $0} not found", 1, { 0 } }, + { "window_theme_changed", "Using theme {hilight $0} in this window", 1, { 0 } }, + { "format_title", "%:[{hilight $0}] - [{hilight $1}]%:%:", 2, { 0, 0 } }, + { "format_subtitle", "[{hilight $0}]", 1, { 0 } }, + { "format_item", "$0 = $1", 2, { 0, 0 } }, /* ---- */ { NULL, "Ignores", 0 }, - { "ignored", "Ignoring %_$1%_ from %_$0%_", 2, { 0, 0 } }, - { "unignored", "Unignored %_$0%_", 1, { 0 } }, - { "ignore_not_found", "%_$0%_ is not being ignored", 1, { 0 } }, + { "ignored", "Ignoring {hilight $1} from {nick $0}", 2, { 0, 0 } }, + { "unignored", "Unignored {nick $0}", 1, { 0 } }, + { "ignore_not_found", "{nick $0} is not being ignored", 1, { 0 } }, { "ignore_no_ignores", "There are no ignores", 0 }, { "ignore_header", "Ignorance List:", 0 }, { "ignore_line", "$[-4]0 $1: $2 $3 $4", 4, { 1, 0, 0, 0 } }, diff --git a/src/fe-common/core/printtext.c b/src/fe-common/core/printtext.c index e95c8e23..729a8c83 100644 --- a/src/fe-common/core/printtext.c +++ b/src/fe-common/core/printtext.c @@ -355,12 +355,9 @@ static char *output_format_text_args(TEXT_DEST_REC *dest, FORMAT_REC *format, char *arglist[10]; char buffer[200]; /* should be enough? (won't overflow even if it isn't) */ - const char *str; char code, *ret; int need_free; - str = text != NULL ? text : format->def; - /* read all optional arguments to arglist[] list so they can be used in any order.. */ read_arglist(va, format, @@ -370,20 +367,20 @@ static char *output_format_text_args(TEXT_DEST_REC *dest, FORMAT_REC *format, out = g_string_new(NULL); code = 0; - while (*str != '\0') { + while (*text != '\0') { if (code == '%') { /* color code */ - if (!expand_styles(out, *str, dest)) { + if (!expand_styles(out, *text, dest)) { g_string_append_c(out, '%'); g_string_append_c(out, '%'); - g_string_append_c(out, *str); + g_string_append_c(out, *text); } code = 0; } else if (code == '$') { /* argument */ char *ret; - ret = parse_special((char **) &str, active_win->active_server, + ret = parse_special((char **) &text, active_win->active_server, active_win->active, arglist, &need_free, NULL); if (ret != NULL) { @@ -401,13 +398,13 @@ static char *output_format_text_args(TEXT_DEST_REC *dest, FORMAT_REC *format, } code = 0; } else { - if (*str == '%' || *str == '$') - code = *str; + if (*text == '%' || *text == '$') + code = *text; else - g_string_append_c(out, *str); + g_string_append_c(out, *text); } - str++; + text++; } ret = out->str; @@ -435,7 +432,6 @@ char *output_format_get_text(const char *module, WINDOW_REC *window, va_start(va, formatnum); ret = output_format_text_args(&dest, &formats[formatnum], - module_theme == NULL ? NULL : module_theme->expanded_formats[formatnum], va); va_end(va); @@ -455,7 +451,6 @@ static char *output_format_text(TEXT_DEST_REC *dest, int formatnum, ...) va_start(va, formatnum); ret = output_format_text_args(dest, &fecommon_core_formats[formatnum], - module_theme == NULL ? NULL : module_theme->expanded_formats[formatnum], va); va_end(va); @@ -480,7 +475,6 @@ void printformat_module_args(const char *module, void *server, formats = g_hash_table_lookup(default_formats, module); str = output_format_text_args(&dest, &formats[formatnum], - module_theme == NULL ? NULL : module_theme->expanded_formats[formatnum], va); if (*str != '\0') print_string(&dest, str); g_free(str); @@ -510,7 +504,6 @@ void printformat_module_window_args(const char *module, WINDOW_REC *window, int formats = g_hash_table_lookup(default_formats, module); str = output_format_text_args(&dest, &formats[formatnum], - module_theme == NULL ? NULL : module_theme->expanded_formats[formatnum], va); if (*str != '\0') print_string(&dest, str); g_free(str); diff --git a/src/fe-common/core/themes.c b/src/fe-common/core/themes.c index f3e573f5..c9026e46 100644 --- a/src/fe-common/core/themes.c +++ b/src/fe-common/core/themes.c @@ -256,8 +256,8 @@ static char *theme_format_expand_abstract(THEME_REC *theme, data = g_hash_table_lookup(theme->abstracts, abstract); g_free(abstract); if (data == NULL) { - /* unknown abstract */ - return NULL; + /* unknown abstract, just display the data */ + data = "$0-"; } abstract = g_strdup(data); @@ -474,24 +474,18 @@ static void theme_set_format(THEME_REC *theme, MODULE_THEME_REC *rec, } } -static void theme_read_formats(CONFIG_REC *config, THEME_REC *theme, - const char *module) +static void theme_read_formats(THEME_REC *theme, const char *module, + CONFIG_REC *config, FORMAT_REC *formats, + MODULE_THEME_REC *rec) { - MODULE_THEME_REC *rec; - FORMAT_REC *formats; CONFIG_NODE *node; GSList *tmp; - formats = g_hash_table_lookup(default_formats, module); - if (formats == NULL) return; - node = config_node_traverse(config, "formats", FALSE); if (node == NULL) return; node = config_node_section(node, module, -1); if (node == NULL) return; - rec = theme_module_create(theme, module); - for (tmp = node->value; tmp != NULL; tmp = tmp->next) { node = tmp->data; @@ -502,26 +496,50 @@ static void theme_read_formats(CONFIG_REC *config, THEME_REC *theme, } } +static void theme_init_module(THEME_REC *theme, const char *module, + CONFIG_REC *config) +{ + MODULE_THEME_REC *rec; + FORMAT_REC *formats; + int n; + + formats = g_hash_table_lookup(default_formats, module); + g_return_if_fail(formats != NULL); + + rec = theme_module_create(theme, module); + + if (config != NULL) + theme_read_formats(theme, module, config, formats, rec); + + /* expand the remaining formats */ + for (n = 0; n < rec->count; n++) { + if (rec->expanded_formats[n] == NULL) { + rec->expanded_formats[n] = + theme_format_expand(theme, formats[n].def); + } + } +} + static void theme_read_module(THEME_REC *theme, const char *module) { CONFIG_REC *config; char *msg; config = config_open(theme->path, -1); - if (config == NULL) return; - - config_parse(config); - - if (config_last_error(mainconfig) != NULL) { - msg = g_strdup_printf(_("Ignored errors in theme:\n%s"), - config_last_error(mainconfig)); - signal_emit("gui dialog", 2, "error", msg); - g_free(msg); + if (config != NULL) { + config_parse(config); + + if (config_last_error(mainconfig) != NULL) { + msg = g_strdup_printf(_("Ignored errors in theme:\n%s"), + config_last_error(mainconfig)); + signal_emit("gui dialog", 2, "error", msg); + g_free(msg); + } } - theme_read_formats(config, theme, module); + theme_init_module(theme, module, config); - config_close(config); + if (config != NULL) config_close(config); } static void themes_read_module(const char *module) @@ -618,7 +636,7 @@ typedef struct { static void theme_read_modules(const char *module, void *value, THEME_READ_REC *rec) { - theme_read_formats(rec->config, rec->theme, module); + theme_init_module(rec->theme, module, rec->config); } static void theme_read(THEME_REC *theme, const char *path) |