diff options
author | Timo Sirainen <cras@irssi.org> | 2001-05-31 22:35:49 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-05-31 22:35:49 +0000 |
commit | 28899856a4211645c741f56ad64622a20b9b26dc (patch) | |
tree | 711a766b991156b916fae392b58e4e6c75efc925 | |
parent | 04cb7cfa2338f3c16bb53c8caba930e7aa18b3ae (diff) | |
download | irssi-28899856a4211645c741f56ad64622a20b9b26dc.zip |
removed "print text stripped" signal, the stripped text is now sent in
"print text" signal's third parameter
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1526 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | docs/signals.txt | 3 | ||||
-rw-r--r-- | src/fe-common/core/fe-core-commands.c | 2 | ||||
-rw-r--r-- | src/fe-common/core/fe-log.c | 9 | ||||
-rw-r--r-- | src/fe-common/core/hilight-text.c | 75 | ||||
-rw-r--r-- | src/fe-common/core/printtext.c | 13 |
5 files changed, 42 insertions, 60 deletions
diff --git a/docs/signals.txt b/docs/signals.txt index 203e8b0b..57d42125 100644 --- a/docs/signals.txt +++ b/docs/signals.txt @@ -254,8 +254,7 @@ keyboard.c: "keyinfo destroyed", KEYINFO_REC printtext.c: - "print text", TEXT_DEST_REC *dest, char *text - "print text stripped", TEXT_DEST_REC *dest, char *text + "print text", TEXT_DEST_REC *dest, char *text, char *stripped themes.c: "theme created", THEME_REC diff --git a/src/fe-common/core/fe-core-commands.c b/src/fe-common/core/fe-core-commands.c index 7b8f7f9b..9c0fbab8 100644 --- a/src/fe-common/core/fe-core-commands.c +++ b/src/fe-common/core/fe-core-commands.c @@ -170,7 +170,6 @@ static void event_command(const char *data) hide_output = TRUE; signal_add_first("print starting", (SIGNAL_FUNC) sig_stop); signal_add_first("print format", (SIGNAL_FUNC) sig_stop); - signal_add_first("print text stripped", (SIGNAL_FUNC) sig_stop); signal_add_first("print text", (SIGNAL_FUNC) sig_stop); } } @@ -181,7 +180,6 @@ static void event_command_last(const char *data) hide_output = FALSE; signal_remove("print starting", (SIGNAL_FUNC) sig_stop); signal_remove("print format", (SIGNAL_FUNC) sig_stop); - signal_remove("print text stripped", (SIGNAL_FUNC) sig_stop); signal_remove("print text", (SIGNAL_FUNC) sig_stop); } } diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index 60d96327..8bce482e 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -461,7 +461,8 @@ static void log_line(WINDOW_REC *window, SERVER_REC *server, g_strfreev(lines); } -static void sig_printtext_stripped(TEXT_DEST_REC *dest, const char *text) +static void sig_printtext(TEXT_DEST_REC *dest, const char *text, + const char *stripped) { if (skip_next_printtext) { skip_next_printtext = FALSE; @@ -469,7 +470,7 @@ static void sig_printtext_stripped(TEXT_DEST_REC *dest, const char *text) } log_line(dest->window, dest->server, dest->target, - dest->level, text); + dest->level, stripped); } static void sig_print_format(THEME_REC *theme, const char *module, @@ -631,7 +632,7 @@ void fe_log_init(void) command_bind("log stop", NULL, (SIGNAL_FUNC) cmd_log_stop); command_bind("window log", NULL, (SIGNAL_FUNC) cmd_window_log); command_bind("window logfile", NULL, (SIGNAL_FUNC) cmd_window_logfile); - signal_add_first("print text stripped", (SIGNAL_FUNC) sig_printtext_stripped); + signal_add_first("print text", (SIGNAL_FUNC) sig_printtext); signal_add("window item destroy", (SIGNAL_FUNC) sig_window_item_destroy); signal_add("window refnum changed", (SIGNAL_FUNC) sig_window_refnum_changed); signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected); @@ -657,7 +658,7 @@ void fe_log_deinit(void) command_unbind("log stop", (SIGNAL_FUNC) cmd_log_stop); command_unbind("window log", (SIGNAL_FUNC) cmd_window_log); command_unbind("window logfile", (SIGNAL_FUNC) cmd_window_logfile); - signal_remove("print text stripped", (SIGNAL_FUNC) sig_printtext_stripped); + signal_remove("print text", (SIGNAL_FUNC) sig_printtext); signal_remove("window item destroy", (SIGNAL_FUNC) sig_window_item_destroy); signal_remove("window refnum changed", (SIGNAL_FUNC) sig_window_refnum_changed); signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected); diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 197957f6..0a16c5b2 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -37,8 +37,7 @@ #include "formats.h" static NICKMATCH_REC *nickmatch; -static HILIGHT_REC *next_nick_hilight, *next_line_hilight; -static int next_hilight_start, next_hilight_end; +static HILIGHT_REC *next_nick_hilight; static int never_hilight_level, default_hilight_level; GSList *hilights; @@ -277,22 +276,24 @@ static void hilight_update_text_dest(TEXT_DEST_REC *dest, HILIGHT_REC *rec) dest->hilight_color = hilight_get_act_color(rec); } -static void sig_print_text_stripped(TEXT_DEST_REC *dest, const char *str) +static void sig_print_text(TEXT_DEST_REC *dest, const char *text, + const char *stripped) { - HILIGHT_REC *hilight; - - g_return_if_fail(str != NULL); + HILIGHT_REC *hilight; + char *color, *newstr; + int hilight_start, hilight_end, hilight_len; + hilight_start = hilight_end = 0; if (next_nick_hilight != NULL) { if (!next_nick_hilight->nick) { /* non-nick hilight wanted */ hilight = next_nick_hilight; next_nick_hilight = NULL; - if (!hilight_match_text(hilight, str, - &next_hilight_start, - &next_hilight_end)) { - next_hilight_start = 0; - next_hilight_end = strlen(str); + if (!hilight_match_text(hilight, stripped, + &hilight_start, + &hilight_end)) { + hilight_start = 0; + hilight_end = strlen(stripped); } } else { /* nick is highlighted, just set priority */ @@ -305,33 +306,23 @@ static void sig_print_text_stripped(TEXT_DEST_REC *dest, const char *str) return; hilight = hilight_match(dest->server, dest->target, - NULL, NULL, dest->level, str, - &next_hilight_start, - &next_hilight_end); - } - - if (hilight != NULL) { - /* update the level / hilight info */ - hilight_update_text_dest(dest, hilight); - - next_line_hilight = hilight; + NULL, NULL, dest->level, stripped, + &hilight_start, + &hilight_end); } -} -static void sig_print_text(TEXT_DEST_REC *dest, const char *str) -{ - char *color, *newstr; - int next_hilight_len; - - if (next_line_hilight == NULL) + if (hilight == NULL) return; - color = hilight_get_color(next_line_hilight); - next_hilight_len = next_hilight_end-next_hilight_start; + /* update the level / hilight info */ + hilight_update_text_dest(dest, hilight); + + color = hilight_get_color(hilight); + hilight_len = hilight_end-hilight_start; - if (!next_line_hilight->word) { + if (!hilight->word) { /* hilight whole line */ - char *tmp = strip_codes(str); + char *tmp = strip_codes(text); newstr = g_strconcat(color, tmp, NULL); g_free(tmp); } else { @@ -343,25 +334,25 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *str) tmp = g_string_new(NULL); /* start of the line */ - pos = strip_real_length(str, next_hilight_start, NULL, NULL); - g_string_append(tmp, str); + pos = strip_real_length(text, hilight_start, NULL, NULL); + g_string_append(tmp, text); g_string_truncate(tmp, pos); /* color */ g_string_append(tmp, color); /* middle of the line, stripped */ - middle = strip_codes(str+pos); + middle = strip_codes(text+pos); pos = tmp->len; g_string_append(tmp, middle); - g_string_truncate(tmp, pos+next_hilight_len); + g_string_truncate(tmp, pos+hilight_len); g_free(middle); /* end of the line */ - pos = strip_real_length(str, next_hilight_end, + pos = strip_real_length(text, hilight_end, &color_pos, &color_len); if (color_pos > 0) - lastcolor = g_strndup(str+color_pos, color_len); + lastcolor = g_strndup(text+color_pos, color_len); else { /* no colors in line, change back to default */ lastcolor = g_malloc0(3); @@ -369,15 +360,14 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *str) lastcolor[1] = FORMAT_STYLE_DEFAULTS; } g_string_append(tmp, lastcolor); - g_string_append(tmp, str+pos); + g_string_append(tmp, text+pos); g_free(lastcolor); newstr = tmp->str; g_string_free(tmp, FALSE); } - next_line_hilight = NULL; - signal_emit("print text", 2, dest, newstr); + signal_emit("print text", 3, dest, newstr, stripped); g_free(color); g_free(newstr); @@ -665,14 +655,12 @@ void hilight_text_init(void) settings_add_str("lookandfeel", "hilight_level", "PUBLIC DCCMSGS"); next_nick_hilight = NULL; - next_line_hilight = NULL; read_settings(); nickmatch = nickmatch_init(hilight_nick_cache); read_hilight_config(); - signal_add_first("print text stripped", (SIGNAL_FUNC) sig_print_text_stripped); signal_add_first("print text", (SIGNAL_FUNC) sig_print_text); signal_add("setup reread", (SIGNAL_FUNC) read_hilight_config); signal_add("setup changed", (SIGNAL_FUNC) read_settings); @@ -687,7 +675,6 @@ void hilight_text_deinit(void) hilights_destroy_all(); nickmatch_deinit(nickmatch); - signal_remove("print text stripped", (SIGNAL_FUNC) sig_print_text_stripped); signal_remove("print text", (SIGNAL_FUNC) sig_print_text); signal_remove("setup reread", (SIGNAL_FUNC) read_hilight_config); signal_remove("setup changed", (SIGNAL_FUNC) read_settings); diff --git a/src/fe-common/core/printtext.c b/src/fe-common/core/printtext.c index 38de158d..3bc7a85b 100644 --- a/src/fe-common/core/printtext.c +++ b/src/fe-common/core/printtext.c @@ -35,7 +35,6 @@ static int beep_msg_level, beep_when_away, beep_when_window_active; static int signal_gui_print_text; -static int signal_print_text_stripped; static int signal_print_text; static int signal_print_text_finished; static int signal_print_format; @@ -150,7 +149,7 @@ void printformat_module_gui(const char *module, int formatnum, ...) static void print_line(TEXT_DEST_REC *dest, const char *text) { - char *str, *tmp; + char *str, *tmp, *stripped; g_return_if_fail(dest != NULL); g_return_if_fail(text != NULL); @@ -159,13 +158,12 @@ static void print_line(TEXT_DEST_REC *dest, const char *text) str = format_add_linestart(text, tmp); g_free_not_null(tmp); - /* send the plain text version for logging etc.. */ - tmp = strip_codes(str); - signal_emit_id(signal_print_text_stripped, 2, dest, tmp); - g_free(tmp); + /* send both the formatted + stripped (for logging etc.) */ + stripped = strip_codes(str); + signal_emit_id(signal_print_text, 3, dest, str, stripped); - signal_emit_id(signal_print_text, 2, dest, str); g_free(str); + g_free(stripped); } /* append string to `out', expand newlines. */ @@ -434,7 +432,6 @@ void printtext_init(void) { sending_print_starting = FALSE; signal_gui_print_text = signal_get_uniq_id("gui print text"); - signal_print_text_stripped = signal_get_uniq_id("print text stripped"); signal_print_text = signal_get_uniq_id("print text"); signal_print_text_finished = signal_get_uniq_id("print text finished"); signal_print_format = signal_get_uniq_id("print format"); |