mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
Highlight colors can now have background color set with fg,bg. Works
with activity list too, useful for example blinking. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1249 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
1117638b52
commit
c1c7674ae2
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user