From 177fa6c528031ab77b2f03783e7dcacb3152c3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 29 Sep 2019 16:30:57 +0200 Subject: [PATCH] core: add support of reverse video in ANSI color codes --- ChangeLog.adoc | 1 + src/gui/gui-color.c | 6 ++++++ tests/unit/gui/test-gui-color.cpp | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 521798eb3..7f96ef05a 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -28,6 +28,7 @@ New features:: Bug fixes:: + * core: add support of reverse video in ANSI color codes * core: fixed segfault during excessive evaluation in function string_repeat (issue #1400) * buflist: fix extra spaces between buffers when conditions are used to hide buffers (regression introduced in version 2.6) (issue #1403) * irc: remove option irc.network.channel_encode, add server option "charset_message" to control which part of the IRC message is decoded/encoded to the target charset (issue #832) diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index 6115ff472..cbebc317a 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -833,12 +833,18 @@ gui_color_decode_ansi_cb (void *data, const char *text) case 4: /* underline */ strcat (output, gui_color_get_custom ("underline")); break; + case 7: /* reverse */ + strcat (output, gui_color_get_custom ("reverse")); + break; case 23: /* remove italic */ strcat (output, gui_color_get_custom ("-italic")); break; case 24: /* remove underline */ strcat (output, gui_color_get_custom ("-underline")); break; + case 27: /* remove reverse */ + strcat (output, gui_color_get_custom ("-reverse")); + break; case 30: /* text color */ case 31: case 32: diff --git a/tests/unit/gui/test-gui-color.cpp b/tests/unit/gui/test-gui-color.cpp index 2790b9efa..8dd9203bd 100644 --- a/tests/unit/gui/test-gui-color.cpp +++ b/tests/unit/gui/test-gui-color.cpp @@ -437,6 +437,15 @@ TEST(GuiColor, ColorDecodeAnsi) WEE_CHECK_DECODE_ANSI(string, "test_\x1B[1mbold\x1B[21m_end", 1); WEE_CHECK_DECODE_ANSI(string, "test_\x1B[1mbold\x1B[22m_end", 1); + /* reverse */ + WEE_CHECK_DECODE_ANSI("test_reverse_end", + "test_\x1B[7mreverse\x1B[27m_end", 0); + snprintf (string, sizeof (string), + "test_%sreverse%s_end", + gui_color_get_custom ("reverse"), + gui_color_get_custom ("-reverse")); + WEE_CHECK_DECODE_ANSI(string, "test_\x1B[7mreverse\x1B[27m_end", 1); + /* italic */ WEE_CHECK_DECODE_ANSI("test_italic_end", "test_\x1B[3mitalic\x1B[23m_end", 0);