[vte] widget: Move some methods to VteTerminalPrivate



commit 14f8835b4aa89867e886a76165f62807abac6dee
Author: Christian Persch <chpe gnome org>
Date:   Sun Nov 22 21:07:02 2015 +0100

    widget: Move some methods to VteTerminalPrivate

 src/vte-private.h  |    3 --
 src/vte.cc         |   55 ++++++++++++++++++++++++---------------------------
 src/vteinternal.hh |    5 ++++
 src/vteseq.cc      |   10 ++++----
 4 files changed, 36 insertions(+), 37 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 44089cd..4fff894 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -74,9 +74,6 @@ gboolean _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
 void _vte_terminal_scroll_region(VteTerminal *terminal,
                                 long row, glong count, glong delta);
 void _vte_terminal_set_default_attributes(VteTerminal *terminal);
-void _vte_terminal_clear_tabstop(VteTerminal *terminal, int column);
-gboolean _vte_terminal_get_tabstop(VteTerminal *terminal, int column);
-void _vte_terminal_set_tabstop(VteTerminal *terminal, int column);
 void _vte_terminal_update_insert_delta(VteTerminal *terminal);
 void _vte_terminal_cleanup_fragments(VteTerminal *terminal, long start, long end);
 PangoColor *_vte_terminal_get_color(const VteTerminal *terminal, int idx);
diff --git a/src/vte.cc b/src/vte.cc
index db68ff0..ad8d957 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -999,57 +999,54 @@ VteTerminalPrivate::deselect_all()
        }
 }
 
+// FIXMEchpe make m_tabstops a hashset
+
 /* Remove a tabstop. */
 void
