[vte] widget: Move some methods to VteTerminalPrivate



commit c85982033570ea6c4fb95ec24436ca5c8576cbf3
Author: Christian Persch <chpe gnome org>
Date:   Fri Nov 20 20:58:30 2015 +0100

    widget: Move some methods to VteTerminalPrivate

 src/vte-private.h  |    1 -
 src/vte.cc         |   88 ++++++++++++++++++++++++---------------------------
 src/vteinternal.hh |    3 ++
 src/vteseq.cc      |   12 +++---
 4 files changed, 50 insertions(+), 54 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 6ae9fc2..44089cd 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -61,7 +61,6 @@ void _vte_invalidate_cells(VteTerminal *terminal,
 void _vte_invalidate_cell(VteTerminal *terminal, glong col, glong row);
 void _vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic);
 VteRowData * _vte_new_row_data(VteTerminal *terminal);
-void _vte_terminal_adjust_adjustments(VteTerminal *terminal);
 void _vte_terminal_queue_contents_changed(VteTerminal *terminal);
 void _vte_terminal_emit_text_deleted(VteTerminal *terminal);
 void _vte_terminal_emit_text_inserted(VteTerminal *terminal);
diff --git a/src/vte.cc b/src/vte.cc
index ab24425..2898d49 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -2241,84 +2241,78 @@ vte_terminal_queue_adjustment_value_changed_clamped(VteTerminal *terminal, doubl
        vte_terminal_queue_adjustment_value_changed (terminal, v);
 }
 
-
 void
