[vte] widget: Add support for not automatically brightening bold colors
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] widget: Add support for not automatically brightening bold colors
- Date: Sat, 9 Dec 2017 11:26:35 +0000 (UTC)
commit 6c44229d130dd1d5cdb218e897ec6f245e96d538
Author: Egmont Koblinger <egmont gmail com>
Date: Sat Dec 9 12:18:40 2017 +0100
widget: Add support for not automatically brightening bold colors
https://bugzilla.gnome.org/show_bug.cgi?id=762247
doc/reference/vte-sections.txt | 2 +
src/app/app.cc | 4 +++
src/vte.cc | 15 +++++++++-
src/vte/vteterminal.h | 6 ++++
src/vtegtk.cc | 59 ++++++++++++++++++++++++++++++++++++++++
src/vtegtk.hh | 1 +
src/vteinternal.hh | 2 +
7 files changed, 88 insertions(+), 1 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index f73b3da..b87d249 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -25,6 +25,8 @@ vte_terminal_set_audible_bell
vte_terminal_get_audible_bell
vte_terminal_set_allow_bold
vte_terminal_get_allow_bold
+vte_terminal_set_bold_is_bright
+vte_terminal_get_bold_is_bright
vte_terminal_set_allow_hyperlink
vte_terminal_get_allow_hyperlink
vte_terminal_set_scroll_on_output
diff --git a/src/app/app.cc b/src/app/app.cc
index 2770477..636df47 100644
--- a/src/app/app.cc
+++ b/src/app/app.cc
@@ -45,6 +45,7 @@ public:
gboolean icon_title{false};
gboolean keep{false};
gboolean no_argb_visual{false};
+ gboolean no_bold_is_bright{false};
gboolean no_builtin_dingus{false};
gboolean no_context_menu{false};
gboolean no_double_buffer{false};
@@ -382,6 +383,8 @@ public:
"Live on after the command exits", nullptr },
{ "no-argb-visual", 0, 0, G_OPTION_ARG_NONE, &no_argb_visual,
"Don't use an ARGB visual", nullptr },
+ { "no-bold-is-bright", 'B', 0, G_OPTION_ARG_NONE, &no_bold_is_bright,
+ "Bold does not brightens colors", nullptr },
{ "no-builtin-dingus", 0, 0, G_OPTION_ARG_NONE, &no_builtin_dingus,
"Highlight URLs inside the terminal", nullptr },
{ "no-context-menu", 0, 0, G_OPTION_ARG_NONE, &no_context_menu,
@@ -1836,6 +1839,7 @@ vteapp_window_constructed(GObject *object)
vte_terminal_set_allow_hyperlink(window->terminal, !options.no_hyperlink);
vte_terminal_set_audible_bell(window->terminal, options.audible_bell);
+ vte_terminal_set_bold_is_bright(window->terminal, !options.no_bold_is_bright);
vte_terminal_set_cell_height_scale(window->terminal, options.cell_height_scale);
vte_terminal_set_cell_width_scale(window->terminal, options.cell_width_scale);
vte_terminal_set_cjk_ambiguous_width(window->terminal, options.cjk_ambiguous_width);
diff --git a/src/vte.cc b/src/vte.cc
index 94b2404..f62548f 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -8159,6 +8159,7 @@ VteTerminalPrivate::VteTerminalPrivate(VteTerminal *t) :
m_meta_sends_escape = TRUE;
m_audible_bell = TRUE;
m_allow_bold = TRUE;
+ m_bold_is_bright = TRUE;
m_deccolm_mode = FALSE;
m_rewrap_on_resize = TRUE;
set_default_tabstops();
@@ -8790,7 +8791,7 @@ VteTerminalPrivate::determine_colors(VteCellAttr const* attr,
}
/* Handle bold by using set bold color or brightening */
- if (attr->bold) {
+ if (attr->bold && m_bold_is_bright) {
if (fore == VTE_DEFAULT_FG)
fore = VTE_BOLD_FG;
else if (fore >= VTE_LEGACY_COLORS_OFFSET && fore < VTE_LEGACY_COLORS_OFFSET +
VTE_LEGACY_COLOR_SET_SIZE) {
@@ -10114,6 +10115,18 @@ VteTerminalPrivate::set_allow_bold(bool setting)
}
bool
+VteTerminalPrivate::set_bold_is_bright(bool setting)
+{
+ if (setting == m_bold_is_bright)
+ return false;
+
+ m_bold_is_bright = setting;
+ invalidate_all();
+
+ return true;
+}
+
+bool
VteTerminalPrivate::set_allow_hyperlink(bool setting)
{
if (setting == m_allow_hyperlink)
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
index 755dc8e..7d85474 100644
--- a/src/vte/vteterminal.h
+++ b/src/vte/vteterminal.h
@@ -309,6 +309,12 @@ _VTE_PUBLIC
gboolean vte_terminal_get_allow_bold(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
_VTE_PUBLIC
+void vte_terminal_set_bold_is_bright(VteTerminal *terminal,
+ gboolean bold_is_bright) _VTE_GNUC_NONNULL(1);
+_VTE_PUBLIC
+gboolean vte_terminal_get_bold_is_bright(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+
+_VTE_PUBLIC
void vte_terminal_set_allow_hyperlink(VteTerminal *terminal,
gboolean allow_hyperlink) _VTE_GNUC_NONNULL(1);
_VTE_PUBLIC
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 1098bf5..fa86130 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -436,6 +436,9 @@ vte_terminal_get_property (GObject *object,
case PROP_BACKSPACE_BINDING:
g_value_set_enum (value, impl->m_backspace_binding);
break;
+ case PROP_BOLD_IS_BRIGHT:
+ g_value_set_boolean (value, vte_terminal_get_bold_is_bright (terminal));
+ break;
case PROP_CELL_HEIGHT_SCALE:
g_value_set_double (value, vte_terminal_get_cell_height_scale (terminal));
break;
@@ -543,6 +546,9 @@ vte_terminal_set_property (GObject *object,
case PROP_BACKSPACE_BINDING:
vte_terminal_set_backspace_binding (terminal, (VteEraseBinding)g_value_get_enum
(value));
break;
+ case PROP_BOLD_IS_BRIGHT:
+ vte_terminal_set_bold_is_bright (terminal, g_value_get_boolean (value));
+ break;
case PROP_CELL_HEIGHT_SCALE:
vte_terminal_set_cell_height_scale (terminal, g_value_get_double (value));
break;
@@ -1316,6 +1322,20 @@ vte_terminal_class_init(VteTerminalClass *klass)
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY));
/**
+ * VteTerminal:bold-is-bright:
+ *
+ * Whether the SGR 1 attribute also switches to the bright counterpart
+ * of the first 8 palette colors, in addition to making them bold (legacy behavior)
+ * or if SGR 1 only enables bold and leaves the color intact.
+ *
+ * Since: 0.52
+ */
+ pspecs[PROP_BOLD_IS_BRIGHT] =
+ g_param_spec_boolean ("bold-is-bright", NULL, NULL,
+ TRUE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
* VteTerminal:cell-height-scale:
*
* Scale factor for the cell height, to increase line spacing. (The font's height is not affected.)
@@ -3009,6 +3029,45 @@ vte_terminal_set_backspace_binding(VteTerminal *terminal,
}
/**
+ * vte_terminal_get_bold_is_bright:
+ * @terminal: a #VteTerminal
+ *
+ * Checks whether the SGR 1 attribute also switches to the bright counterpart
+ * of the first 8 palette colors, in addition to making them bold (legacy behavior)
+ * or if SGR 1 only enables bold and leaves the color intact.
+ *
+ * Returns: %TRUE if bold also enables bright, %FALSE if not
+ *
+ * Since: 0.52
+ */
+gboolean
+vte_terminal_get_bold_is_bright(VteTerminal *terminal)
+{
+ g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
+ return IMPL(terminal)->m_bold_is_bright;
+}
+/**
+ * vte_terminal_set_bold_is_bright:
+ * @terminal: a #VteTerminal
+ * @bold_is_bright: %TRUE if bold should also enable bright
+ *
+ * Sets whether the SGR 1 attribute also switches to the bright counterpart
+ * of the first 8 palette colors, in addition to making them bold (legacy behavior)
+ * or if SGR 1 only enables bold and leaves the color intact.
+ *
+ * Since: 0.52
+ */
+void
+vte_terminal_set_bold_is_bright(VteTerminal *terminal,
+ gboolean bold_is_bright)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+ if (IMPL(terminal)->set_bold_is_bright(bold_is_bright != FALSE))
+ g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_BOLD_IS_BRIGHT]);
+}
+
+/**
* vte_terminal_get_char_height:
* @terminal: a #VteTerminal
*
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
index ea970a4..7adadfe 100644
--- a/src/vtegtk.hh
+++ b/src/vtegtk.hh
@@ -67,6 +67,7 @@ enum {
PROP_ALLOW_HYPERLINK,
PROP_AUDIBLE_BELL,
PROP_BACKSPACE_BINDING,
+ PROP_BOLD_IS_BRIGHT,
PROP_CELL_HEIGHT_SCALE,
PROP_CELL_WIDTH_SCALE,
PROP_CJK_AMBIGUOUS_WIDTH,
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index c90229c..7e1863e 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -485,6 +485,7 @@ public:
gboolean m_meta_sends_escape;
gboolean m_audible_bell;
gboolean m_allow_bold;
+ gboolean m_bold_is_bright;
gboolean m_deccolm_mode; /* DECCOLM allowed */
GHashTable *m_tabstops;
gboolean m_text_modified_flag;
@@ -1214,6 +1215,7 @@ public:
bool set_allow_hyperlink(bool setting);
bool set_backspace_binding(VteEraseBinding binding);
bool set_background_alpha(double alpha);
+ bool set_bold_is_bright(bool setting);
bool set_cell_height_scale(double scale);
bool set_cell_width_scale(double scale);
bool set_cjk_ambiguous_width(int width);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]