[vte] widget: Move some public API to its own file
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] widget: Move some public API to its own file
- Date: Wed, 18 Nov 2015 20:22:07 +0000 (UTC)
commit b921f1a59646bf4f3979ecc59520c66b5886d8b2
Author: Christian Persch <chpe gnome org>
Date: Wed Nov 18 21:15:46 2015 +0100
widget: Move some public API to its own file
src/vte.cc | 140 ++++++++++++++++--------------------------------
src/vtegtk.cc | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/vteinternal.hh | 10 ++++
3 files changed, 208 insertions(+), 93 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 2639c06..5b5be3e 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -3008,60 +3008,48 @@ _pango_color_from_rgba(PangoColor *color,
return color;
}
-/**
- * vte_terminal_set_color_bold:
- * @terminal: a #VteTerminal
+/*
+ * VteTerminalPrivate::set_color_bold:
* @bold: (allow-none): the new bold color or %NULL
*
* Sets the color used to draw bold text in the default foreground color.
* If @bold is %NULL then the default color is used.
*/
void
-vte_terminal_set_color_bold(VteTerminal *terminal,
- const GdkRGBA *bold)
+VteTerminalPrivate::set_color_bold(GdkRGBA const* bold)
{
PangoColor color;
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
- if (bold == NULL)
- {
- vte_terminal_generate_bold(_vte_terminal_get_color(terminal, VTE_DEFAULT_FG),
- _vte_terminal_get_color(terminal, VTE_DEFAULT_BG),
+ if (bold == nullptr) {
+ vte_terminal_generate_bold(_vte_terminal_get_color(m_terminal, VTE_DEFAULT_FG),
+ _vte_terminal_get_color(m_terminal, VTE_DEFAULT_BG),
1.8,
&color);
- }
- else
- {
+ } else {
_pango_color_from_rgba(&color, bold);
}
- _vte_terminal_set_color_bold(terminal, &color);
+ _vte_terminal_set_color_bold(m_terminal, &color);
}
-/**
- * vte_terminal_set_color_foreground:
- * @terminal: a #VteTerminal
+/*
+ * VteTerminalPrivate::set_color_foreground:
* @foreground: the new foreground color
*
* Sets the foreground color used to draw normal text.
*/
void
-vte_terminal_set_color_foreground(VteTerminal *terminal,
- const GdkRGBA *foreground)
+VteTerminalPrivate::set_color_foreground(GdkRGBA const* foreground)
{
- PangoColor color;
+ g_assert(foreground != nullptr);
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
- g_return_if_fail(foreground != NULL);
-
- _vte_terminal_set_color_foreground(terminal,
+ PangoColor color;
+ _vte_terminal_set_color_foreground(m_terminal,
_pango_color_from_rgba(&color, foreground));
}
-/**
- * vte_terminal_set_color_background:
- * @terminal: a #VteTerminal
+/*
+ * VteTerminalPrivate::set_color_background:
* @background: the new background color
*
* Sets the background color for text which does not have a specific background
@@ -3069,22 +3057,18 @@ vte_terminal_set_color_foreground(VteTerminal *terminal,
* the terminal is not transparent.
*/
void
-vte_terminal_set_color_background(VteTerminal *terminal,
- const GdkRGBA *background)
+VteTerminalPrivate::set_color_background(GdkRGBA const *background)
{
- PangoColor color;
+ g_assert(background != nullptr);
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
- g_return_if_fail(background != NULL);
-
- _vte_terminal_set_color_background(terminal,
+ PangoColor color;
+ _vte_terminal_set_color_background(m_terminal,
_pango_color_from_rgba(&color, background));
- _vte_terminal_set_background_alpha(terminal, background->alpha);
+ _vte_terminal_set_background_alpha(m_terminal, background->alpha);
}
-/**
- * vte_terminal_set_color_cursor:
- * @terminal: a #VteTerminal
+/*
+ * VteTerminalPrivate::set_color_cursor:
* @cursor_background: (allow-none): the new color to use for the text cursor, or %NULL
*
* Sets the background color for text which is under the cursor. If %NULL, text
@@ -3092,20 +3076,15 @@ vte_terminal_set_color_background(VteTerminal *terminal,
* reversed.
*/
void
-vte_terminal_set_color_cursor(VteTerminal *terminal,
- const GdkRGBA *cursor_background)
+VteTerminalPrivate::set_color_cursor(GdkRGBA const* cursor_background)
{
PangoColor color;
-
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
- _vte_terminal_set_color_cursor(terminal,
+ _vte_terminal_set_color_cursor(m_terminal,
_pango_color_from_rgba(&color, cursor_background));
}
-/**
- * vte_terminal_set_color_highlight:
- * @terminal: a #VteTerminal
+/*
+ * VteTerminalPrivate::set_color_highlight:
* @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,
@@ -3114,20 +3093,15 @@ vte_terminal_set_color_cursor(VteTerminal *terminal,
* be drawn with foreground and background colors reversed.
*/
void
-vte_terminal_set_color_highlight(VteTerminal *terminal,
- const GdkRGBA *highlight_background)
+VteTerminalPrivate::set_color_highlight(GdkRGBA const *highlight_background)
{
PangoColor color;
-
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
- _vte_terminal_set_color_highlight(terminal,
+ _vte_terminal_set_color_highlight(m_terminal,
_pango_color_from_rgba(&color, highlight_background));
}
/**
- * vte_terminal_set_color_highlight_foreground:
- * @terminal: a #VteTerminal
+ * VteTerminalPrivate::set_color_highlight_foreground:
* @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,
@@ -3136,20 +3110,15 @@ vte_terminal_set_color_highlight(VteTerminal *terminal,
* be drawn with foreground and background colors reversed.
*/
void
-vte_terminal_set_color_highlight_foreground(VteTerminal *terminal,
- const GdkRGBA *highlight_foreground)
+VteTerminalPrivate::set_color_highlight_foreground(GdkRGBA const *highlight_foreground)
{
PangoColor color;
-
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
- _vte_terminal_set_color_highlight_foreground(terminal,
+ _vte_terminal_set_color_highlight_foreground(m_terminal,
_pango_color_from_rgba(&color, highlight_foreground));
}
-/**
- * vte_terminal_set_colors:
- * @terminal: a #VteTerminal
+/*
+ * VteTerminalPrivate::set_colors:
* @foreground: (allow-none): the new foreground color, or %NULL
* @background: (allow-none): the new background color, or %NULL
* @palette: (array length=palette_size zero-terminated=0) (element-type Gdk.RGBA) (allow-none): the color
palette
@@ -3166,49 +3135,34 @@ vte_terminal_set_color_highlight_foreground(VteTerminal *terminal,
* greater than 0, the new background color is taken from @palette[0].
*/
void
-vte_terminal_set_colors(VteTerminal *terminal,
- const GdkRGBA *foreground,
- const GdkRGBA *background,
- const GdkRGBA *palette,
- gsize palette_size)
+VteTerminalPrivate::set_colors(GdkRGBA const *foreground,
+ GdkRGBA const *background,
+ GdkRGBA const *palette_,
+ gsize palette_size)
{
PangoColor fg, bg, *pal;
gsize i;
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
- g_return_if_fail((palette_size == 0) ||
- (palette_size == 8) ||
- (palette_size == 16) ||
- (palette_size == 232) ||
- (palette_size == 256));
+ g_assert((palette_size == 0) ||
+ (palette_size == 8) ||
+ (palette_size == 16) ||
+ (palette_size == 232) ||
+ (palette_size == 256));
- pal = g_new (PangoColor, palette_size);
+ pal = g_new(PangoColor, palette_size);
for (i = 0; i < palette_size; ++i)
- _pango_color_from_rgba(&pal[i], &palette[i]);
+ _pango_color_from_rgba(&pal[i], &palette_[i]);
- _vte_terminal_set_colors(terminal,
+ _vte_terminal_set_colors(m_terminal,
_pango_color_from_rgba(&fg, foreground),
_pango_color_from_rgba(&bg, background),
pal, palette_size);
- _vte_terminal_set_background_alpha(terminal, background ? background->alpha : 1.0);
+ _vte_terminal_set_background_alpha(m_terminal, background ? background->alpha : 1.0);
g_free (pal);
}
-/**
- * vte_terminal_set_default_colors:
- * @terminal: a #VteTerminal
- *
- * Reset the terminal palette to reasonable compiled-in default color.
- */
-void
-vte_terminal_set_default_colors(VteTerminal *terminal)
-{
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
- _vte_terminal_set_colors(terminal, NULL, NULL, NULL, 0);
-}
-
/*
* _vte_terminal_cleanup_fragments:
* @terminal: a #VteTerminal
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index c04588c..a714352 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -2365,6 +2365,157 @@ vte_terminal_set_cjk_ambiguous_width(VteTerminal *terminal, int width)
}
/**
+ * vte_terminal_set_color_background:
+ * @terminal: a #VteTerminal
+ * @background: the new background color
+ *
+ * Sets the background color for text which does not have a specific background
+ * color assigned. Only has effect when no background image is set and when
+ * the terminal is not transparent.
+ */
+void
+vte_terminal_set_color_background(VteTerminal *terminal,
+ const GdkRGBA *background)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ g_return_if_fail(background != NULL);
+ terminal->pvt->set_color_background(background);
+}
+
+/**
+ * vte_terminal_set_color_bold:
+ * @terminal: a #VteTerminal
+ * @bold: (allow-none): the new bold color or %NULL
+ *
+ * Sets the color used to draw bold text in the default foreground color.
+ * If @bold is %NULL then the default color is used.
+ */
+void
+vte_terminal_set_color_bold(VteTerminal *terminal,
+ const GdkRGBA *bold)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ terminal->pvt->set_color_bold(bold);
+}
+
+/**
+ * vte_terminal_set_color_cursor:
+ * @terminal: a #VteTerminal
+ * @cursor_background: (allow-none): the new color to use for the text cursor, or %NULL
+ *
+ * Sets the background color for text which is under the cursor. If %NULL, text
+ * under the cursor will be drawn with foreground and background colors
+ * reversed.
+ */
+void
+vte_terminal_set_color_cursor(VteTerminal *terminal,
+ const GdkRGBA *cursor_background)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ terminal->pvt->set_color_cursor(cursor_background);
+}
+
+/**
+ * vte_terminal_set_color_foreground:
+ * @terminal: a #VteTerminal
+ * @foreground: the new foreground color
+ *
+ * Sets the foreground color used to draw normal text.
+ */
+void
+vte_terminal_set_color_foreground(VteTerminal *terminal,
+ const GdkRGBA *foreground)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ g_return_if_fail(foreground != NULL);
+ terminal->pvt->set_color_foreground(foreground);
+}
+
+/**
+ * vte_terminal_set_color_highlight:
+ * @terminal: a #VteTerminal
+ * @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.
+ */
+void
+vte_terminal_set_color_highlight(VteTerminal *terminal,
+ const GdkRGBA *highlight_background)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ terminal->pvt->set_color_highlight(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.
+ */
+void
+vte_terminal_set_color_highlight_foreground(VteTerminal *terminal,
+ const GdkRGBA *highlight_foreground)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ terminal->pvt->set_color_highlight_foreground(highlight_foreground);
+}
+
+/**
+ * vte_terminal_set_colors:
+ * @terminal: a #VteTerminal
+ * @foreground: (allow-none): the new foreground color, or %NULL
+ * @background: (allow-none): the new background color, or %NULL
+ * @palette: (array length=palette_size zero-terminated=0) (element-type Gdk.RGBA) (allow-none): the color
palette
+ * @palette_size: the number of entries in @palette
+ *
+ * @palette specifies the new values for the 256 palette colors: 8 standard colors,
+ * their 8 bright counterparts, 6x6x6 color cube, and 24 grayscale colors.
+ * Omitted entries will default to a hardcoded value.
+ *
+ * @palette_size must be 0, 8, 16, 232 or 256.
+ *
+ * If @foreground is %NULL and @palette_size is greater than 0, the new foreground
+ * color is taken from @palette[7]. If @background is %NULL and @palette_size is
+ * greater than 0, the new background color is taken from @palette[0].
+ */
+void
+vte_terminal_set_colors(VteTerminal *terminal,
+ const GdkRGBA *foreground,
+ const GdkRGBA *background,
+ const GdkRGBA *palette,
+ gsize palette_size)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ g_return_if_fail((palette_size == 0) ||
+ (palette_size == 8) ||
+ (palette_size == 16) ||
+ (palette_size == 232) ||
+ (palette_size == 256));
+
+ terminal->pvt->set_colors(foreground, background, palette, palette_size);
+}
+
+/**
+ * vte_terminal_set_default_colors:
+ * @terminal: a #VteTerminal
+ *
+ * Reset the terminal palette to reasonable compiled-in default color.
+ */
+void
+vte_terminal_set_default_colors(VteTerminal *terminal)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ terminal->pvt->set_colors(nullptr, nullptr, nullptr, 0);
+}
+
+/**
* vte_terminal_get_column_count:
* @terminal: a #VteTerminal
*
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 414b809..5a5e4a4 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -644,6 +644,16 @@ public:
bool set_allow_bold(bool setting);
bool set_backspace_binding(VteEraseBinding binding);
bool set_cjk_ambiguous_width(int width);
+ void set_color_background(GdkRGBA const *background);
+ void set_color_bold(GdkRGBA const* bold);
+ void set_color_cursor(GdkRGBA const* cursor_background);
+ void set_color_foreground(GdkRGBA const* foreground);
+ void set_color_highlight(GdkRGBA const *highlight_background);
+ void set_color_highlight_foreground(GdkRGBA const *highlight_foreground);
+ void set_colors(GdkRGBA const *foreground,
+ GdkRGBA const *background,
+ GdkRGBA const *palette,
+ gsize palette_size);
bool set_cursor_blink_mode(VteCursorBlinkMode mode);
bool set_cursor_shape(VteCursorShape shape);
bool set_delete_binding(VteEraseBinding binding);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]