-_vte_terminal_adjust_adjustments(VteTerminal *terminal)
+VteTerminalPrivate::adjust_adjustments()
 {
-       VteScreen *screen;
-       long delta;
+       g_assert(m_screen != nullptr);
+       g_assert(m_screen->row_data != nullptr);
 
-       g_assert(terminal->pvt->screen != NULL);
-       g_assert(terminal->pvt->screen->row_data != NULL);
-
-       vte_terminal_queue_adjustment_changed(terminal);
+       vte_terminal_queue_adjustment_changed(m_terminal);
 
        /* The lower value should be the first row in the buffer. */
-       screen = terminal->pvt->screen;
-       delta = _vte_ring_delta(screen->row_data);
+       long delta = _vte_ring_delta(m_screen->row_data);
        /* Snap the insert delta and the cursor position to be in the visible
         * area.  Leave the scrolling delta alone because it will be updated
         * when the adjustment changes. */
-       screen->insert_delta = MAX(screen->insert_delta, delta);
-        terminal->pvt->cursor.row = MAX(terminal->pvt->cursor.row,
-                                        screen->insert_delta);
+       screen->insert_delta = MAX(m_screen->insert_delta, delta);
+        m_cursor.row = MAX(m_cursor.row,
+                           m_screen->insert_delta);
 
-       if (screen->scroll_delta > screen->insert_delta) {
-               vte_terminal_queue_adjustment_value_changed(terminal,
-                               screen->insert_delta);
+       if (m_screen->scroll_delta > m_screen->insert_delta) {
+               vte_terminal_queue_adjustment_value_changed(m_terminal,
+                               m_screen->insert_delta);
        }
 }
 
 /* Update the adjustment field of the widget.  This function should be called
  * whenever we add rows to or remove rows from the history or switch screens. */
-static void
-_vte_terminal_adjust_adjustments_full (VteTerminal *terminal)
+void
+VteTerminalPrivate::adjust_adjustments_full()
 {
-       gboolean changed = FALSE;
-       gdouble v;
+       bool changed = false;
 
-       g_assert(terminal->pvt->screen != NULL);
-       g_assert(terminal->pvt->screen->row_data != NULL);
+       g_assert(m_screen != NULL);
+       g_assert(m_screen->row_data != NULL);
 
-       _vte_terminal_adjust_adjustments(terminal);
+       adjust_adjustments();
 
-        g_object_freeze_notify(G_OBJECT(terminal->pvt->vadjustment));
+        g_object_freeze_notify(G_OBJECT(m_vadjustment));
 
        /* The step increment should always be one. */
-       v = gtk_adjustment_get_step_increment(terminal->pvt->vadjustment);
+       double v = gtk_adjustment_get_step_increment(m_vadjustment);
        if (v != 1) {
                _vte_debug_print(VTE_DEBUG_ADJ,
                                "Changing step increment from %.0lf to 1\n", v);
-               gtk_adjustment_set_step_increment(terminal->pvt->vadjustment, 1);
-               changed = TRUE;
+               gtk_adjustment_set_step_increment(m_vadjustment, 1);
+               changed = true;
        }
 
        /* Set the number of rows the user sees to the number of rows the
         * user sees. */
-       v = gtk_adjustment_get_page_size(terminal->pvt->vadjustment);
-       if (v != terminal->pvt->row_count) {
+       v = gtk_adjustment_get_page_size(m_vadjustment);
+       if (v != m_row_count) {
                _vte_debug_print(VTE_DEBUG_ADJ,
                                "Changing page size from %.0f to %ld\n",
-                                v, terminal->pvt->row_count);
-               gtk_adjustment_set_page_size(terminal->pvt->vadjustment,
-                                            terminal->pvt->row_count);
-               changed = TRUE;
+                                v, m_row_count);
+               gtk_adjustment_set_page_size(m_vadjustment,
+                                            m_row_count);
+               changed = true;
        }
 
        /* Clicking in the empty area should scroll one screen, so set the
         * page size to the number of visible rows. */
-       v = gtk_adjustment_get_page_increment(terminal->pvt->vadjustment);
-       if (v != terminal->pvt->row_count) {
+       v = gtk_adjustment_get_page_increment(m_vadjustment);
+       if (v != m_row_count) {
                _vte_debug_print(VTE_DEBUG_ADJ,
                                "Changing page increment from "
                                "%.0f to %ld\n",
-                               v, terminal->pvt->row_count);
-               gtk_adjustment_set_page_increment(terminal->pvt->vadjustment,
-                                                 terminal->pvt->row_count);
-               changed = TRUE;
+                               v, m_row_count);
+               gtk_adjustment_set_page_increment(m_vadjustment,
+                                                 m_row_count);
+               changed = true;
        }
 
-       g_object_thaw_notify(G_OBJECT(terminal->pvt->vadjustment));
+       g_object_thaw_notify(G_OBJECT(m_vadjustment));
 
        if (changed)
                _vte_debug_print(VTE_DEBUG_SIGNALS,
@@ -2512,7 +2506,7 @@ _vte_terminal_ensure_row (VteTerminal *terminal)
        delta = v - _vte_ring_next(screen->row_data) + 1;
        if (delta > 0) {
                row = vte_terminal_insert_rows (terminal, delta);
-               _vte_terminal_adjust_adjustments(terminal);
+               terminal->pvt->adjust_adjustments();
        } else {
                /* Find the row the cursor is in. */
                row = _vte_ring_index_writable (screen->row_data, v);
@@ -2564,7 +2558,7 @@ _vte_terminal_update_insert_delta(VteTerminal *terminal)
        /* Adjust the insert delta and scroll if needed. */
        if (delta != screen->insert_delta) {
                screen->insert_delta = delta;
-               _vte_terminal_adjust_adjustments(terminal);
+               terminal->pvt->adjust_adjustments();
        }
 }
 
@@ -3300,7 +3294,7 @@ _vte_terminal_cursor_down (VteTerminal *terminal)
                                _vte_terminal_scroll_region(terminal, start,
                                                            end - start + 1, 1);
                                /* Force scroll. */
-                               _vte_terminal_adjust_adjustments(terminal);
+                               terminal->pvt->adjust_adjustments();
                        } else {
                                /* If we're at the bottom of the scrolling
                                 * region, add a line at the top to scroll the
@@ -3344,7 +3338,7 @@ _vte_terminal_drop_scrollback (VteTerminal *terminal)
 
         if (terminal->pvt->screen == &terminal->pvt->normal_screen) {
                 vte_terminal_queue_adjustment_value_changed (terminal, 
terminal->pvt->normal_screen.insert_delta);
-                _vte_terminal_adjust_adjustments_full (terminal);
+                terminal->pvt->adjust_adjustments_full();
         }
 }
 
@@ -8142,7 +8136,7 @@ VteTerminalPrivate::set_size(long columns,
                                                     MAX (_vte_ring_delta (m_screen->row_data),
                                                          _vte_ring_next (m_screen->row_data) - 1));
 
-               _vte_terminal_adjust_adjustments_full(m_terminal);
+               adjust_adjustments_full();
                gtk_widget_queue_resize_no_redraw(m_widget);
                /* Our visible text changed. */
                vte_terminal_emit_text_modified(m_terminal);
@@ -10516,7 +10510,7 @@ VteTerminalPrivate::set_scrollback_lines(long lines)
         scroll_delta = m_screen->scroll_delta;
        m_screen->scroll_delta = -1;
        vte_terminal_queue_adjustment_value_changed(m_terminal, scroll_delta);
-       _vte_terminal_adjust_adjustments_full(m_terminal);
+       adjust_adjustments_full();
 
         return true;
 }
@@ -10617,7 +10611,7 @@ VteTerminalPrivate::reset(bool clear_tabstops,
                    vte_term_q_adj_val_changed() doesn't shortcut to no-op, see bug 730599. */
                 m_screen->scroll_delta = -1;
                 vte_terminal_queue_adjustment_value_changed(m_terminal, m_screen->insert_delta);
-               _vte_terminal_adjust_adjustments_full(m_terminal);
+               adjust_adjustments_full();
        }
         /* DECSCUSR cursor style */
         m_cursor_style = VTE_CURSOR_STYLE_TERMINAL_DEFAULT;
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 6bb6ca0..1727c6d 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -530,6 +530,9 @@ public:
 
         void beep();
 
+        void adjust_adjustments();
+        void adjust_adjustments_full();
+
         void match_contents_clear();
         void match_contents_refresh();
         void set_cursor_from_regex_match(struct vte_match_regex *regex);
diff --git a/src/vteseq.cc b/src/vteseq.cc
index e53dd8c..18173be 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -300,7 +300,7 @@ _vte_terminal_clear_screen (VteTerminal *terminal)
         * newly-cleared area and scroll if need be. */
        screen->insert_delta = initial;
         terminal->pvt->cursor.row = row + screen->insert_delta;
-       _vte_terminal_adjust_adjustments(terminal);
+       terminal->pvt->adjust_adjustments();
        /* Redraw everything. */
        _vte_invalidate_all(terminal);
        /* We've modified the display.  Make a note of it. */
@@ -403,7 +403,7 @@ _vte_terminal_scroll_text (VteTerminal *terminal, int scroll_amount)
                                   scroll_amount);
 
        /* Adjust the scrollbars if necessary. */
-       _vte_terminal_adjust_adjustments(terminal);
+       terminal->pvt->adjust_adjustments();
 
        /* We've modified the display.  Make a note of it. */
        terminal->pvt->text_inserted_flag = TRUE;
@@ -1778,7 +1778,7 @@ vte_sequence_handler_reverse_index (VteTerminal *terminal, GValueArray *params)
                 terminal->pvt->cursor.row--;
        }
        /* Adjust the scrollbars if necessary. */
