mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 14:26:39 +02:00
Dynamically allocate color pairs
This commit introduces major changes in 256 colors support: - extended colors can be used without being added with command "/color add" - background color is now allowed for nick colors (using slash separator)
This commit is contained in:
+48
-49
@@ -889,7 +889,7 @@ COMMAND_CALLBACK(buffer)
|
||||
|
||||
COMMAND_CALLBACK(color)
|
||||
{
|
||||
char *str_alias, *str_pair, *str_rgb, *pos, *error;
|
||||
char *str_alias, *str_rgb, *pos, *error;
|
||||
char str_color[1024], str_command[1024];
|
||||
long number;
|
||||
int i;
|
||||
@@ -905,17 +905,17 @@ COMMAND_CALLBACK(color)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* add a color pair */
|
||||
/* add a color */
|
||||
if (string_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
COMMAND_MIN_ARGS(3, "color add");
|
||||
COMMAND_MIN_ARGS(4, "color add");
|
||||
|
||||
/* check pair number */
|
||||
/* check color number */
|
||||
error = NULL;
|
||||
number = strtol (argv[2], &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
if ((number < 1) || (number > gui_color_get_last_pair ()))
|
||||
if ((number < 0) || (number > gui_color_get_term_colors ()))
|
||||
number = -1;
|
||||
}
|
||||
else
|
||||
@@ -925,30 +925,23 @@ COMMAND_CALLBACK(color)
|
||||
if (number < 0)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sInvalid pair number \"%s\" (must be between "
|
||||
"%d and %d)"),
|
||||
_("%sInvalid color number \"%s\" (must be "
|
||||
"between %d and %d)"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
argv[2], 1, gui_color_get_last_pair ());
|
||||
argv[2], 0, gui_color_get_term_colors ());
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/* check other arguments */
|
||||
str_alias = NULL;
|
||||
str_pair = NULL;
|
||||
str_rgb = NULL;
|
||||
for (i = 3; i < argc; i++)
|
||||
{
|
||||
pos = strchr (argv[i], ',');
|
||||
pos = strchr (argv[i], '/');
|
||||
if (pos)
|
||||
str_pair = argv[i];
|
||||
str_rgb = argv[i];
|
||||
else
|
||||
{
|
||||
pos = strchr (argv[i], '/');
|
||||
if (pos)
|
||||
str_rgb = argv[i];
|
||||
else
|
||||
str_alias = argv[i];
|
||||
}
|
||||
str_alias = argv[i];
|
||||
}
|
||||
str_color[0] = '\0';
|
||||
if (str_alias)
|
||||
@@ -956,18 +949,13 @@ COMMAND_CALLBACK(color)
|
||||
strcat (str_color, ";");
|
||||
strcat (str_color, str_alias);
|
||||
}
|
||||
if (str_pair)
|
||||
{
|
||||
strcat (str_color, ";");
|
||||
strcat (str_color, str_pair);
|
||||
}
|
||||
if (str_rgb)
|
||||
{
|
||||
strcat (str_color, ";");
|
||||
strcat (str_color, str_rgb);
|
||||
}
|
||||
|
||||
/* add color pair */
|
||||
/* add color */
|
||||
snprintf (str_command, sizeof (str_command),
|
||||
"/set weechat.palette.%d \"%s\"",
|
||||
(int)number,
|
||||
@@ -976,17 +964,17 @@ COMMAND_CALLBACK(color)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* delete a color pair */
|
||||
/* delete a color */
|
||||
if (string_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
COMMAND_MIN_ARGS(3, "color del");
|
||||
|
||||
/* check pair number */
|
||||
/* check color number */
|
||||
error = NULL;
|
||||
number = strtol (argv[2], &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
if ((number < 1) || (number > gui_color_get_last_pair ()))
|
||||
if ((number < 0) || (number > gui_color_get_term_colors ()))
|
||||
number = -1;
|
||||
}
|
||||
else
|
||||
@@ -996,14 +984,14 @@ COMMAND_CALLBACK(color)
|
||||
if (number < 0)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sInvalid pair number \"%s\" (must be between "
|
||||
"%d and %d)"),
|
||||
_("%sInvalid color number \"%s\" (must be "
|
||||
"between %d and %d)"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
argv[2], 1, gui_color_get_last_pair ());
|
||||
argv[2], 0, gui_color_get_term_colors ());
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/* search color pair */
|
||||
/* search color */
|
||||
color_palette = gui_color_palette_get ((int)number);
|
||||
if (!color_palette)
|
||||
{
|
||||
@@ -1014,7 +1002,7 @@ COMMAND_CALLBACK(color)
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/* delete color pair */
|
||||
/* delete color */
|
||||
snprintf (str_command, sizeof (str_command),
|
||||
"/unset weechat.palette.%d",
|
||||
(int)number);
|
||||
@@ -1022,6 +1010,13 @@ COMMAND_CALLBACK(color)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* reset color pairs */
|
||||
if (string_strcasecmp (argv[1], "reset") == 0)
|
||||
{
|
||||
gui_color_reset_pairs ();
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* switch WeeChat/terminal colors */
|
||||
if (string_strcasecmp (argv[1], "switch") == 0)
|
||||
{
|
||||
@@ -1138,6 +1133,10 @@ COMMAND_CALLBACK(debug)
|
||||
{
|
||||
gui_window_term_display_infos ();
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "color") == 0)
|
||||
{
|
||||
gui_color_dump (buffer);
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "set") == 0)
|
||||
{
|
||||
COMMAND_MIN_ARGS(4, "debug set");
|
||||
@@ -4524,27 +4523,25 @@ command_init ()
|
||||
" || %(buffers_numbers)",
|
||||
&command_buffer, NULL);
|
||||
hook_command (NULL, "color",
|
||||
N_("define custom colors and display palette of colors"),
|
||||
N_("[add pair [alias] [fg,bg]] | [del pair] | switch"),
|
||||
N_(" add: add a color pair\n"
|
||||
" del: delete a color pair\n"
|
||||
"switch: switch WeeChat/terminal colors\n"
|
||||
" pair: pair number (>= 1)\n"
|
||||
N_("define color aliases and display palette of colors"),
|
||||
N_("[add color alias] | [del color] | reset"),
|
||||
N_(" add: add an alias for a color\n"
|
||||
" del: delete an alias\n"
|
||||
" color: color number (>= 1, max depends on terminal, "
|
||||
"commonly 63 or 255)\n"
|
||||
" alias: alias name for color (for example: \"orange\")\n"
|
||||
" fg,bg: foreground and background pair number (-1 for "
|
||||
"default terminal foreground or background)\n\n"
|
||||
" reset: reset all color pairs (useful when no more "
|
||||
"pairs are available)\n\n"
|
||||
"Without argument, this command displays colors in a new "
|
||||
"buffer.\n\n"
|
||||
"Examples:\n"
|
||||
" add color 214 with alias \"orange\":\n"
|
||||
" add alias \"orange\" for color 214:\n"
|
||||
" /color add 214 orange\n"
|
||||
" add color 250 with orange on blue:\n"
|
||||
" /color add 250 214,4 orange_blue\n"
|
||||
" delete color 214:\n"
|
||||
" /color del 214"),
|
||||
"add %(color_pairs)"
|
||||
" || del %(color_pairs)"
|
||||
" || switch",
|
||||
"add %(palette_colors)"
|
||||
" || del %(palette_colors)"
|
||||
" || reset",
|
||||
&command_color, NULL);
|
||||
hook_command (NULL, "command",
|
||||
N_("launch explicit WeeChat or plugin command"),
|
||||
@@ -4558,7 +4555,7 @@ command_init ()
|
||||
hook_command (NULL, "debug",
|
||||
N_("control debug for core/plugins"),
|
||||
N_("[list | set plugin level | dump [plugin] | buffer | "
|
||||
"windows | term]"),
|
||||
"windows | term | color]"),
|
||||
N_(" set: set log level for plugin\n"
|
||||
" plugin: name of plugin (\"core\" for WeeChat core)\n"
|
||||
" level: debug level for plugin (0 = disable debug)\n"
|
||||
@@ -4568,13 +4565,15 @@ command_init ()
|
||||
"in log file\n"
|
||||
"windows: display windows tree\n"
|
||||
" term: display infos about terminal and available "
|
||||
"colors"),
|
||||
"colors\n"
|
||||
" color: display infos about current color pairs"),
|
||||
"list"
|
||||
" || set %(plugins_names)|core"
|
||||
" || dump %(plugins_names)|core"
|
||||
" || buffer"
|
||||
" || windows"
|
||||
" || term",
|
||||
" || term"
|
||||
" || color",
|
||||
&command_debug, NULL);
|
||||
hook_command (NULL, "filter",
|
||||
N_("filter messages in buffers, to hide/show them according "
|
||||
|
||||
+36
-18
@@ -261,13 +261,13 @@ completion_list_add_buffer_properties_get_cb (void *data,
|
||||
}
|
||||
|
||||
/*
|
||||
* completion_list_map_add_color_cb: add color pairs in completion
|
||||
* completion_list_map_add_palette_color_cb: add palette color in completion
|
||||
*/
|
||||
|
||||
void
|
||||
completion_list_map_add_color_cb (void *data,
|
||||
struct t_hashtable *hashtable,
|
||||
const void *key, const void *value)
|
||||
completion_list_map_add_palette_color_cb (void *data,
|
||||
struct t_hashtable *hashtable,
|
||||
const void *key, const void *value)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
@@ -279,14 +279,14 @@ completion_list_map_add_color_cb (void *data,
|
||||
}
|
||||
|
||||
/*
|
||||
* completion_list_add_color_pairs_cb: add color pairs (in section "palette")
|
||||
* completion_list_add_palette_colors_cb: add colors (in section "palette")
|
||||
*/
|
||||
|
||||
int
|
||||
completion_list_add_color_pairs_cb (void *data,
|
||||
const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
completion_list_add_palette_colors_cb (void *data,
|
||||
const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -294,7 +294,7 @@ completion_list_add_color_pairs_cb (void *data,
|
||||
(void) buffer;
|
||||
|
||||
hashtable_map (gui_color_hash_palette_color,
|
||||
&completion_list_map_add_color_cb,
|
||||
&completion_list_map_add_palette_color_cb,
|
||||
completion);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -776,12 +776,13 @@ completion_list_add_config_option_values_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
char *pos_space, *option_full_name, *pos_section, *pos_option;
|
||||
char *file, *section, *value_string;
|
||||
char *file, *section, *value_string, str_number[64];
|
||||
const char *color_name;
|
||||
int length, i, num_colors;
|
||||
struct t_config_file *ptr_config;
|
||||
struct t_config_section *ptr_section, *section_found;
|
||||
struct t_config_option *option_found;
|
||||
struct t_gui_color_palette *color_palette;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -943,15 +944,32 @@ completion_list_add_config_option_values_cb (void *data,
|
||||
{
|
||||
color_name = gui_color_get_name (i);
|
||||
if (color_name)
|
||||
{
|
||||
gui_completion_list_add (completion,
|
||||
color_name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
}
|
||||
if (gui_color_hash_palette_alias)
|
||||
num_colors = gui_color_get_term_colors ();
|
||||
for (i = 0; i <= num_colors; i++)
|
||||
{
|
||||
hashtable_map (gui_color_hash_palette_alias,
|
||||
&completion_list_map_add_color_alias_cb,
|
||||
completion);
|
||||
color_palette = gui_color_palette_get (i);
|
||||
if (color_palette)
|
||||
{
|
||||
gui_completion_list_add (completion,
|
||||
color_palette->alias,
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (str_number,
|
||||
sizeof (str_number),
|
||||
"%d",
|
||||
i);
|
||||
gui_completion_list_add (completion,
|
||||
str_number,
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
}
|
||||
gui_completion_list_add (completion, "++1",
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
@@ -1195,9 +1213,9 @@ completion_init ()
|
||||
hook_completion (NULL, "buffer_properties_get",
|
||||
N_("properties that can be read on a buffer"),
|
||||
&completion_list_add_buffer_properties_get_cb, NULL);
|
||||
hook_completion (NULL, "color_pairs",
|
||||
N_("color pairs"),
|
||||
&completion_list_add_color_pairs_cb, NULL);
|
||||
hook_completion (NULL, "palette_colors",
|
||||
N_("palette colors"),
|
||||
&completion_list_add_palette_colors_cb, NULL);
|
||||
hook_completion (NULL, "config_files", /* formerly "%c" */
|
||||
N_("configuration files"),
|
||||
&completion_list_add_config_files_cb, NULL);
|
||||
|
||||
@@ -251,7 +251,7 @@ config_change_buffers (void *data, struct t_config_option *option)
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
gui_window_refresh_windows ();
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -384,7 +384,7 @@ config_change_prefix_align_min (void *data, struct t_config_option *option)
|
||||
if (ptr_buffer->mixed_lines)
|
||||
gui_line_compute_prefix_max_length (ptr_buffer->mixed_lines);
|
||||
}
|
||||
gui_window_refresh_windows ();
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -400,9 +400,8 @@ config_change_color (void *data, struct t_config_option *option)
|
||||
|
||||
if (gui_ok)
|
||||
{
|
||||
gui_color_init_pairs ();
|
||||
gui_color_init_weechat ();
|
||||
gui_window_refresh_windows ();
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -742,10 +741,7 @@ config_weechat_palette_create_option_cb (void *data,
|
||||
ptr_option = config_file_new_option (
|
||||
config_file, section,
|
||||
option_name, "string",
|
||||
_("custom color in palette, format is: \"alias;fg,bg\" "
|
||||
"where alias is color name, fg,bg is \"foreground,background\" "
|
||||
"(example: \"200,-1\") (everything is optional "
|
||||
"in this format and order is not important)"),
|
||||
_("alias for color"),
|
||||
NULL, 0, 0, "", value, 0, NULL, NULL,
|
||||
&config_weechat_palette_change_cb, NULL,
|
||||
NULL, NULL);
|
||||
@@ -1879,7 +1875,8 @@ config_weechat_init_options ()
|
||||
config_color_chat_nick_colors = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"chat_nick_colors", "string",
|
||||
N_("text color for nicks (comma separated list of colors)"),
|
||||
N_("text color for nicks (comma separated list of colors, background "
|
||||
"is allowed with format: \"fg/bg\", for example: \"blue/red\")"),
|
||||
NULL, 0, 0, "cyan,magenta,green,brown,lightblue,default,lightcyan,"
|
||||
"lightmagenta,lightgreen,blue", NULL, 0,
|
||||
NULL, NULL, &config_change_nick_colors, NULL, NULL, NULL);
|
||||
|
||||
@@ -156,8 +156,8 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
int hide_chars_if_scrolling)
|
||||
{
|
||||
int weechat_color, x_with_hidden, size_on_screen, fg, bg, low_char, hidden;
|
||||
int pair, rc;
|
||||
char str_fg[3], str_bg[3], str_pair[6], utf_char[16], *next_char, *output;
|
||||
int pair;
|
||||
char str_fg[6], str_bg[6], str_pair[6], utf_char[16], *next_char, *output;
|
||||
char *error;
|
||||
|
||||
if (!string || !string[0])
|
||||
@@ -185,56 +185,150 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
switch (string[0])
|
||||
{
|
||||
case GUI_COLOR_FG_CHAR: /* fg color */
|
||||
if (string[1] && string[2])
|
||||
if (string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
str_fg[0] = string[1];
|
||||
str_fg[1] = string[2];
|
||||
str_fg[2] = '\0';
|
||||
rc = sscanf (str_fg, "%d", &fg);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
if (string[2] && string[3] && string[4]
|
||||
&& string[5] && string[6])
|
||||
{
|
||||
gui_window_set_custom_color_fg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
fg);
|
||||
memcpy (str_fg, string + 2, 5);
|
||||
str_fg[5] = '\0';
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_custom_color_fg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
fg | GUI_COLOR_PAIR_FLAG);
|
||||
}
|
||||
string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string[1] && string[2])
|
||||
{
|
||||
str_fg[0] = string[1];
|
||||
str_fg[1] = string[2];
|
||||
str_fg[2] = '\0';
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_custom_color_fg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
fg);
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
break;
|
||||
case GUI_COLOR_BG_CHAR: /* bg color */
|
||||
if (string[1] && string[2])
|
||||
if (string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
str_bg[0] = string[1];
|
||||
str_bg[1] = string[2];
|
||||
str_bg[2] = '\0';
|
||||
rc = sscanf (str_bg, "%d", &bg);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
if (string[2] && string[3] && string[4]
|
||||
&& string[5] && string[6])
|
||||
{
|
||||
gui_window_set_custom_color_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
bg);
|
||||
memcpy (str_bg, string + 2, 5);
|
||||
str_bg[5] = '\0';
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_custom_color_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
bg | GUI_COLOR_PAIR_FLAG);
|
||||
}
|
||||
string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string[1] && string[2])
|
||||
{
|
||||
str_bg[0] = string[1];
|
||||
str_bg[1] = string[2];
|
||||
str_bg[2] = '\0';
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_custom_color_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
bg);
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
break;
|
||||
case GUI_COLOR_FG_BG_CHAR: /* fg + bg color */
|
||||
if (string[1] && string[2] && (string[3] == ',')
|
||||
&& string[4] && string[5])
|
||||
str_fg[0] = '\0';
|
||||
str_bg[0] = '\0';
|
||||
fg = -1;
|
||||
bg = -1;
|
||||
if (string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
str_fg[0] = string[1];
|
||||
str_fg[1] = string[2];
|
||||
str_fg[2] = '\0';
|
||||
str_bg[0] = string[4];
|
||||
str_bg[1] = string[5];
|
||||
str_bg[2] = '\0';
|
||||
rc = sscanf (str_fg, "%d", &fg);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
if (string[2] && string[3] && string[4]
|
||||
&& string[5] && string[6])
|
||||
{
|
||||
rc = sscanf (str_bg, "%d", &bg);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
memcpy (str_fg, string + 2, 5);
|
||||
str_fg[5] = '\0';
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (!error || error[0])
|
||||
fg = -1;
|
||||
else
|
||||
fg |= GUI_COLOR_PAIR_FLAG;
|
||||
string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string[1] && string[2])
|
||||
{
|
||||
str_fg[0] = string[1];
|
||||
str_fg[1] = string[2];
|
||||
str_fg[2] = '\0';
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (!error || error[0])
|
||||
fg = -1;
|
||||
string += 3;
|
||||
}
|
||||
}
|
||||
if (str_fg[0] && (string[0] == ','))
|
||||
{
|
||||
string++;
|
||||
if (string[0] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
if (string[1] && string[2] && string[3]
|
||||
&& string[4] && string[5])
|
||||
{
|
||||
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
fg, bg);
|
||||
memcpy (str_bg, string + 1, 5);
|
||||
str_bg[5] = '\0';
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (!error || error[0])
|
||||
bg = -1;
|
||||
else
|
||||
bg |= GUI_COLOR_PAIR_FLAG;
|
||||
string += 6;
|
||||
}
|
||||
}
|
||||
string += 6;
|
||||
else
|
||||
{
|
||||
if (string[0] && string[1])
|
||||
{
|
||||
str_bg[0] = string[0];
|
||||
str_bg[1] = string[1];
|
||||
str_bg[2] = '\0';
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (!error || error[0])
|
||||
bg = -1;
|
||||
string += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((fg >= 0) && (bg >= 0))
|
||||
{
|
||||
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
fg, bg);
|
||||
}
|
||||
break;
|
||||
case GUI_COLOR_PAIR_CHAR: /* pair number */
|
||||
@@ -303,8 +397,9 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
str_fg[0] = string[0];
|
||||
str_fg[1] = string[1];
|
||||
str_fg[2] = '\0';
|
||||
rc = sscanf (str_fg, "%d", &weechat_color);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
error = NULL;
|
||||
weechat_color = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_weechat_color (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
weechat_color);
|
||||
@@ -500,6 +595,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
|
||||
gui_bar_window_set_current_size (bar_window, window, 1);
|
||||
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
|
||||
}
|
||||
else
|
||||
@@ -554,6 +650,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
}
|
||||
|
||||
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
|
||||
x = 0;
|
||||
y = 0;
|
||||
@@ -714,6 +811,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
|
||||
gui_bar_window_set_current_size (bar_window, window, 1);
|
||||
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ gui_chat_string_next_char (struct t_gui_window *window,
|
||||
const unsigned char *string, int apply_style)
|
||||
{
|
||||
char str_fg[3], str_bg[3], str_pair[6], *error;
|
||||
int weechat_color, fg, bg, pair, rc;
|
||||
int weechat_color, fg, bg, pair;
|
||||
|
||||
while (string[0])
|
||||
{
|
||||
@@ -196,65 +196,174 @@ gui_chat_string_next_char (struct t_gui_window *window,
|
||||
switch (string[0])
|
||||
{
|
||||
case GUI_COLOR_FG_CHAR: /* fg color */
|
||||
if (string[1] && string[2])
|
||||
if (string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
if (apply_style)
|
||||
if (string[2] && string[3] && string[4]
|
||||
&& string[5] && string[6])
|
||||
{
|
||||
str_fg[0] = string[1];
|
||||
str_fg[1] = string[2];
|
||||
str_fg[2] = '\0';
|
||||
rc = sscanf (str_fg, "%d", &fg);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
if (apply_style)
|
||||
{
|
||||
gui_window_set_custom_color_fg (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
fg);
|
||||
memcpy (str_fg, string + 2, 5);
|
||||
str_fg[5] = '\0';
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_custom_color_fg (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
fg | GUI_COLOR_PAIR_FLAG);
|
||||
}
|
||||
}
|
||||
string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string[1] && string[2])
|
||||
{
|
||||
if (apply_style)
|
||||
{
|
||||
str_fg[0] = string[1];
|
||||
str_fg[1] = string[2];
|
||||
str_fg[2] = '\0';
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_custom_color_fg (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
fg);
|
||||
}
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
break;
|
||||
case GUI_COLOR_BG_CHAR: /* bg color */
|
||||
if (string[1] && string[2])
|
||||
if (string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
if (apply_style)
|
||||
if (string[2] && string[3] && string[4]
|
||||
&& string[5] && string[6])
|
||||
{
|
||||
str_bg[0] = string[1];
|
||||
str_bg[1] = string[2];
|
||||
str_bg[2] = '\0';
|
||||
rc = sscanf (str_bg, "%d", &bg);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
if (apply_style)
|
||||
{
|
||||
gui_window_set_custom_color_bg (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
bg);
|
||||
memcpy (str_bg, string + 2, 5);
|
||||
str_bg[5] = '\0';
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_custom_color_bg (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
bg | GUI_COLOR_PAIR_FLAG);
|
||||
}
|
||||
}
|
||||
string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string[1] && string[2])
|
||||
{
|
||||
if (apply_style)
|
||||
{
|
||||
str_bg[0] = string[1];
|
||||
str_bg[1] = string[2];
|
||||
str_bg[2] = '\0';
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_custom_color_bg (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
bg);
|
||||
}
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
break;
|
||||
case GUI_COLOR_FG_BG_CHAR: /* fg + bg color */
|
||||
if (string[1] && string[2] && (string[3] == ',')
|
||||
&& string[4] && string[5])
|
||||
str_fg[0] = '\0';
|
||||
str_bg[0] = '\0';
|
||||
fg = -1;
|
||||
bg = -1;
|
||||
if (string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
if (apply_style)
|
||||
if (string[2] && string[3] && string[4]
|
||||
&& string[5] && string[6])
|
||||
{
|
||||
str_fg[0] = string[1];
|
||||
str_fg[1] = string[2];
|
||||
str_fg[2] = '\0';
|
||||
str_bg[0] = string[4];
|
||||
str_bg[1] = string[5];
|
||||
str_bg[2] = '\0';
|
||||
rc = sscanf (str_fg, "%d", &fg);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
if (apply_style)
|
||||
{
|
||||
rc = sscanf (str_bg, "%d", &bg);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
memcpy (str_fg, string + 2, 5);
|
||||
str_fg[5] = '\0';
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (!error || error[0])
|
||||
fg = -1;
|
||||
else
|
||||
fg |= GUI_COLOR_PAIR_FLAG;
|
||||
}
|
||||
string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string[1] && string[2])
|
||||
{
|
||||
if (apply_style)
|
||||
{
|
||||
str_fg[0] = string[1];
|
||||
str_fg[1] = string[2];
|
||||
str_fg[2] = '\0';
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (!error || error[0])
|
||||
fg = -1;
|
||||
}
|
||||
string += 3;
|
||||
}
|
||||
}
|
||||
if (string[0] == ',')
|
||||
{
|
||||
string++;
|
||||
if (string[0] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
if (string[1] && string[2] && string[3]
|
||||
&& string[4] && string[5])
|
||||
{
|
||||
if (apply_style)
|
||||
{
|
||||
gui_window_set_custom_color_fg_bg (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
fg, bg);
|
||||
memcpy (str_bg, string + 1, 5);
|
||||
str_bg[5] = '\0';
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (!error || error[0])
|
||||
bg = -1;
|
||||
else
|
||||
bg |= GUI_COLOR_PAIR_FLAG;
|
||||
}
|
||||
string += 6;
|
||||
}
|
||||
}
|
||||
string += 6;
|
||||
else
|
||||
{
|
||||
if (string[0] && string[1])
|
||||
{
|
||||
if (apply_style)
|
||||
{
|
||||
str_bg[0] = string[0];
|
||||
str_bg[1] = string[1];
|
||||
str_bg[2] = '\0';
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (!error || error[0])
|
||||
bg = -1;
|
||||
}
|
||||
string += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (apply_style && (fg >= 0) && (bg >= 0))
|
||||
{
|
||||
gui_window_set_custom_color_fg_bg (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
fg, bg);
|
||||
}
|
||||
break;
|
||||
case GUI_COLOR_PAIR_CHAR: /* pair number */
|
||||
@@ -301,8 +410,9 @@ gui_chat_string_next_char (struct t_gui_window *window,
|
||||
str_fg[0] = string[0];
|
||||
str_fg[1] = string[1];
|
||||
str_fg[2] = '\0';
|
||||
rc = sscanf (str_fg, "%d", &weechat_color);
|
||||
if ((rc != EOF) && (rc >= 1))
|
||||
error = NULL;
|
||||
weechat_color = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
weechat_color);
|
||||
@@ -1028,7 +1138,7 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
|
||||
if (gui_chat_display_word_raw (window, line->data->message,
|
||||
window->win_chat_width, 1) < window->win_chat_width)
|
||||
{
|
||||
gui_window_clrtoeol_with_current_bg (GUI_WINDOW_OBJECTS(window)->win_chat);
|
||||
gui_window_clrtoeol (GUI_WINDOW_OBJECTS(window)->win_chat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+702
-340
File diff suppressed because it is too large
Load Diff
@@ -224,6 +224,13 @@ gui_main_refreshs ()
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
/* refresh color buffer if needed */
|
||||
if (gui_color_buffer_refresh_needed)
|
||||
{
|
||||
gui_color_buffer_display ();
|
||||
gui_color_buffer_refresh_needed = 0;
|
||||
}
|
||||
|
||||
/* refresh window if needed */
|
||||
if (gui_window_refresh_needed)
|
||||
|
||||
@@ -205,22 +205,24 @@ gui_window_clear_weechat (WINDOW *window, int weechat_color)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_clear (WINDOW *window, int bg)
|
||||
gui_window_clear (WINDOW *window, int fg, int bg)
|
||||
{
|
||||
int color;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if ((bg >= 0) && (bg < GUI_CURSES_NUM_WEECHAT_COLORS))
|
||||
{
|
||||
color = gui_weechat_colors[bg].background;
|
||||
wbkgdset (window,
|
||||
' ' | COLOR_PAIR (((color == -1) || (color == 99)) ?
|
||||
gui_color_last_pair : (color * gui_color_num_bg) + 1));
|
||||
werase (window);
|
||||
wmove (window, 0, 0);
|
||||
}
|
||||
|
||||
if ((fg > 0) && (fg & GUI_COLOR_PAIR_FLAG))
|
||||
fg &= GUI_COLOR_PAIR_MASK;
|
||||
else
|
||||
fg = gui_weechat_colors[fg].foreground;
|
||||
|
||||
if ((bg > 0) && (bg & GUI_COLOR_PAIR_FLAG))
|
||||
bg &= GUI_COLOR_PAIR_MASK;
|
||||
else
|
||||
bg = gui_weechat_colors[bg].background;
|
||||
|
||||
wbkgdset (window, ' ' | COLOR_PAIR (gui_color_get_pair (fg, bg)));
|
||||
werase (window);
|
||||
wmove (window, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -273,17 +275,7 @@ gui_window_set_color (WINDOW *window, int fg, int bg)
|
||||
window_current_style_fg = fg;
|
||||
window_current_style_bg = bg;
|
||||
|
||||
if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
wattron (window, COLOR_PAIR(gui_color_last_pair));
|
||||
else
|
||||
{
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
wattron (window, COLOR_PAIR((bg * gui_color_num_bg) + fg + 1));
|
||||
}
|
||||
wattron (window, COLOR_PAIR(gui_color_get_pair (fg, bg)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -293,21 +285,19 @@ gui_window_set_color (WINDOW *window, int fg, int bg)
|
||||
void
|
||||
gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if ((num_color >= 0) && (num_color < GUI_COLOR_NUM_COLORS))
|
||||
{
|
||||
gui_window_reset_style (window, num_color);
|
||||
wattron (window, gui_color[num_color]->attributes);
|
||||
if ((gui_color[num_color]->foreground > 0)
|
||||
&& (gui_color[num_color]->foreground & GUI_COLOR_PAIR_FLAG))
|
||||
{
|
||||
wattron (window, COLOR_PAIR(gui_color[num_color]->foreground & GUI_COLOR_PAIR_MASK));
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_window_set_color (window,
|
||||
gui_color[num_color]->foreground,
|
||||
gui_color[num_color]->background);
|
||||
}
|
||||
fg = gui_color[num_color]->foreground;
|
||||
bg = gui_color[num_color]->background;
|
||||
if ((fg > 0) && (fg & GUI_COLOR_PAIR_FLAG))
|
||||
fg &= GUI_COLOR_PAIR_MASK;
|
||||
if ((bg > 0) && (bg & GUI_COLOR_PAIR_FLAG))
|
||||
bg &= GUI_COLOR_PAIR_MASK;
|
||||
gui_window_set_color (window, fg, bg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,30 +309,27 @@ gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
void
|
||||
gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
|
||||
{
|
||||
if ((fg >= 0) && (fg < GUI_CURSES_NUM_WEECHAT_COLORS)
|
||||
&& (bg >= 0) && (bg < GUI_CURSES_NUM_WEECHAT_COLORS))
|
||||
if ((fg >= 0) && (bg >= 0))
|
||||
{
|
||||
gui_window_remove_color_style (window, A_BOLD);
|
||||
wattron (window, gui_weechat_colors[fg].attributes);
|
||||
gui_window_set_color (window,
|
||||
gui_weechat_colors[fg].foreground,
|
||||
(gui_color_num_bg > 8) ?
|
||||
gui_weechat_colors[bg].background : gui_weechat_colors[bg].foreground);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_set_custom_color_pair: set a custom color for a window
|
||||
* (pair number)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_set_custom_color_pair (WINDOW *window, int pair)
|
||||
{
|
||||
if ((pair >= 0) && (pair <= gui_color_last_pair))
|
||||
{
|
||||
gui_window_remove_color_style (window, A_BOLD);
|
||||
wattron (window, COLOR_PAIR(pair));
|
||||
|
||||
if ((fg > 0) && (fg & GUI_COLOR_PAIR_FLAG))
|
||||
fg &= GUI_COLOR_PAIR_MASK;
|
||||
else
|
||||
{
|
||||
wattron (window, gui_weechat_colors[fg].attributes);
|
||||
fg = gui_weechat_colors[fg].foreground;
|
||||
}
|
||||
|
||||
if ((bg > 0) && (bg & GUI_COLOR_PAIR_FLAG))
|
||||
bg &= GUI_COLOR_PAIR_MASK;
|
||||
else
|
||||
{
|
||||
bg = (gui_color_num_bg > 8) ?
|
||||
gui_weechat_colors[bg].background : gui_weechat_colors[bg].foreground;
|
||||
}
|
||||
|
||||
gui_window_set_color (window, fg, bg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,16 +342,17 @@ void
|
||||
gui_window_set_custom_color_fg (WINDOW *window, int fg)
|
||||
{
|
||||
int current_bg;
|
||||
|
||||
|
||||
if (fg >= 0)
|
||||
{
|
||||
if (fg & GUI_COLOR_PAIR_FLAG)
|
||||
current_bg = window_current_style_bg;
|
||||
|
||||
if ((fg > 0) && (fg & GUI_COLOR_PAIR_FLAG))
|
||||
{
|
||||
gui_window_set_custom_color_pair (window, fg & GUI_COLOR_PAIR_MASK);
|
||||
gui_window_set_color (window, fg & GUI_COLOR_PAIR_MASK, current_bg);
|
||||
}
|
||||
else if (fg < GUI_CURSES_NUM_WEECHAT_COLORS)
|
||||
{
|
||||
current_bg = window_current_style_bg;
|
||||
gui_window_remove_color_style (window, A_BOLD);
|
||||
gui_window_set_color_style (window, gui_weechat_colors[fg].attributes);
|
||||
gui_window_set_color (window,
|
||||
@@ -386,14 +374,15 @@ gui_window_set_custom_color_bg (WINDOW *window, int bg)
|
||||
|
||||
if (bg >= 0)
|
||||
{
|
||||
if (bg & GUI_COLOR_PAIR_FLAG)
|
||||
current_attr = window_current_style_attr;
|
||||
current_fg = window_current_style_fg;
|
||||
|
||||
if ((bg > 0) && (bg & GUI_COLOR_PAIR_FLAG))
|
||||
{
|
||||
gui_window_set_custom_color_pair (window, bg & GUI_COLOR_PAIR_MASK);
|
||||
gui_window_set_color (window, current_fg, bg & GUI_COLOR_PAIR_MASK);
|
||||
}
|
||||
else if (bg < GUI_CURSES_NUM_WEECHAT_COLORS)
|
||||
{
|
||||
current_attr = window_current_style_attr;
|
||||
current_fg = window_current_style_fg;
|
||||
gui_window_set_color_style (window, current_attr);
|
||||
gui_window_set_color (window, current_fg,
|
||||
(gui_color_num_bg > 8) ?
|
||||
@@ -403,15 +392,30 @@ gui_window_set_custom_color_bg (WINDOW *window, int bg)
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_clrtoeol_with_current_bg: clear until end of line with current bg
|
||||
* gui_window_set_custom_color_pair: set a custom color for a window
|
||||
* (pair number)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_clrtoeol_with_current_bg (WINDOW *window)
|
||||
gui_window_set_custom_color_pair (WINDOW *window, int pair)
|
||||
{
|
||||
if ((pair >= 0) && (pair <= gui_color_num_pairs))
|
||||
{
|
||||
gui_window_remove_color_style (window, A_BOLD);
|
||||
wattron (window, COLOR_PAIR(pair));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_clrtoeol: clear until end of line with current background
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_clrtoeol (WINDOW *window)
|
||||
{
|
||||
wbkgdset (window,
|
||||
' ' | COLOR_PAIR ((window_current_style_bg < 0) ?
|
||||
gui_color_last_pair : (window_current_style_bg * gui_color_num_bg) + 1));
|
||||
' ' | COLOR_PAIR (gui_color_get_pair (window_current_style_fg,
|
||||
window_current_style_bg)));
|
||||
wclrtoeol (window);
|
||||
}
|
||||
|
||||
@@ -1526,8 +1530,6 @@ gui_window_term_display_infos ()
|
||||
gui_chat_printf (NULL, _("Terminal infos:"));
|
||||
gui_chat_printf (NULL, _(" TERM='%s', size: %dx%d"),
|
||||
getenv("TERM"), gui_term_cols, gui_term_lines);
|
||||
gui_chat_printf (NULL, _(" %d colors available, %d pairs"),
|
||||
COLORS, COLOR_PAIRS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -57,10 +57,12 @@ struct t_gui_bar_window_curses_objects
|
||||
|
||||
extern int gui_term_cols, gui_term_lines;
|
||||
extern struct t_gui_color gui_weechat_colors[];
|
||||
extern int gui_color_last_pair;
|
||||
extern int gui_color_num_pairs;
|
||||
extern int gui_color_num_bg;
|
||||
extern int gui_color_buffer_refresh_needed;
|
||||
|
||||
/* color functions */
|
||||
extern int gui_color_get_pair (int fg, int bg);
|
||||
extern int gui_color_weechat_get_pair (int weechat_color);
|
||||
extern void gui_color_pre_init ();
|
||||
extern void gui_color_init ();
|
||||
@@ -79,7 +81,7 @@ extern int gui_keyboard_read_cb (void *data, int fd);
|
||||
extern void gui_window_read_terminal_size ();
|
||||
extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer);
|
||||
extern int gui_window_get_hline_char ();
|
||||
extern void gui_window_clear (WINDOW *window, int bg);
|
||||
extern void gui_window_clear (WINDOW *window, int fg, int bg);
|
||||
extern void gui_window_reset_style (WINDOW *window, int num_color);
|
||||
extern void gui_window_set_color_style (WINDOW *window, int style);
|
||||
extern void gui_window_remove_color_style (WINDOW *window, int style);
|
||||
@@ -89,7 +91,7 @@ extern void gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg);
|
||||
extern void gui_window_set_custom_color_pair (WINDOW *window, int pair);
|
||||
extern void gui_window_set_custom_color_fg (WINDOW *window, int fg);
|
||||
extern void gui_window_set_custom_color_bg (WINDOW *window, int bg);
|
||||
extern void gui_window_clrtoeol_with_current_bg (WINDOW *window);
|
||||
extern void gui_window_clrtoeol (WINDOW *window);
|
||||
extern void gui_window_set_title (const char *title);
|
||||
|
||||
#endif /* __WEECHAT_GUI_CURSES_H */
|
||||
|
||||
@@ -147,17 +147,6 @@ void
|
||||
gui_chat_set_color (struct t_gui_window *window, int fg, int bg)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
/*if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
wattron (window->win_chat, COLOR_PAIR(63));
|
||||
else
|
||||
{
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = WEECHAT_COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
wattron (window->win_chat, COLOR_PAIR((bg * 8) + fg));
|
||||
}*/
|
||||
(void) window;
|
||||
(void) fg;
|
||||
(void) bg;
|
||||
|
||||
+72
-75
@@ -132,15 +132,40 @@ gui_color_get_weechat_colors_number ()
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_get_last_pair: get last pair number
|
||||
* gui_color_get_term_colors: get number of colors supported by terminal
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_get_last_pair ()
|
||||
gui_color_get_term_colors ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_get_pair: get a pair with given foreground/background colors
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_get_pair (int fg, int bg)
|
||||
{
|
||||
(void) fg;
|
||||
(void) bg;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_weechat_get_pair: get color pair with a WeeChat color number
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_weechat_get_pair (int weechat_color)
|
||||
{
|
||||
(void) weechat_color;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_get_name: get color name
|
||||
*/
|
||||
@@ -151,53 +176,6 @@ gui_color_get_name (int num_color)
|
||||
return gui_weechat_colors[num_color].string;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_get_pair: get color pair with a WeeChat color number
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_get_pair (int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if ((num_color < 0) || (num_color > GUI_COLOR_NUM_COLORS - 1))
|
||||
return WEECHAT_COLOR_WHITE;
|
||||
|
||||
fg = gui_color[num_color]->foreground;
|
||||
bg = gui_color[num_color]->background;
|
||||
|
||||
if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
return 63;
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = WEECHAT_COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
|
||||
return (bg * 8) + fg;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init_pair: init a color pair
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init_pair (int number)
|
||||
{
|
||||
/* This function does nothing in Gtk GUI */
|
||||
(void) number;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init_pairs: init color pairs
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init_pairs ()
|
||||
{
|
||||
/* This function does nothing in Gtk GUI */
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init_weechat: init WeeChat colors
|
||||
*/
|
||||
@@ -230,32 +208,6 @@ gui_color_rebuild_weechat ()
|
||||
gui_color_init_weechat ();
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_pre_init: pre-init colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_pre_init ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
|
||||
{
|
||||
gui_color[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init: init GUI colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init ()
|
||||
{
|
||||
gui_color_init_pairs ();
|
||||
gui_color_init_weechat ();
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_display_terminal_colors: display terminal colors
|
||||
* This is called by command line option
|
||||
@@ -288,6 +240,16 @@ gui_color_switch_colors ()
|
||||
/* This function does nothing in Gtk GUI */
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_reset_pairs: reset all color pairs
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_reset_pairs ()
|
||||
{
|
||||
/* This function does nothing in Gtk GUI */
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_buffer_assign: assign color buffer to pointer if it is not yet set
|
||||
*/
|
||||
@@ -343,6 +305,41 @@ gui_color_palette_free (struct t_gui_color_palette *color_palette)
|
||||
(void) color_palette;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_pre_init: pre-init colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_pre_init ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
|
||||
{
|
||||
gui_color[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init: init GUI colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init ()
|
||||
{
|
||||
gui_color_init_weechat ();
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_dump: dump colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_dump ()
|
||||
{
|
||||
/* This function does nothing in Gtk GUI */
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_end: end GUI colors
|
||||
*/
|
||||
|
||||
@@ -88,7 +88,7 @@ extern GtkWidget *gui_gtk_entry_input;
|
||||
extern GtkWidget *gui_gtk_label1;
|
||||
|
||||
/* color functions */
|
||||
extern int gui_color_get_pair (int num_color);
|
||||
extern int gui_color_get_pair (int fg, int bg);
|
||||
extern void gui_color_pre_init ();
|
||||
extern void gui_color_init ();
|
||||
extern void gui_color_end ();
|
||||
|
||||
@@ -888,7 +888,7 @@ void
|
||||
gui_buffer_set_nicklist (struct t_gui_buffer *buffer, int nicklist)
|
||||
{
|
||||
buffer->nicklist = (nicklist) ? 1 : 0;
|
||||
gui_window_refresh_windows ();
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -913,7 +913,7 @@ gui_buffer_set_nicklist_display_groups (struct t_gui_buffer *buffer,
|
||||
buffer->nicklist_display_groups = (display_groups) ? 1 : 0;
|
||||
buffer->nicklist_visible_count = 0;
|
||||
gui_nicklist_compute_visible_count (buffer, buffer->nicklist_root);
|
||||
gui_window_refresh_windows ();
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+178
-109
@@ -91,10 +91,11 @@ gui_color_search_config (const char *color_name)
|
||||
const char *
|
||||
gui_color_get_custom (const char *color_name)
|
||||
{
|
||||
int fg, bg, pair;
|
||||
int fg, bg, fg_pair, bg_pair, pair;
|
||||
static char color[32][16];
|
||||
static int index_color = 0;
|
||||
char *pos_comma, *str_fg, *pos_bg, *error;
|
||||
char color_fg[32], color_bg[32];
|
||||
char *pos_delim, *str_fg, *pos_bg, *error;
|
||||
|
||||
/* attribute or other color name (GUI dependent) */
|
||||
index_color = (index_color + 1) % 32;
|
||||
@@ -106,64 +107,64 @@ gui_color_get_custom (const char *color_name)
|
||||
if (string_strcasecmp (color_name, "reset") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s",
|
||||
GUI_COLOR_RESET_STR);
|
||||
"%c",
|
||||
GUI_COLOR_RESET_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "bold") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_SET_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_BOLD_STR);
|
||||
"%c%c",
|
||||
GUI_COLOR_SET_WEECHAT_CHAR,
|
||||
GUI_COLOR_ATTR_BOLD_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "-bold") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_REMOVE_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_BOLD_STR);
|
||||
"%c%c",
|
||||
GUI_COLOR_REMOVE_WEECHAT_CHAR,
|
||||
GUI_COLOR_ATTR_BOLD_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "reverse") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_SET_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_REVERSE_STR);
|
||||
"%c%c",
|
||||
GUI_COLOR_SET_WEECHAT_CHAR,
|
||||
GUI_COLOR_ATTR_REVERSE_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "-reverse") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_REMOVE_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_REVERSE_STR);
|
||||
"%c%c",
|
||||
GUI_COLOR_REMOVE_WEECHAT_CHAR,
|
||||
GUI_COLOR_ATTR_REVERSE_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "italic") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_SET_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_ITALIC_STR);
|
||||
"%c%c",
|
||||
GUI_COLOR_SET_WEECHAT_CHAR,
|
||||
GUI_COLOR_ATTR_ITALIC_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "-italic") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_REMOVE_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_ITALIC_STR);
|
||||
"%c%c",
|
||||
GUI_COLOR_REMOVE_WEECHAT_CHAR,
|
||||
GUI_COLOR_ATTR_ITALIC_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "underline") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_SET_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_UNDERLINE_STR);
|
||||
"%c%c",
|
||||
GUI_COLOR_SET_WEECHAT_CHAR,
|
||||
GUI_COLOR_ATTR_UNDERLINE_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "-underline") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_REMOVE_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_UNDERLINE_STR);
|
||||
"%c%c",
|
||||
GUI_COLOR_REMOVE_WEECHAT_CHAR,
|
||||
GUI_COLOR_ATTR_UNDERLINE_CHAR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "bar_fg") == 0)
|
||||
{
|
||||
@@ -192,86 +193,121 @@ gui_color_get_custom (const char *color_name)
|
||||
else
|
||||
{
|
||||
/* custom color name (GUI dependent) */
|
||||
pair = gui_color_palette_get_alias (color_name);
|
||||
if (pair >= 0)
|
||||
pos_delim = strchr (color_name, ',');
|
||||
if (!pos_delim)
|
||||
pos_delim = strchr (color_name, '/');
|
||||
if (pos_delim)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s%05d",
|
||||
GUI_COLOR_COLOR_STR,
|
||||
GUI_COLOR_PAIR_STR,
|
||||
pair);
|
||||
if (pos_delim == color_name)
|
||||
str_fg = NULL;
|
||||
else
|
||||
str_fg = string_strndup (color_name, pos_delim - color_name);
|
||||
pos_bg = pos_delim + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = NULL;
|
||||
pair = (int)strtol (color_name, &error, 10);
|
||||
if (error && !error[0])
|
||||
str_fg = strdup (color_name);
|
||||
pos_bg = NULL;
|
||||
}
|
||||
|
||||
fg_pair = -1;
|
||||
bg_pair = -1;
|
||||
fg = -1;
|
||||
bg = -1;
|
||||
color_fg[0] = '\0';
|
||||
color_bg[0] = '\0';
|
||||
|
||||
if (str_fg)
|
||||
{
|
||||
fg_pair = gui_color_palette_get_alias (str_fg);
|
||||
if (fg_pair < 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s%05d",
|
||||
GUI_COLOR_COLOR_STR,
|
||||
GUI_COLOR_PAIR_STR,
|
||||
pair);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos_comma = strchr (color_name, ',');
|
||||
if (pos_comma)
|
||||
error = NULL;
|
||||
pair = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
if (pos_comma == color_name)
|
||||
str_fg = NULL;
|
||||
else
|
||||
str_fg = string_strndup (color_name, pos_comma - color_name);
|
||||
pos_bg = pos_comma + 1;
|
||||
fg_pair = pair;
|
||||
if (fg_pair < 0)
|
||||
fg_pair = 0;
|
||||
else if (fg_pair > 99999)
|
||||
fg_pair = 99999;
|
||||
}
|
||||
else
|
||||
{
|
||||
str_fg = strdup (color_name);
|
||||
pos_bg = NULL;
|
||||
}
|
||||
|
||||
if (str_fg && pos_bg)
|
||||
{
|
||||
fg = gui_color_search (str_fg);
|
||||
bg = gui_color_search (pos_bg);
|
||||
if ((fg >= 0) && (bg >= 0))
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s%02d,%02d",
|
||||
GUI_COLOR_COLOR_STR,
|
||||
GUI_COLOR_FG_BG_STR,
|
||||
fg, bg);
|
||||
}
|
||||
}
|
||||
else if (str_fg && !pos_bg)
|
||||
{
|
||||
fg = gui_color_search (str_fg);
|
||||
if (fg >= 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s%02d",
|
||||
GUI_COLOR_COLOR_STR,
|
||||
GUI_COLOR_FG_STR,
|
||||
fg);
|
||||
}
|
||||
}
|
||||
else if (!str_fg && pos_bg)
|
||||
{
|
||||
bg = gui_color_search (pos_bg);
|
||||
if (bg >= 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s%02d",
|
||||
GUI_COLOR_COLOR_STR,
|
||||
GUI_COLOR_BG_STR,
|
||||
bg);
|
||||
}
|
||||
}
|
||||
|
||||
if (str_fg)
|
||||
free (str_fg);
|
||||
}
|
||||
}
|
||||
if (pos_bg)
|
||||
{
|
||||
bg_pair = gui_color_palette_get_alias (pos_bg);
|
||||
if (bg_pair < 0)
|
||||
{
|
||||
error = NULL;
|
||||
pair = (int)strtol (pos_bg, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
bg_pair = pair;
|
||||
if (bg_pair < 0)
|
||||
bg_pair = 0;
|
||||
else if (bg_pair > 99999)
|
||||
bg_pair = 99999;
|
||||
}
|
||||
else
|
||||
bg = gui_color_search (pos_bg);
|
||||
}
|
||||
}
|
||||
|
||||
if (fg_pair >= 0)
|
||||
{
|
||||
snprintf (color_fg, sizeof (color_fg), "%c%05d",
|
||||
GUI_COLOR_PAIR_CHAR,
|
||||
fg_pair);
|
||||
}
|
||||
else if (fg >= 0)
|
||||
{
|
||||
snprintf (color_fg, sizeof (color_fg), "%02d",
|
||||
fg);
|
||||
}
|
||||
|
||||
if (bg_pair >= 0)
|
||||
{
|
||||
snprintf (color_bg, sizeof (color_bg), "%c%05d",
|
||||
GUI_COLOR_PAIR_CHAR,
|
||||
bg_pair);
|
||||
}
|
||||
else if (bg >= 0)
|
||||
{
|
||||
snprintf (color_bg, sizeof (color_bg), "%02d",
|
||||
bg);
|
||||
}
|
||||
|
||||
if (color_fg[0] && color_bg[0])
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%c%c%s,%s",
|
||||
GUI_COLOR_COLOR_CHAR,
|
||||
GUI_COLOR_FG_BG_CHAR,
|
||||
color_fg,
|
||||
color_bg);
|
||||
}
|
||||
else if (color_fg[0])
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%c%c%s",
|
||||
GUI_COLOR_COLOR_CHAR,
|
||||
GUI_COLOR_FG_CHAR,
|
||||
color_fg);
|
||||
}
|
||||
else if (color_bg[0])
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%c%c%s",
|
||||
GUI_COLOR_COLOR_CHAR,
|
||||
GUI_COLOR_BG_CHAR,
|
||||
color_bg);
|
||||
}
|
||||
|
||||
if (str_fg)
|
||||
free (str_fg);
|
||||
}
|
||||
|
||||
return color[index_color];
|
||||
@@ -314,13 +350,51 @@ gui_color_decode (const char *string, const char *replacement)
|
||||
{
|
||||
case GUI_COLOR_FG_CHAR:
|
||||
case GUI_COLOR_BG_CHAR:
|
||||
if (ptr_string[1] && ptr_string[2])
|
||||
ptr_string += 3;
|
||||
if (ptr_string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
if (ptr_string[2] && ptr_string[3] && ptr_string[4]
|
||||
&& ptr_string[5] && ptr_string[6])
|
||||
{
|
||||
ptr_string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ptr_string[1] && ptr_string[2])
|
||||
ptr_string += 3;
|
||||
}
|
||||
break;
|
||||
case GUI_COLOR_FG_BG_CHAR:
|
||||
if (ptr_string[1] && ptr_string[2] && (ptr_string[3] == ',')
|
||||
&& ptr_string[4] && ptr_string[5])
|
||||
ptr_string += 6;
|
||||
if (ptr_string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
if (ptr_string[2] && ptr_string[3] && ptr_string[4]
|
||||
&& ptr_string[5] && ptr_string[6])
|
||||
{
|
||||
ptr_string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ptr_string[1] && ptr_string[2])
|
||||
ptr_string += 3;
|
||||
}
|
||||
if (ptr_string[0] == ',')
|
||||
{
|
||||
if (ptr_string[1] == GUI_COLOR_PAIR_CHAR)
|
||||
{
|
||||
if (ptr_string[2] && ptr_string[3]
|
||||
&& ptr_string[4] && ptr_string[5]
|
||||
&& ptr_string[6])
|
||||
{
|
||||
ptr_string += 7;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ptr_string[1] && ptr_string[2])
|
||||
ptr_string += 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GUI_COLOR_PAIR_CHAR:
|
||||
if ((isdigit (ptr_string[1])) && (isdigit (ptr_string[2]))
|
||||
@@ -582,17 +656,14 @@ gui_color_palette_add (int number, const char *value)
|
||||
new_color_palette = gui_color_palette_new (number, value);
|
||||
if (!new_color_palette)
|
||||
return;
|
||||
|
||||
|
||||
snprintf (str_number, sizeof (str_number), "%d", number);
|
||||
hashtable_set (gui_color_hash_palette_color,
|
||||
str_number, new_color_palette);
|
||||
gui_color_palette_build_aliases ();
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
gui_color_init_pair (number);
|
||||
gui_color_buffer_display ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -614,11 +685,9 @@ gui_color_palette_remove (int number)
|
||||
{
|
||||
hashtable_remove (gui_color_hash_palette_color, str_number);
|
||||
gui_color_palette_build_aliases ();
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
gui_color_init_pair (number);
|
||||
gui_color_buffer_display ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-23
@@ -69,52 +69,36 @@ enum t_gui_color_enum
|
||||
/* WeeChat internal color attributes (should never be in protocol messages) */
|
||||
|
||||
#define GUI_COLOR_COLOR_CHAR '\x19'
|
||||
#define GUI_COLOR_COLOR_STR "\x19"
|
||||
#define GUI_COLOR_SET_WEECHAT_CHAR '\x1A'
|
||||
#define GUI_COLOR_SET_WEECHAT_STR "\x1A"
|
||||
#define GUI_COLOR_REMOVE_WEECHAT_CHAR '\x1B'
|
||||
#define GUI_COLOR_REMOVE_WEECHAT_STR "\x1B"
|
||||
#define GUI_COLOR_RESET_CHAR '\x1C'
|
||||
#define GUI_COLOR_RESET_STR "\x1C"
|
||||
|
||||
#define GUI_COLOR_ATTR_BOLD_CHAR '\x01'
|
||||
#define GUI_COLOR_ATTR_BOLD_STR "\x01"
|
||||
#define GUI_COLOR_ATTR_REVERSE_CHAR '\x02'
|
||||
#define GUI_COLOR_ATTR_REVERSE_STR "\x02"
|
||||
#define GUI_COLOR_ATTR_ITALIC_CHAR '\x03'
|
||||
#define GUI_COLOR_ATTR_ITALIC_STR "\x03"
|
||||
#define GUI_COLOR_ATTR_UNDERLINE_CHAR '\x04'
|
||||
#define GUI_COLOR_ATTR_UNDERLINE_STR "\x04"
|
||||
|
||||
#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "")
|
||||
#define GUI_NO_COLOR GUI_COLOR_RESET_STR
|
||||
#define GUI_NO_COLOR "\x1C"
|
||||
|
||||
#define GUI_COLOR_CUSTOM_BAR_FG (gui_color_get_custom ("bar_fg"))
|
||||
#define GUI_COLOR_CUSTOM_BAR_DELIM (gui_color_get_custom ("bar_delim"))
|
||||
#define GUI_COLOR_CUSTOM_BAR_BG (gui_color_get_custom ("bar_bg"))
|
||||
|
||||
/* color codes for chat and bars */
|
||||
#define GUI_COLOR_FG_CHAR 'F'
|
||||
#define GUI_COLOR_FG_STR "F"
|
||||
#define GUI_COLOR_BG_CHAR 'B'
|
||||
#define GUI_COLOR_BG_STR "B"
|
||||
#define GUI_COLOR_FG_BG_CHAR '*'
|
||||
#define GUI_COLOR_FG_BG_STR "*"
|
||||
#define GUI_COLOR_PAIR_CHAR '@'
|
||||
#define GUI_COLOR_PAIR_STR "@"
|
||||
|
||||
/* color codes specific to bars */
|
||||
#define GUI_COLOR_BAR_CHAR 'b'
|
||||
#define GUI_COLOR_BAR_STR "b"
|
||||
#define GUI_COLOR_BAR_FG_CHAR 'F'
|
||||
#define GUI_COLOR_BAR_FG_STR "F"
|
||||
#define GUI_COLOR_BAR_DELIM_CHAR 'D'
|
||||
#define GUI_COLOR_BAR_DELIM_STR "D"
|
||||
#define GUI_COLOR_BAR_BG_CHAR 'B'
|
||||
#define GUI_COLOR_BAR_BG_STR "B"
|
||||
#define GUI_COLOR_BAR_START_INPUT_CHAR '_'
|
||||
#define GUI_COLOR_BAR_START_INPUT_STR "_"
|
||||
#define GUI_COLOR_BAR_START_INPUT_HIDDEN_CHAR '-'
|
||||
#define GUI_COLOR_BAR_START_INPUT_HIDDEN_STR "-"
|
||||
#define GUI_COLOR_BAR_MOVE_CURSOR_CHAR '#'
|
||||
#define GUI_COLOR_BAR_MOVE_CURSOR_STR "#"
|
||||
|
||||
#define GUI_COLOR_PAIR_FLAG 0x10000
|
||||
#define GUI_COLOR_PAIR_MASK 0xFFFF
|
||||
@@ -134,8 +118,6 @@ struct t_gui_color
|
||||
struct t_gui_color_palette
|
||||
{
|
||||
char *alias; /* alias name for this color pair */
|
||||
int foreground; /* foreground color */
|
||||
int background; /* background color */
|
||||
int r, g, b; /* red/green/blue values for color */
|
||||
};
|
||||
|
||||
@@ -167,7 +149,7 @@ extern int gui_color_assign (int *color, char const *color_name);
|
||||
extern int gui_color_assign_by_diff (int *color, const char *color_name,
|
||||
int diff);
|
||||
extern int gui_color_get_weechat_colors_number ();
|
||||
extern int gui_color_get_last_pair ();
|
||||
extern int gui_color_get_term_colors ();
|
||||
extern const char *gui_color_get_name (int num_color);
|
||||
extern void gui_color_init_pair (int number);
|
||||
extern void gui_color_init_pairs ();
|
||||
@@ -175,11 +157,13 @@ extern void gui_color_init_weechat ();
|
||||
extern void gui_color_display_terminal_colors ();
|
||||
extern void gui_color_buffer_display ();
|
||||
extern void gui_color_switch_colors ();
|
||||
extern void gui_color_reset_pairs ();
|
||||
extern void gui_color_buffer_assign ();
|
||||
extern void gui_color_buffer_open ();
|
||||
extern void gui_color_palette_build_aliases ();
|
||||
extern struct t_gui_color_palette *gui_color_palette_new (int number,
|
||||
const char *value);
|
||||
extern void gui_color_palette_free (struct t_gui_color_palette *color_palette);
|
||||
extern void gui_color_dump ();
|
||||
|
||||
#endif /* __WEECHAT_GUI_COLOR_H */
|
||||
|
||||
@@ -158,7 +158,6 @@ extern void gui_window_scroll_up (struct t_gui_window *window);
|
||||
extern void gui_window_scroll_down (struct t_gui_window *window);
|
||||
extern void gui_window_scroll_top (struct t_gui_window *window);
|
||||
extern void gui_window_scroll_bottom (struct t_gui_window *window);
|
||||
extern void gui_window_refresh_windows ();
|
||||
extern struct t_gui_window *gui_window_split_horizontal (struct t_gui_window *window,
|
||||
int percentage);
|
||||
extern struct t_gui_window *gui_window_split_vertical (struct t_gui_window *window,
|
||||
|
||||
Reference in New Issue
Block a user