diff --git a/src/core/window-item-rec.h b/src/core/window-item-rec.h index dae5d5ec..134726c2 100644 --- a/src/core/window-item-rec.h +++ b/src/core/window-item-rec.h @@ -10,6 +10,6 @@ char *name; time_t createtime; int data_level; -int hilight_color; +int hilight_color, hilight_bg_color; #undef STRUCT_SERVER_REC diff --git a/src/fe-common/core/fe-windows.h b/src/fe-common/core/fe-windows.h index 12c47854..62869a49 100644 --- a/src/fe-common/core/fe-windows.h +++ b/src/fe-common/core/fe-windows.h @@ -42,7 +42,7 @@ typedef struct { int histlines; int data_level; /* current data level */ - int hilight_color; /* current hilight color */ + int hilight_color, hilight_bg_color; /* current hilight color */ time_t last_timestamp; /* When was last timestamp printed */ time_t last_line; /* When was last line printed */ diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c index 433defbc..1799e812 100644 --- a/src/fe-common/core/formats.c +++ b/src/fe-common/core/formats.c @@ -213,6 +213,7 @@ void format_create_dest(TEXT_DEST_REC *dest, dest->hilight_priority = 0; dest->hilight_color = 0; + dest->hilight_bg_color = 0; } static char *format_get_text_args(TEXT_DEST_REC *dest, diff --git a/src/fe-common/core/formats.h b/src/fe-common/core/formats.h index 5be7a4b5..2e2d6cff 100644 --- a/src/fe-common/core/formats.h +++ b/src/fe-common/core/formats.h @@ -38,7 +38,7 @@ typedef struct { int level; int hilight_priority; - int hilight_color; + int hilight_color, hilight_bg_color; } TEXT_DEST_REC; int format_find_tag(const char *module, const char *tag); diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 102db2bb..c85e1ced 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -291,11 +291,32 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, return NULL; } +static int get_colors(const char *color, int *fg, int *bg) +{ + const char *p; + + if (!is_numeric(color, ',')) + return FALSE; + + *fg = atoi(color); + *bg = -1; + + p = strchr(color, ','); + if (p != NULL) { + p++; + if (!is_numeric(p, '\0')) + return FALSE; + *bg = atoi(p); + } + + return TRUE; +} + char *hilight_get_color(HILIGHT_REC *rec, int activity) { const char *color; char number[MAX_INT_STRLEN]; - int colornum; + int colornum, fg, bg; g_return_val_if_fail(rec != NULL, NULL); @@ -315,15 +336,16 @@ char *hilight_get_color(HILIGHT_REC *rec, int activity) color = number; } - if (is_numeric(color, 0)) - return g_strdup_printf("\003%02d", atoi(color)); - + if (get_colors(color, &fg, &bg)) { + return bg == -1 ? g_strdup_printf("\003%02d", fg) : + g_strdup_printf("\003%d,%02d", fg, bg); + } return g_strdup(color); } static void hilight_update_text_dest(TEXT_DEST_REC *dest, HILIGHT_REC *rec) { - char *color; + char *color, *bgcolor; dest->level |= MSGLEVEL_HILIGHT; @@ -331,8 +353,14 @@ static void hilight_update_text_dest(TEXT_DEST_REC *dest, HILIGHT_REC *rec) dest->hilight_priority = rec->priority; color = hilight_get_color(rec, TRUE); - if (*color == 3) + if (*color == 3) { dest->hilight_color = atoi(color+1); + bgcolor = color+1; + while (*bgcolor != ',' && *bgcolor != '\0') + bgcolor++; + dest->hilight_bg_color = *bgcolor != ',' ? -1 : + atoi(bgcolor+1); + } g_free(color); } diff --git a/src/fe-common/core/window-activity.c b/src/fe-common/core/window-activity.c index f5a6d4a1..c928a498 100644 --- a/src/fe-common/core/window-activity.c +++ b/src/fe-common/core/window-activity.c @@ -35,8 +35,8 @@ static char **hide_targets; static int hide_level, msg_level, hilight_level; -static void window_activity(WINDOW_REC *window, - int data_level, int hilight_color) +static void window_activity(WINDOW_REC *window, int data_level, + int hilight_color, int hilight_bg_color) { int old_data_level; @@ -44,6 +44,7 @@ static void window_activity(WINDOW_REC *window, if (data_level == 0 || window->data_level < data_level) { window->data_level = data_level; window->hilight_color = hilight_color; + window->hilight_bg_color = hilight_bg_color; signal_emit("window hilight", 1, window); } @@ -51,8 +52,8 @@ static void window_activity(WINDOW_REC *window, GINT_TO_POINTER(old_data_level)); } -static void window_item_activity(WI_ITEM_REC *item, - int data_level, int hilight_color) +static void window_item_activity(WI_ITEM_REC *item, int data_level, + int hilight_color, int hilight_bg_color) { int old_data_level; @@ -60,6 +61,7 @@ static void window_item_activity(WI_ITEM_REC *item, if (data_level == 0 || item->data_level < data_level) { item->data_level = data_level; item->hilight_color = hilight_color; + item->hilight_bg_color = hilight_bg_color; signal_emit("window item hilight", 1, item); } @@ -94,10 +96,12 @@ static void sig_hilight_text(TEXT_DEST_REC *dest, const char *msg) item = window_item_find(dest->server, dest->target); if (item != NULL) { window_item_activity(item, data_level, - dest->hilight_color); + dest->hilight_color, + dest->hilight_bg_color); } } - window_activity(dest->window, data_level, dest->hilight_color); + window_activity(dest->window, data_level, + dest->hilight_color, dest->hilight_bg_color); } static void sig_dehilight_window(WINDOW_REC *window) @@ -107,9 +111,9 @@ static void sig_dehilight_window(WINDOW_REC *window) g_return_if_fail(window != NULL); if (window->data_level != 0) { - window_activity(window, 0, 0); + window_activity(window, 0, 0, 0); for (tmp = window->items; tmp != NULL; tmp = tmp->next) - window_item_activity(tmp->data, 0, 0); + window_item_activity(tmp->data, 0, 0, 0); } } diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c index 8243a9ac..035c77e1 100644 --- a/src/fe-text/statusbar-items.c +++ b/src/fe-text/statusbar-items.c @@ -353,9 +353,14 @@ static void draw_activity(gchar *title, gboolean act, gboolean det, int size) set_color(stdscr, sbar_color_bold); break; default: - if (window->hilight_color > 0) - set_color(stdscr, sbar_color_background | mirc_colors[window->hilight_color%16]); - else + if (window->hilight_color > 0) { + int bg; + + bg = window->hilight_bg_color == -1 ? + sbar_color_background : + (window->hilight_bg_color << 4); + set_color(stdscr, bg | mirc_colors[window->hilight_color%16]); + } else set_color(stdscr, sbar_color_act_highlight); break; }