[vte] emulation: Add support for OSC 5;0 (bold color)
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] emulation: Add support for OSC 5;0 (bold color)
- Date: Wed, 21 Mar 2018 21:43:11 +0000 (UTC)
commit e258bda404f146262545abf7c332d7917a55d5d6
Author: Egmont Koblinger <egmont gmail com>
Date: Wed Mar 21 22:36:55 2018 +0100
emulation: Add support for OSC 5;0 (bold color)
Also OSC 4;256 does the same. Resetting counterparts (104, 105) added too.
https://bugzilla.gnome.org/show_bug.cgi?id=722751
src/caps-list.hh | 6 +++++
src/vteinternal.hh | 2 +-
src/vteseq-list.hh | 3 ++
src/vteseq.cc | 57 ++++++++++++++++++++++++++++++++++++---------------
4 files changed, 50 insertions(+), 18 deletions(-)
---
diff --git a/src/caps-list.hh b/src/caps-list.hh
index 0528d7b..cc7075c 100644
--- a/src/caps-list.hh
+++ b/src/caps-list.hh
@@ -218,6 +218,7 @@ static const vte_matcher_entry_t entries[] = {
ENTRY(OSC "2;%s" BEL, set_window_title),
ENTRY(OSC "3;%s" BEL, set_xproperty),
ENTRY(OSC "4;%s" BEL, change_color_bel),
+ ENTRY(OSC "5;0;%s" BEL, change_bold_color_bel),
ENTRY(OSC "6;%s" BEL, set_current_file_uri),
ENTRY(OSC "7;%s" BEL, set_current_directory_uri),
ENTRY(OSC "8;%s;%s" BEL, set_current_hyperlink),
@@ -236,6 +237,8 @@ static const vte_matcher_entry_t entries[] = {
ENTRY(OSC "50;%s" BEL, change_font_name),
ENTRY(OSC "104" BEL, reset_color),
ENTRY(OSC "104;%m" BEL, reset_color),
+ ENTRY(OSC "105" BEL, reset_bold_color),
+ ENTRY(OSC "105;0" BEL, reset_bold_color),
ENTRY(OSC "110" BEL, reset_foreground_color),
ENTRY(OSC "111" BEL, reset_background_color),
ENTRY(OSC "112" BEL, reset_cursor_background_color),
@@ -257,6 +260,7 @@ static const vte_matcher_entry_t entries[] = {
ENTRY(OSC "2;%s" ST, set_window_title),
ENTRY(OSC "3;%s" ST, set_xproperty),
ENTRY(OSC "4;%s" ST, change_color_st),
+ ENTRY(OSC "5;0;%s" ST, change_bold_color_st),
ENTRY(OSC "6;%s" ST, set_current_file_uri),
ENTRY(OSC "7;%s" ST, set_current_directory_uri),
ENTRY(OSC "8;%s;%s" ST, set_current_hyperlink),
@@ -275,6 +279,8 @@ static const vte_matcher_entry_t entries[] = {
ENTRY(OSC "50;%s" ST, change_font_name),
ENTRY(OSC "104" ST, reset_color),
ENTRY(OSC "104;%m" ST, reset_color),
+ ENTRY(OSC "105" ST, reset_bold_color),
+ ENTRY(OSC "105;0" ST, reset_bold_color),
ENTRY(OSC "110" ST, reset_foreground_color),
ENTRY(OSC "111" ST, reset_background_color),
ENTRY(OSC "112" ST, reset_cursor_background_color),
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index ec43466..f813913 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -1343,7 +1343,7 @@ public:
inline void change_special_color(vte::parser::Params const& params,
int index,
int index_fallback,
- int osc,
+ const char *osc,
char const *terminator);
unsigned int checksum_area(vte::grid::row_t start_row,
diff --git a/src/vteseq-list.hh b/src/vteseq-list.hh
index af9fc89..daba388 100644
--- a/src/vteseq-list.hh
+++ b/src/vteseq-list.hh
@@ -8,6 +8,8 @@ SEQUENCE_HANDLER(bell)
SEQUENCE_HANDLER(carriage_return)
SEQUENCE_HANDLER(change_background_color_bel)
SEQUENCE_HANDLER(change_background_color_st)
+SEQUENCE_HANDLER(change_bold_color_bel)
+SEQUENCE_HANDLER(change_bold_color_st)
SEQUENCE_HANDLER(change_color_bel)
SEQUENCE_HANDLER(change_color_st)
SEQUENCE_HANDLER(change_cursor_background_color_bel)
@@ -96,6 +98,7 @@ SEQUENCE_HANDLER(repeat)
SEQUENCE_HANDLER(request_locator_position)
SEQUENCE_HANDLER(request_terminal_parameters)
SEQUENCE_HANDLER(reset_background_color)
+SEQUENCE_HANDLER(reset_bold_color)
SEQUENCE_HANDLER(reset_color)
SEQUENCE_HANDLER(reset_cursor_background_color)
SEQUENCE_HANDLER(reset_foreground_color)
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 218bedf..99b8bb3 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -1623,14 +1623,16 @@ VteTerminalPrivate::change_color(vte::parser::Params const& params,
for (i = 0; pairs[i] && pairs[i + 1]; i += 2) {
idx = strtoul (pairs[i], (char **) NULL, 10);
- if (idx >= VTE_DEFAULT_FG)
+ if (idx >= VTE_DEFAULT_FG && idx != 256)
continue;
if (color.parse(pairs[i + 1])) {
- set_color(idx, VTE_COLOR_SOURCE_ESCAPE, color);
+ set_color(idx == 256 ? VTE_BOLD_FG : idx, VTE_COLOR_SOURCE_ESCAPE, color);
} else if (strcmp (pairs[i + 1], "?") == 0) {
gchar buf[128];
- auto c = get_color(idx);
+ auto c = get_color(idx == 256 ? VTE_BOLD_FG : idx);
+ if (c == NULL && idx == 256)
+ c = get_color(VTE_DEFAULT_FG);
g_assert(c != NULL);
g_snprintf (buf, sizeof (buf),
_VTE_CAP_OSC "4;%u;rgb:%04x/%04x/%04x%s",
@@ -1671,10 +1673,10 @@ VteTerminalPrivate::seq_reset_color(vte::parser::Params const& params)
if (!params.number_at_unchecked(i, value))
continue;
- if (value < 0 || value >= VTE_DEFAULT_FG)
+ if ((value < 0 || value >= VTE_DEFAULT_FG) && value != 256)
continue;
- reset_color(value, VTE_COLOR_SOURCE_ESCAPE);
+ reset_color(value == 256 ? VTE_BOLD_FG : value, VTE_COLOR_SOURCE_ESCAPE);
}
} else {
for (unsigned int idx = 0; idx < VTE_DEFAULT_FG; idx++) {
@@ -3010,7 +3012,7 @@ void
VteTerminalPrivate::change_special_color(vte::parser::Params const& params,
int index,
int index_fallback,
- int osc,
+ const char *osc,
const char *terminator)
{
char* name;
@@ -3028,24 +3030,45 @@ VteTerminalPrivate::change_special_color(vte::parser::Params const& params,
c = get_color(index_fallback);
g_assert(c != NULL);
g_snprintf (buf, sizeof (buf),
- _VTE_CAP_OSC "%d;rgb:%04x/%04x/%04x%s",
+ _VTE_CAP_OSC "%s;rgb:%04x/%04x/%04x%s",
osc, c->red, c->green, c->blue, terminator);
feed_child(buf, -1);
}
}
+/* Change the bold color, BEL terminated */
+void
+VteTerminalPrivate::seq_change_bold_color_bel(vte::parser::Params const& params)
+{
+ change_special_color(params, VTE_BOLD_FG, VTE_DEFAULT_FG, "5;0", BEL);
+}
+
+/* Change the bold color, ST terminated */
+void
+VteTerminalPrivate::seq_change_bold_color_st(vte::parser::Params const& params)
+{
+ change_special_color(params, VTE_BOLD_FG, VTE_DEFAULT_FG, "5;0", ST);
+}
+
+/* Reset the bold color */
+void
+VteTerminalPrivate::seq_reset_bold_color(vte::parser::Params const& params)
+{
+ reset_color(VTE_BOLD_FG, VTE_COLOR_SOURCE_ESCAPE);
+}
+
/* Change the default foreground cursor, BEL terminated */
void
VteTerminalPrivate::seq_change_foreground_color_bel(vte::parser::Params const& params)
{
- change_special_color(params, VTE_DEFAULT_FG, -1, 10, BEL);
+ change_special_color(params, VTE_DEFAULT_FG, -1, "10", BEL);
}
/* Change the default foreground cursor, ST terminated */
void
VteTerminalPrivate::seq_change_foreground_color_st(vte::parser::Params const& params)
{
- change_special_color(params, VTE_DEFAULT_FG, -1, 10, ST);
+ change_special_color(params, VTE_DEFAULT_FG, -1, "10", ST);
}
/* Reset the default foreground color */
@@ -3059,14 +3082,14 @@ VteTerminalPrivate::seq_reset_foreground_color(vte::parser::Params const& params
void
VteTerminalPrivate::seq_change_background_color_bel(vte::parser::Params const& params)
{
- change_special_color(params, VTE_DEFAULT_BG, -1, 11, BEL);
+ change_special_color(params, VTE_DEFAULT_BG, -1, "11", BEL);
}
/* Change the default background cursor, ST terminated */
void
VteTerminalPrivate::seq_change_background_color_st(vte::parser::Params const& params)
{
- change_special_color(params, VTE_DEFAULT_BG, -1, 11, ST);
+ change_special_color(params, VTE_DEFAULT_BG, -1, "11", ST);
}
/* Reset the default background color */
@@ -3080,14 +3103,14 @@ VteTerminalPrivate::seq_reset_background_color(vte::parser::Params const& params
void
VteTerminalPrivate::seq_change_cursor_background_color_bel(vte::parser::Params const& params)
{
- change_special_color(params, VTE_CURSOR_BG, VTE_DEFAULT_FG, 12, BEL);
+ change_special_color(params, VTE_CURSOR_BG, VTE_DEFAULT_FG, "12", BEL);
}
/* Change the color of the cursor background, ST terminated */
void
VteTerminalPrivate::seq_change_cursor_background_color_st(vte::parser::Params const& params)
{
- change_special_color(params, VTE_CURSOR_BG, VTE_DEFAULT_FG, 12, ST);
+ change_special_color(params, VTE_CURSOR_BG, VTE_DEFAULT_FG, "12", ST);
}
/* Reset the color of the cursor */
@@ -3101,14 +3124,14 @@ VteTerminalPrivate::seq_reset_cursor_background_color(vte::parser::Params const&
void
VteTerminalPrivate::seq_change_highlight_background_color_bel(vte::parser::Params const& params)
{
- change_special_color(params, VTE_HIGHLIGHT_BG, VTE_DEFAULT_FG, 17, BEL);
+ change_special_color(params, VTE_HIGHLIGHT_BG, VTE_DEFAULT_FG, "17", BEL);
}
/* Change the highlight background color, ST terminated */
void
VteTerminalPrivate::seq_change_highlight_background_color_st(vte::parser::Params const& params)
{
- change_special_color(params, VTE_HIGHLIGHT_BG, VTE_DEFAULT_FG, 17, ST);
+ change_special_color(params, VTE_HIGHLIGHT_BG, VTE_DEFAULT_FG, "17", ST);
}
/* Reset the highlight background color */
@@ -3122,14 +3145,14 @@ VteTerminalPrivate::seq_reset_highlight_background_color(vte::parser::Params con
void
VteTerminalPrivate::seq_change_highlight_foreground_color_bel(vte::parser::Params const& params)
{
- change_special_color(params, VTE_HIGHLIGHT_FG, VTE_DEFAULT_BG, 19, BEL);
+ change_special_color(params, VTE_HIGHLIGHT_FG, VTE_DEFAULT_BG, "19", BEL);
}
/* Change the highlight foreground color, ST terminated */
void
VteTerminalPrivate::seq_change_highlight_foreground_color_st(vte::parser::Params const& params)
{
- change_special_color(params, VTE_HIGHLIGHT_FG, VTE_DEFAULT_BG, 19, ST);
+ change_special_color(params, VTE_HIGHLIGHT_FG, VTE_DEFAULT_BG, "19", ST);
}
/* Reset the highlight foreground color */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]