-_vte_terminal_clear_tabstop(VteTerminal *terminal, int column)
+VteTerminalPrivate::clear_tabstop(int column)
 {
-       g_assert(VTE_IS_TERMINAL(terminal));
-       if (terminal->pvt->tabstops != NULL) {
+       if (m_tabstops) {
                /* Remove a tab stop from the hash table. */
-               g_hash_table_remove(terminal->pvt->tabstops,
+               g_hash_table_remove(m_tabstops,
                                    GINT_TO_POINTER(2 * column + 1));
        }
 }
 
 /* Check if we have a tabstop at a given position. */
-gboolean
-_vte_terminal_get_tabstop(VteTerminal *terminal, int column)
+bool
+VteTerminalPrivate::get_tabstop(int column)
 {
-       gpointer hash;
-       g_assert(VTE_IS_TERMINAL(terminal));
-       if (terminal->pvt->tabstops != NULL) {
-               hash = g_hash_table_lookup(terminal->pvt->tabstops,
+       if (m_tabstops != NULL) {
+               auto hash = g_hash_table_lookup(m_tabstops,
                                           GINT_TO_POINTER(2 * column + 1));
-               return (hash != NULL);
-       } else {
-               return FALSE;
+               return hash != nullptr;
        }
+
+        return false;
 }
 
 /* Reset the set of tab stops to the default. */
 void
-_vte_terminal_set_tabstop(VteTerminal *terminal, int column)
+VteTerminalPrivate::set_tabstop(int column)
 {
-       g_assert(VTE_IS_TERMINAL(terminal));
-       if (terminal->pvt->tabstops != NULL) {
+       if (m_tabstops != NULL) {
                /* Just set a non-NULL pointer for this column number. */
-               g_hash_table_insert(terminal->pvt->tabstops,
+               g_hash_table_insert(m_tabstops,
                                    GINT_TO_POINTER(2 * column + 1),
-                                   terminal);
+                                   m_terminal);
        }
 }
 
 /* Reset the set of tab stops to the default. */
-static void
-vte_terminal_set_default_tabstops(VteTerminal *terminal)
+void
+VteTerminalPrivate::set_default_tabstops()
 {
-        int i;
-       if (terminal->pvt->tabstops != NULL) {
-               g_hash_table_destroy(terminal->pvt->tabstops);
+       if (m_tabstops) {
+               g_hash_table_destroy(m_tabstops);
        }
-       terminal->pvt->tabstops = g_hash_table_new(NULL, NULL);
-        for (i = 0; i <= VTE_TAB_MAX; i += VTE_TAB_WIDTH) {
-               _vte_terminal_set_tabstop(terminal, i);
+       m_tabstops = g_hash_table_new(nullptr, nullptr);
+        for (int i = 0; i <= VTE_TAB_MAX; i += VTE_TAB_WIDTH) {
+               set_tabstop(i);
        }
 }
 
@@ -8218,7 +8215,7 @@ VteTerminalPrivate::VteTerminalPrivate(VteTerminal *t) :
        m_allow_bold = TRUE;
         m_deccolm_mode = FALSE;
         m_rewrap_on_resize = TRUE;
-       vte_terminal_set_default_tabstops(m_terminal);
+       set_default_tabstops();
 
         m_input_enabled = TRUE;
 
@@ -8570,7 +8567,7 @@ VteTerminalPrivate::~VteTerminalPrivate()
        m_adjustment_changed_pending = FALSE;
 
        /* Tabstop information. */
-       if (m_tabstops != NULL) {
+       if (m_tabstops) {
                g_hash_table_destroy(m_tabstops);
        }
 
@@ -10488,7 +10485,7 @@ VteTerminalPrivate::reset(bool clear_tabstops,
         m_cursor_style = VTE_CURSOR_STYLE_TERMINAL_DEFAULT;
        /* Do more stuff we refer to as a "full" reset. */
        if (clear_tabstops) {
-               vte_terminal_set_default_tabstops(m_terminal);
+               set_default_tabstops();
        }
        /* Reset restricted scrolling regions, leave insert mode, make
         * the cursor visible again. */
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 63644fc..39ebafb 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -562,6 +562,11 @@ public:
         void emit_increase_font_size();
         void emit_decrease_font_size();
 
+        void clear_tabstop(int column); // FIXMEchpe vte::grid::column_t ?
+        bool get_tabstop(int column);
+        void set_tabstop(int column);
+        void set_default_tabstops();
+
         void process_incoming();
 
         void match_contents_clear();
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 1ffa62a..b457a16 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -1037,11 +1037,11 @@ vte_sequence_handler_cursor_back_tab (VteTerminal *terminal, GValueArray *params
        /* Calculate which column is the previous tab stop. */
         newcol = terminal->pvt->cursor.col;
 
-       if (terminal->pvt->tabstops != NULL) {
+       if (terminal->pvt->tabstops) {
                /* Find the next tabstop. */
                while (newcol > 0) {
                        newcol--;
-                       if (_vte_terminal_get_tabstop(terminal,
+                       if (terminal->pvt->get_tabstop(
                                                     newcol % terminal->pvt->column_count)) {
                                break;
                        }
@@ -1790,7 +1790,7 @@ vte_sequence_handler_tab_set (VteTerminal *terminal, GValueArray *params)
        if (terminal->pvt->tabstops == NULL) {
                terminal->pvt->tabstops = g_hash_table_new(NULL, NULL);
        }
-       _vte_terminal_set_tabstop(terminal,
+       terminal->pvt->set_tabstop(
                                  terminal->pvt->cursor.col);
 }
 
@@ -1808,7 +1808,7 @@ vte_sequence_handler_tab (VteTerminal *terminal, GValueArray *params)
        if (terminal->pvt->tabstops != NULL) {
                /* Find the next tabstop. */
                for (newcol++; newcol < VTE_TAB_MAX; newcol++) {
-                       if (_vte_terminal_get_tabstop(terminal, newcol)) {
+                       if (terminal->pvt->get_tabstop(newcol)) {
                                break;
                        }
                }
@@ -1900,7 +1900,7 @@ vte_sequence_handler_tab_clear (VteTerminal *terminal, GValueArray *params)
                }
        }
        if (param == 0) {
-               _vte_terminal_clear_tabstop(terminal,
+               terminal->pvt->clear_tabstop(
                                            terminal->pvt->cursor.col);
        } else
        if (param == 3) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]