diff options
-rw-r--r-- | ChangeLog.adoc | 2 | ||||
-rw-r--r-- | src/gui/gui-color.c | 33 | ||||
-rw-r--r-- | tests/unit/gui/test-gui-color.cpp | 18 |
3 files changed, 52 insertions, 1 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 3b2578884..159e1f258 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -55,7 +55,7 @@ New features:: Bug fixes:: - * core: fix conversion of WeeChat "default" color to ANSI color + * core: fix conversion of WeeChat colors to ANSI colors: "default", "bar_fg", "bar_bg", "bar_delim" * core: fix recursive search of group in nicklist * core: use nick offline highlight color for prefix of action message when the nick is offline with a highlight * core: add missing hdata name "buffer" in hdata "hotlist" diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index c895d5e7c..8823bde65 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -1544,8 +1544,41 @@ gui_color_encode_ansi (const char *string) switch (ptr_string[0]) { case GUI_COLOR_BAR_FG_CHAR: + snprintf (str_concat, sizeof (str_concat), + "\x1B[%dm", + GUI_COLOR_ANSI_DEFAULT_FG); + string_dyn_concat (out, str_concat, -1); + ptr_string++; + break; case GUI_COLOR_BAR_BG_CHAR: + snprintf (str_concat, sizeof (str_concat), + "\x1B[%dm", + GUI_COLOR_ANSI_DEFAULT_BG); + string_dyn_concat (out, str_concat, -1); + ptr_string++; + break; case GUI_COLOR_BAR_DELIM_CHAR: + color = CONFIG_COLOR(config_color_chat_delimiters); + if (color & GUI_COLOR_EXTENDED_FLAG) + { + snprintf (str_concat, sizeof (str_concat), + "\x1B[48;5;%dm", + color & GUI_COLOR_EXTENDED_MASK); + } + else + { + ansi_color = gui_color_weechat_to_ansi ( + CONFIG_COLOR(config_color_chat_delimiters)); + snprintf (str_concat, sizeof (str_concat), + "\x1B[%dm", + (ansi_color < 0) ? + GUI_COLOR_ANSI_DEFAULT_FG : + ((ansi_color < 8) ? + ansi_color + 40 : ansi_color - 8 + 100)); + } + string_dyn_concat (out, str_concat, -1); + ptr_string++; + break; case GUI_COLOR_BAR_START_INPUT_CHAR: case GUI_COLOR_BAR_START_INPUT_HIDDEN_CHAR: case GUI_COLOR_BAR_MOVE_CURSOR_CHAR: diff --git a/tests/unit/gui/test-gui-color.cpp b/tests/unit/gui/test-gui-color.cpp index d2f618429..15fbf0f17 100644 --- a/tests/unit/gui/test-gui-color.cpp +++ b/tests/unit/gui/test-gui-color.cpp @@ -797,6 +797,24 @@ TEST(GuiColor, EncodeAnsi) gui_color_get_custom ("default")); WEE_CHECK_ENCODE_ANSI("test_" "\x1B[39m" "default", string); + /* text color: bar foreground -> ANSI: 39 (default fg color) */ + snprintf (string, sizeof (string), + "test_" "%s" "bar_fg", + gui_color_get_custom ("bar_fg")); + WEE_CHECK_ENCODE_ANSI("test_" "\x1B[39m" "bar_fg", string); + + /* text color: bar background -> ANSI: 49 (default bg color) */ + snprintf (string, sizeof (string), + "test_" "%s" "bar_bg", + gui_color_get_custom ("bar_bg")); + WEE_CHECK_ENCODE_ANSI("test_" "\x1B[49m" "bar_bg", string); + + /* text color: bar delimiter -> color in option weechat.color.chat_delimiters */ + snprintf (string, sizeof (string), + "test_" "%s" "bar_delim", + gui_color_get_custom ("bar_delim")); + WEE_CHECK_ENCODE_ANSI("test_" "\x1B[48;5;22m" "bar_delim", string); + /* text color */ snprintf (string, sizeof (string), "test_" "%s" "blue", |