-       _vte_terminal_adjust_adjustments(terminal);
+       terminal->pvt->adjust_adjustments();
        /* We modified the display, so make a note of it. */
        terminal->pvt->text_modified_flag = TRUE;
 }
@@ -2616,7 +2616,7 @@ vte_sequence_handler_insert_lines (VteTerminal *terminal, GValueArray *params)
        /* Update the display. */
        _vte_terminal_scroll_region(terminal, row, end - row + 1, param);
        /* Adjust the scrollbars if necessary. */
-       _vte_terminal_adjust_adjustments(terminal);
+       terminal->pvt->adjust_adjustments();
        /* We've modified the display.  Make a note of it. */
        terminal->pvt->text_inserted_flag = TRUE;
 }
@@ -2664,7 +2664,7 @@ vte_sequence_handler_delete_lines (VteTerminal *terminal, GValueArray *params)
        /* Update the display. */
        _vte_terminal_scroll_region(terminal, row, end - row + 1, -param);
        /* Adjust the scrollbars if necessary. */
-       _vte_terminal_adjust_adjustments(terminal);
+       terminal->pvt->adjust_adjustments();
        /* We've modified the display.  Make a note of it. */
        terminal->pvt->text_deleted_flag = TRUE;
 }
@@ -2831,7 +2831,7 @@ vte_sequence_handler_screen_alignment_test (VteTerminal *terminal, GValueArray *
                /* Find this row. */
                while (_vte_ring_next(screen->row_data) <= row)
                        _vte_terminal_ring_append (terminal, FALSE);
-               _vte_terminal_adjust_adjustments(terminal);
+                terminal->pvt->adjust_adjustments();
                rowdata = _vte_ring_index_writable (screen->row_data, row);
                g_assert(rowdata != NULL);
                /* Clear this row. */


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