[vte] terminal: Use an enum class for text blink mode
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] terminal: Use an enum class for text blink mode
- Date: Mon, 18 Nov 2019 21:43:35 +0000 (UTC)
commit 6a7bd15672fddd32bdbb86146361c33d67ede9bf
Author: Christian Persch <chpe src gnome org>
Date: Mon Nov 18 22:42:22 2019 +0100
terminal: Use an enum class for text blink mode
src/vte.cc | 13 ++++++-------
src/vtegtk.cc | 4 ++--
src/vteinternal.hh | 13 +++++++++++--
src/widget.hh | 3 +++
4 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index ffe84293..c82cdb17 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -7212,8 +7212,8 @@ Terminal::widget_focus_in(GdkEventFocus *event)
/* If blinking gets enabled now, do a full repaint.
* If blinking gets disabled, only repaint if there's blinking stuff present
* (we could further optimize by checking its current phase). */
- if (m_text_blink_mode == VTE_TEXT_BLINK_FOCUSED ||
- (m_text_blink_mode == VTE_TEXT_BLINK_UNFOCUSED && m_text_blink_tag != 0)) {
+ if (m_text_blink_mode == TextBlinkMode::eFOCUSED ||
+ (m_text_blink_mode == TextBlinkMode::eUNFOCUSED && m_text_blink_tag != 0)) {
invalidate_all();
}
@@ -7243,8 +7243,8 @@ Terminal::widget_focus_out(GdkEventFocus *event)
/* If blinking gets enabled now, do a full repaint.
* If blinking gets disabled, only repaint if there's blinking stuff present
* (we could further optimize by checking its current phase). */
- if (m_text_blink_mode == VTE_TEXT_BLINK_UNFOCUSED ||
- (m_text_blink_mode == VTE_TEXT_BLINK_FOCUSED && m_text_blink_tag != 0)) {
+ if (m_text_blink_mode == TextBlinkMode::eUNFOCUSED ||
+ (m_text_blink_mode == TextBlinkMode::eFOCUSED && m_text_blink_tag != 0)) {
invalidate_all();
}
@@ -7887,7 +7887,6 @@ Terminal::Terminal(vte::platform::Widget* w,
/* Miscellaneous options. */
set_backspace_binding(VTE_ERASE_AUTO);
set_delete_binding(VTE_ERASE_AUTO);
- m_text_blink_mode = VTE_TEXT_BLINK_ALWAYS;
/* Initialize the saved cursor. */
save_cursor(&m_normal_screen);
@@ -9422,7 +9421,7 @@ Terminal::widget_draw(cairo_t *cr)
/* Whether blinking text should be visible now */
m_text_blink_state = true;
- text_blink_enabled_now = m_text_blink_mode & (m_has_focus ? VTE_TEXT_BLINK_FOCUSED :
VTE_TEXT_BLINK_UNFOCUSED);
+ text_blink_enabled_now = (unsigned)m_text_blink_mode & (unsigned)(m_has_focus ?
TextBlinkMode::eFOCUSED : TextBlinkMode::eUNFOCUSED);
if (text_blink_enabled_now) {
now = g_get_monotonic_time() / 1000;
if (now % (m_text_blink_cycle * 2) >= m_text_blink_cycle)
@@ -9632,7 +9631,7 @@ Terminal::set_audible_bell(bool setting)
}
bool
-Terminal::set_text_blink_mode(VteTextBlinkMode setting)
+Terminal::set_text_blink_mode(TextBlinkMode setting)
{
if (setting == m_text_blink_mode)
return false;
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 81f035d6..c7164f93 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -3214,7 +3214,7 @@ VteTextBlinkMode
vte_terminal_get_text_blink_mode(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), VTE_TEXT_BLINK_ALWAYS);
- return IMPL(terminal)->m_text_blink_mode;
+ return WIDGET(terminal)->text_blink_mode();
}
/**
@@ -3232,7 +3232,7 @@ vte_terminal_set_text_blink_mode(VteTerminal *terminal,
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
- if (IMPL(terminal)->set_text_blink_mode(text_blink_mode))
+ if (WIDGET(terminal)->set_text_blink_mode(text_blink_mode))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_TEXT_BLINK_MODE]);
}
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 0fc77da5..7ea8c0b4 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -347,6 +347,14 @@ protected:
eUNDERLINE
};
+ /* NOTE: This needs to be kept in sync with the public VteTextBlinkMode enum */
+ enum class TextBlinkMode {
+ eNEVER = 0,
+ eFOCUSED = 1,
+ eUNFOCUSED = 2,
+ eALWAYS = 3
+ };
+
public:
Terminal(vte::platform::Widget* w,
VteTerminal *t);
@@ -520,7 +528,7 @@ public:
bool m_cursor_blinks{false}; /* whether the cursor is actually blinking */
/* Contents blinking */
- VteTextBlinkMode m_text_blink_mode;
+ TextBlinkMode m_text_blink_mode{TextBlinkMode::eALWAYS};
gint m_text_blink_cycle; /* gtk-cursor-blink-time / 2 */
bool m_text_blink_state; /* whether blinking text should be visible at this very moment */
bool m_text_to_blink; /* drawing signals here if it encounters any cell with blink attribute */
@@ -1272,7 +1280,8 @@ public:
int source);
bool set_audible_bell(bool setting);
- bool set_text_blink_mode(VteTextBlinkMode setting);
+ bool set_text_blink_mode(TextBlinkMode setting);
+ auto text_blink_mode() const noexcept { return m_text_blink_mode; }
bool set_allow_bold(bool setting);
bool set_allow_hyperlink(bool setting);
bool set_backspace_binding(VteEraseBinding binding);
diff --git a/src/widget.hh b/src/widget.hh
index b5452cbf..2e09c75c 100644
--- a/src/widget.hh
+++ b/src/widget.hh
@@ -111,6 +111,9 @@ public:
bool set_cursor_shape(VteCursorShape shape) { return
terminal()->set_cursor_shape(vte::terminal::Terminal::CursorShape(shape)); }
auto cursor_shape() const noexcept { return VteCursorShape(terminal()->cursor_shape()); }
+ bool set_text_blink_mode(VteTextBlinkMode mode) { return
terminal()->set_text_blink_mode(vte::terminal::Terminal::TextBlinkMode(mode)); }
+ auto text_blink_mode() const noexcept { return VteTextBlinkMode(terminal()->text_blink_mode()); }
+
char const* encoding() const noexcept { return m_terminal->encoding(); }
void emit_child_exited(int status) noexcept;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]