diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-11-23 08:18:22 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-11-23 08:49:54 +0100 |
commit | 87f74e9f9544a7e3b7e4ffd0acc40841b8eb79e8 (patch) | |
tree | c13466c75920da25ee3e80e838cb8a7b5bf6adf7 /src/gui | |
parent | 2b0c2747ade0b65c4d2bdeee2ee80c1529edb633 (diff) | |
download | weechat-87f74e9f9544a7e3b7e4ffd0acc40841b8eb79e8.zip |
core: add syntax highlighting in evaluation of expressions, add option weechat.color.eval_syntax_colors (issue #2042)
Syntax highlighting (raw string without evaluation): `${raw_hl:xxx}`
Syntax highlighting: `${hl:xxx}`
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index 26948eb0f..5d197b994 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -870,8 +870,8 @@ gui_color_info_term_colors (char *buffer, int size) void gui_color_buffer_display () { - int y, i, lines, columns, line, col, color, max_color, num_items; - char str_line[1024], str_color[64], str_rgb[64], **items; + int y, i, lines, columns, line, col, color, max_color; + char str_line[1024], str_color[64], str_rgb[64]; struct t_gui_color_palette *color_palette; if (!gui_color_buffer) @@ -1011,47 +1011,70 @@ gui_color_buffer_display () y++; gui_chat_printf_y (gui_color_buffer, y++, _("Nick colors:")); - items = string_split (CONFIG_STRING(config_color_chat_nick_colors), - ",", - NULL, - WEECHAT_STRING_SPLIT_STRIP_LEFT - | WEECHAT_STRING_SPLIT_STRIP_RIGHT - | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS, - 0, - &num_items); - if (items) + if (config_num_nick_colors > 0) { str_line[0] = '\0'; - for (i = 0; i < num_items; i++) + for (i = 0; i < config_num_nick_colors; i++) { if (gui_color_use_term_colors) { snprintf (str_color, sizeof (str_color), " %s", - items[i]); + config_nick_colors[i]); } else { snprintf (str_color, sizeof (str_color), "%c %s%s", GUI_COLOR_RESET_CHAR, - gui_color_get_custom (items[i]), - items[i]); + gui_color_get_custom (config_nick_colors[i]), + config_nick_colors[i]); } - if (gui_chat_strlen_screen (str_line) + gui_chat_strlen_screen (str_color) > 80) + if (gui_chat_strlen_screen (str_line) + + gui_chat_strlen_screen (str_color) > 80) { - gui_chat_printf_y (gui_color_buffer, y++, - " %s", str_line); + gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); str_line[0] = '\0'; } strcat (str_line, str_color); } if (str_line[0]) + gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); + } + + /* display eval syntax highlighting colors */ + y++; + gui_chat_printf_y (gui_color_buffer, y++, + _("Syntax highlighting colors in evaluated strings:")); + if (config_num_eval_syntax_colors > 0) + { + str_line[0] = '\0'; + for (i = 0; i < config_num_eval_syntax_colors; i++) { - gui_chat_printf_y (gui_color_buffer, y++, - " %s", str_line); + if (gui_color_use_term_colors) + { + snprintf (str_color, sizeof (str_color), + " %s", + config_eval_syntax_colors[i]); + } + else + { + snprintf (str_color, sizeof (str_color), + "%c %s%s", + GUI_COLOR_RESET_CHAR, + gui_color_get_custom (config_eval_syntax_colors[i]), + config_eval_syntax_colors[i]); + } + if (gui_chat_strlen_screen (str_line) + + gui_chat_strlen_screen (str_color) > 80) + { + gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); + str_line[0] = '\0'; + } + strcat (str_line, str_color); } - string_free_split (items); + if (str_line[0]) + gui_chat_printf_y (gui_color_buffer, y++, " %s", str_line); } /* display palette colors */ |