[vte/vte-0-36] emulation: Add support for OSC 19/119 (highlight fg color) and corresponding API
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-0-36] emulation: Add support for OSC 19/119 (highlight fg color) and corresponding API
- Date: Sat, 15 Mar 2014 14:32:35 +0000 (UTC)
commit 9c9a0fcf80d6b55f4afb0de1ac474d3cb7b1b99c
Author: Egmont Koblinger <egmont gmail com>
Date: Sat Mar 15 15:27:16 2014 +0100
emulation: Add support for OSC 19/119 (highlight fg color) and corresponding API
https://bugzilla.gnome.org/show_bug.cgi?id=725974
src/vte.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++---
src/vte.h | 4 +++
src/vterowdata.h | 7 +++--
src/vteseq-n.gperf | 6 ++--
src/vteseq.c | 23 ++++++++++++++++
5 files changed, 104 insertions(+), 11 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index 12213d0..f642178 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -2733,6 +2733,7 @@ vte_terminal_set_color_cursor(VteTerminal *terminal,
* @highlight_background: (allow-none): the new color to use for highlighted text, or %NULL
*
* Sets the background color for text which is highlighted. If %NULL,
+ * it is unset. If neither highlight background nor highlight foreground are set,
* highlighted text (which is usually highlighted because it is selected) will
* be drawn with foreground and background colors reversed.
*
@@ -2746,18 +2747,49 @@ vte_terminal_set_color_highlight(VteTerminal *terminal,
if (highlight_background != NULL) {
_vte_debug_print(VTE_DEBUG_MISC,
- "Set highlight color to (%04x,%04x,%04x).\n",
+ "Set highlight background color to (%04x,%04x,%04x).\n",
highlight_background->red,
highlight_background->green,
highlight_background->blue);
} else {
_vte_debug_print(VTE_DEBUG_MISC,
- "Reset highlight color.\n");
+ "Reset highlight background color.\n");
}
_vte_terminal_set_color_internal(terminal, VTE_HIGHLIGHT_BG, VTE_COLOR_SOURCE_API,
highlight_background);
}
/**
+ * vte_terminal_set_color_highlight_foreground:
+ * @terminal: a #VteTerminal
+ * @highlight_foreground: (allow-none): the new color to use for highlighted text, or %NULL
+ *
+ * Sets the foreground color for text which is highlighted. If %NULL,
+ * it is unset. If neither highlight background nor highlight foreground are set,
+ * highlighted text (which is usually highlighted because it is selected) will
+ * be drawn with foreground and background colors reversed.
+ *
+ * Since: 0.36
+ */
+void
+vte_terminal_set_color_highlight_foreground(VteTerminal *terminal,
+ const GdkColor *highlight_foreground)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+ if (highlight_foreground != NULL) {
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Set highlight foreground color to (%04x,%04x,%04x).\n",
+ highlight_foreground->red,
+ highlight_foreground->green,
+ highlight_foreground->blue);
+ } else {
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Reset highlight foreground color.\n");
+ }
+ _vte_terminal_set_color_internal(terminal, VTE_HIGHLIGHT_FG, VTE_COLOR_SOURCE_API,
highlight_foreground);
+}
+
+/**
* vte_terminal_set_colors:
* @terminal: a #VteTerminal
* @foreground: (allow-none): the new foreground color, or %NULL
@@ -2875,6 +2907,9 @@ vte_terminal_set_colors(VteTerminal *terminal,
case VTE_HIGHLIGHT_BG:
unset = TRUE;
break;
+ case VTE_HIGHLIGHT_FG:
+ unset = TRUE;
+ break;
case VTE_CURSOR_BG:
unset = TRUE;
break;
@@ -3039,6 +3074,7 @@ vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
* @highlight_background: (allow-none): the new color to use for highlighted text, or %NULL
*
* Sets the background color for text which is highlighted. If %NULL,
+ * it is unset. If neither highlight background nor highlight foreground are set,
* highlighted text (which is usually highlighted because it is selected) will
* be drawn with foreground and background colors reversed.
*
@@ -3055,6 +3091,28 @@ vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
}
/**
+ * vte_terminal_set_color_highlight_foreground_rgba:
+ * @terminal: a #VteTerminal
+ * @highlight_foreground: (allow-none): the new color to use for highlighted text, or %NULL
+ *
+ * Sets the foreground color for text which is highlighted. If %NULL,
+ * it is unset. If neither highlight background nor highlight foreground are set,
+ * highlighted text (which is usually highlighted because it is selected) will
+ * be drawn with foreground and background colors reversed.
+ *
+ * Since: 0.36
+ */
+void
+vte_terminal_set_color_highlight_foreground_rgba(VteTerminal *terminal,
+ const GdkRGBA *highlight_foreground)
+{
+ GdkColor color;
+
+ vte_terminal_set_color_highlight_foreground(terminal,
+ gdk_color_from_rgba(&color, highlight_foreground));
+}
+
+/**
* vte_terminal_set_colors_rgba:
* @terminal: a #VteTerminal
* @foreground: (allow-none): the new foreground color, or %NULL
@@ -9444,12 +9502,19 @@ vte_terminal_determine_colors_internal(VteTerminal *terminal,
swap (&fore, &back);
}
- /* Selection: use hightlight back, or inverse */
+ /* Selection: use hightlight back/fore, or inverse */
if (selected) {
/* XXX what if hightlight back is same color as current back? */
- if (_vte_terminal_get_color(terminal, VTE_HIGHLIGHT_BG) != NULL)
+ gboolean do_swap = TRUE;
+ if (_vte_terminal_get_color(terminal, VTE_HIGHLIGHT_BG) != NULL) {
back = VTE_HIGHLIGHT_BG;
- else
+ do_swap = FALSE;
+ }
+ if (_vte_terminal_get_color(terminal, VTE_HIGHLIGHT_FG) != NULL) {
+ fore = VTE_HIGHLIGHT_FG;
+ do_swap = FALSE;
+ }
+ if (do_swap)
swap (&fore, &back);
}
diff --git a/src/vte.h b/src/vte.h
index 46ae965..ce479c6 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -325,6 +325,8 @@ void vte_terminal_set_color_cursor(VteTerminal *terminal,
const GdkColor *cursor_background);
void vte_terminal_set_color_highlight(VteTerminal *terminal,
const GdkColor *highlight_background);
+void vte_terminal_set_color_highlight_foreground(VteTerminal *terminal,
+ const GdkColor *highlight_foreground);
void vte_terminal_set_colors(VteTerminal *terminal,
const GdkColor *foreground,
const GdkColor *background,
@@ -344,6 +346,8 @@ void vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
const GdkRGBA *cursor_background);
void vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
const GdkRGBA *highlight_background);
+void vte_terminal_set_color_highlight_foreground_rgba(VteTerminal *terminal,
+ const GdkRGBA *highlight_foreground);
void vte_terminal_set_colors_rgba(VteTerminal *terminal,
const GdkRGBA *foreground,
const GdkRGBA *background,
diff --git a/src/vterowdata.h b/src/vterowdata.h
index 19a0e08..10e2140 100644
--- a/src/vterowdata.h
+++ b/src/vterowdata.h
@@ -30,9 +30,10 @@ G_BEGIN_DECLS
#define VTE_DEFAULT_BG 257
#define VTE_BOLD_FG 258
#define VTE_DIM_FG 259
-#define VTE_HIGHLIGHT_BG 260
-#define VTE_CURSOR_BG 261
-#define VTE_PALETTE_SIZE 262
+#define VTE_HIGHLIGHT_FG 260
+#define VTE_HIGHLIGHT_BG 261
+#define VTE_CURSOR_BG 262
+#define VTE_PALETTE_SIZE 263
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 6)
diff --git a/src/vteseq-n.gperf b/src/vteseq-n.gperf
index 050e83e..388c98f 100644
--- a/src/vteseq-n.gperf
+++ b/src/vteseq-n.gperf
@@ -101,9 +101,9 @@ struct vteseq_n_struct {
"change-highlight-background-colors-bel",
VTE_SEQUENCE_HANDLER(vte_sequence_handler_change_highlight_background_color_bel)
"change-highlight-background-colors-st",
VTE_SEQUENCE_HANDLER(vte_sequence_handler_change_highlight_background_color_st)
"reset-highlight-background-colors",
VTE_SEQUENCE_HANDLER(vte_sequence_handler_reset_highlight_background_color)
-#"change-highlight-foreground-colors-bel", VTE_SEQUENCE_HANDLER_NULL
-#"change-highlight-foreground-colors-st", VTE_SEQUENCE_HANDLER_NULL
-#"reset-highlight-foreground-colors", VTE_SEQUENCE_HANDLER_NULL
+"change-highlight-foreground-colors-bel",
VTE_SEQUENCE_HANDLER(vte_sequence_handler_change_highlight_foreground_color_bel)
+"change-highlight-foreground-colors-st",
VTE_SEQUENCE_HANDLER(vte_sequence_handler_change_highlight_foreground_color_st)
+"reset-highlight-foreground-colors",
VTE_SEQUENCE_HANDLER(vte_sequence_handler_reset_highlight_foreground_color)
#"enable-filter-rectangle", VTE_SEQUENCE_HANDLER_NULL
"insert-blank-characters", VTE_SEQUENCE_HANDLER(vte_sequence_handler_insert_blank_characters)
#"invoke-g2-character-set", VTE_SEQUENCE_HANDLER_NULL
diff --git a/src/vteseq.c b/src/vteseq.c
index 3c46111..28cc79b 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -3672,6 +3672,29 @@ vte_sequence_handler_reset_highlight_background_color (VteTerminal *terminal, GV
_vte_terminal_set_color_internal(terminal, VTE_HIGHLIGHT_BG, VTE_COLOR_SOURCE_ESCAPE, NULL);
}
+/* Change the highlight foreground color, BEL terminated */
+static void
+vte_sequence_handler_change_highlight_foreground_color_bel (VteTerminal *terminal, GValueArray *params)
+{
+ vte_sequence_handler_change_special_color_internal (terminal, params,
+ VTE_HIGHLIGHT_FG, VTE_DEFAULT_BG, 19, BEL);
+}
+
+/* Change the highlight foreground color, ST terminated */
+static void
+vte_sequence_handler_change_highlight_foreground_color_st (VteTerminal *terminal, GValueArray *params)
+{
+ vte_sequence_handler_change_special_color_internal (terminal, params,
+ VTE_HIGHLIGHT_FG, VTE_DEFAULT_BG, 19, ST);
+}
+
+/* Reset the highlight foreground color */
+static void
+vte_sequence_handler_reset_highlight_foreground_color (VteTerminal *terminal, GValueArray *params)
+{
+ _vte_terminal_set_color_internal(terminal, VTE_HIGHLIGHT_FG, VTE_COLOR_SOURCE_ESCAPE, NULL);
+}
+
/* Lookup tables */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]