Commit 9c9a0fcf authored by Egmont Koblinger's avatar Egmont Koblinger

emulation: Add support for OSC 19/119 (highlight fg color) and corresponding API

https://bugzilla.gnome.org/show_bug.cgi?id=725974
parent 3c915ee0
......@@ -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,17 +2747,48 @@ 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
......@@ -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.
*
......@@ -3054,6 +3090,28 @@ vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
gdk_color_from_rgba(&color, highlight_background));
}
/**
* 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
......@@ -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);
}
......
......@@ -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,
......
......@@ -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)
......
......@@ -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
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment