[vte/vte-next: 129/223] Move methods to VteBuffer



commit 02cabd3c4d2e5c820b1edcbab6ba8cfa1df41bd5
Author: Christian Persch <chpe gnome org>
Date:   Thu Jun 9 21:52:00 2011 +0200

    Move methods to VteBuffer

 src/vte-private.h |    7 +++--
 src/vte.c         |   60 ++++++++++++++++++++++++++++++++--------------------
 src/vteseq.c      |   32 +++++++++++++---------------
 3 files changed, 56 insertions(+), 43 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 60d6691..ea68cf5 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -444,9 +444,6 @@ gboolean _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
 			       gboolean invalidate_cells);
 void _vte_terminal_scroll_region(VteTerminal *terminal,
 				 long row, glong count, glong delta);
-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_tab_fragments_at_cursor (VteTerminal *terminal);
 void _vte_terminal_audible_beep(VteTerminal *terminal);
@@ -483,6 +480,10 @@ void _vte_terminal_set_effect_color(VteTerminal *terminal,
 VteRowData *_vte_buffer_ring_insert (VteBuffer *buffer, glong position, gboolean fill);
 VteRowData *_vte_buffer_ring_append (VteBuffer *buffer, gboolean fill);
 void _vte_buffer_ring_remove (VteBuffer *buffer, glong position);
+void _vte_buffer_clear_tabstop(VteBuffer *buffer, int column);
+void _vte_buffer_clear_tabstops(VteBuffer *buffer);
+gboolean _vte_buffer_get_tabstop(VteBuffer *buffer, int column);
+void _vte_buffer_set_tabstop(VteBuffer *buffer, int column);
 
 /* private VteScreen methods */
 void _vte_screen_set_default_attributes(VteScreen *screen);
diff --git a/src/vte.c b/src/vte.c
index f3553e3..0f598d8 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -1039,24 +1039,35 @@ vte_terminal_deselect_all(VteTerminal *terminal)
 
 /* Remove a tabstop. */
 void
-_vte_terminal_clear_tabstop(VteTerminal *terminal, int column)
+_vte_buffer_clear_tabstop(VteBuffer *buffer,
+                          int column)
 {
-	g_assert(VTE_IS_TERMINAL(terminal));
-	if (terminal->pvt->tabstops != NULL) {
+	g_assert(VTE_IS_BUFFER(buffer));
+	if (buffer->pvt->tabstops != NULL) {
 		/* Remove a tab stop from the hash table. */
-		g_hash_table_remove(terminal->pvt->tabstops,
+		g_hash_table_remove(buffer->pvt->tabstops,
 				    GINT_TO_POINTER(2 * column + 1));
 	}
 }
 
+void
+_vte_buffer_clear_tabstops(VteBuffer *buffer)
+{
+        if (buffer->pvt->tabstops != NULL) {
+                g_hash_table_destroy(buffer->pvt->tabstops);
+                buffer->pvt->tabstops = NULL;
+        }
+}
+
 /* Check if we have a tabstop at a given position. */
 gboolean
-_vte_terminal_get_tabstop(VteTerminal *terminal, int column)
+_vte_buffer_get_tabstop(VteBuffer *buffer,
+                        int column)
 {
 	gpointer hash;
-	g_assert(VTE_IS_TERMINAL(terminal));
-	if (terminal->pvt->tabstops != NULL) {
-		hash = g_hash_table_lookup(terminal->pvt->tabstops,
+	g_assert(VTE_IS_BUFFER(buffer));
+	if (buffer->pvt->tabstops != NULL) {
+		hash = g_hash_table_lookup(buffer->pvt->tabstops,
 					   GINT_TO_POINTER(2 * column + 1));
 		return (hash != NULL);
 	} else {
@@ -1066,36 +1077,37 @@ _vte_terminal_get_tabstop(VteTerminal *terminal, int column)
 
 /* Reset the set of tab stops to the default. */
 void
-_vte_terminal_set_tabstop(VteTerminal *terminal, int column)
+_vte_buffer_set_tabstop(VteBuffer *buffer,
+                        int column)
 {
-	g_assert(VTE_IS_TERMINAL(terminal));
-	if (terminal->pvt->tabstops != NULL) {
+	g_assert(VTE_IS_BUFFER(buffer));
+	if (buffer->pvt->tabstops != NULL) {
 		/* Just set a non-NULL pointer for this column number. */
-		g_hash_table_insert(terminal->pvt->tabstops,
+		g_hash_table_insert(buffer->pvt->tabstops,
 				    GINT_TO_POINTER(2 * column + 1),
-				    terminal);
+				    buffer);
 	}
 }
 
 /* Reset the set of tab stops to the default. */
 static void
-vte_terminal_set_default_tabstops(VteTerminal *terminal)
+vte_buffer_set_default_tabstops(VteBuffer *buffer)
 {
 	int i, width = 0;
-	if (terminal->pvt->tabstops != NULL) {
-		g_hash_table_destroy(terminal->pvt->tabstops);
+	if (buffer->pvt->tabstops != NULL) {
+		g_hash_table_destroy(buffer->pvt->tabstops);
 	}
-	terminal->pvt->tabstops = g_hash_table_new(NULL, NULL);
-	if (terminal->pvt->termcap != NULL) {
-		width = _vte_termcap_find_numeric(terminal->pvt->termcap,
-						  terminal->pvt->emulation,
+	buffer->pvt->tabstops = g_hash_table_new(NULL, NULL);
+	if (buffer->pvt->termcap != NULL) {
+		width = _vte_termcap_find_numeric(buffer->pvt->termcap,
+						  buffer->pvt->emulation,
 						  "it");
 	}
 	if (width == 0) {
 		width = VTE_TAB_WIDTH;
 	}
 	for (i = 0; i <= VTE_TAB_MAX; i += width) {
-		_vte_terminal_set_tabstop(terminal, i);
+		_vte_buffer_set_tabstop(buffer, i);
 	}
 }
 
@@ -7675,7 +7687,7 @@ vte_terminal_init(VteTerminal *terminal)
 	pvt->bell_margin = 10;
 	pvt->allow_bold = TRUE;
 	pvt->nrc_mode = TRUE;
-	vte_terminal_set_default_tabstops(terminal);
+	vte_buffer_set_default_tabstops(buffer);
 
 	/* Cursor shape. */
 	term_pvt->cursor_shape = VTE_CURSOR_SHAPE_BLOCK;
@@ -12383,10 +12395,12 @@ vte_terminal_reset(VteTerminal *terminal,
                    gboolean clear_history)
 {
         VteTerminalPrivate *pvt;
+        VteBuffer *buffer;
 
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 
         pvt = terminal->pvt;
+        buffer = terminal->term_pvt->buffer;
 
         g_object_freeze_notify(G_OBJECT(terminal));
 
@@ -12472,7 +12486,7 @@ vte_terminal_reset(VteTerminal *terminal,
 	pvt->alternate_screen.status_line_contents = g_string_new(NULL);
 	/* Do more stuff we refer to as a "full" reset. */
 	if (clear_tabstops) {
-		vte_terminal_set_default_tabstops(terminal);
+		vte_buffer_set_default_tabstops(buffer);
 	}
 	/* Reset restricted scrolling regions, leave insert mode, make
 	 * the cursor visible again. */
diff --git a/src/vteseq.c b/src/vteseq.c
index 31cf446..0d61b11 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -997,7 +997,7 @@ vte_sequence_handler_bt (VteTerminal *terminal, GValueArray *params)
 		/* Find the next tabstop. */
 		while (newcol > 0) {
 			newcol--;
-			if (_vte_terminal_get_tabstop(terminal,
+			if (_vte_buffer_get_tabstop(terminal->term_pvt->buffer,
 						     newcol % terminal->pvt->column_count)) {
 				break;
 			}
@@ -1296,10 +1296,7 @@ vte_sequence_handler_cS (VteTerminal *terminal, GValueArray *params)
 static void
 vte_sequence_handler_ct (VteTerminal *terminal, GValueArray *params)
 {
-	if (terminal->pvt->tabstops != NULL) {
-		g_hash_table_destroy(terminal->pvt->tabstops);
-		terminal->pvt->tabstops = NULL;
-	}
+        _vte_buffer_clear_tabstops(terminal->term_pvt->buffer);
 }
 
 /* Move the cursor to the lower left-hand corner. */
@@ -2024,17 +2021,20 @@ vte_sequence_handler_SR (VteTerminal *terminal, GValueArray *params)
 static void
 vte_sequence_handler_st (VteTerminal *terminal, GValueArray *params)
 {
-	if (terminal->pvt->tabstops == NULL) {
-		terminal->pvt->tabstops = g_hash_table_new(NULL, NULL);
+        VteBuffer *buffer = terminal->term_pvt->buffer;
+
+	if (buffer->pvt->tabstops == NULL) {
+		buffer->pvt->tabstops = g_hash_table_new(NULL, NULL);
 	}
-	_vte_terminal_set_tabstop(terminal,
-				 terminal->pvt->screen->cursor_current.col);
+	_vte_buffer_set_tabstop(buffer,
+				buffer->pvt->screen->cursor_current.col);
 }
 
 /* Tab. */
 static void
 vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
 {
+        VteBuffer *buffer = terminal->term_pvt->buffer;
 	VteScreen *screen;
 	long old_len, newcol, col;
 
@@ -2044,10 +2044,10 @@ vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
 
 	g_assert (col >= 0);
 
-	if (terminal->pvt->tabstops != NULL) {
+	if (buffer->pvt->tabstops != NULL) {
 		/* Find the next tabstop. */
 		for (newcol++; newcol < VTE_TAB_MAX; newcol++) {
-			if (_vte_terminal_get_tabstop(terminal, newcol)) {
+			if (_vte_buffer_get_tabstop(buffer, newcol)) {
 				break;
 			}
 		}
@@ -2126,6 +2126,7 @@ vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
 static void
 vte_sequence_handler_tab_clear (VteTerminal *terminal, GValueArray *params)
 {
+        VteBuffer *buffer = terminal->term_pvt->buffer;
 	GValue *value;
 	long param = 0;
 
@@ -2136,14 +2137,11 @@ vte_sequence_handler_tab_clear (VteTerminal *terminal, GValueArray *params)
 		}
 	}
 	if (param == 0) {
-		_vte_terminal_clear_tabstop(terminal,
-					   terminal->pvt->screen->cursor_current.col);
+		_vte_buffer_clear_tabstop(buffer,
+					  buffer->pvt->screen->cursor_current.col);
 	} else
 	if (param == 3) {
-		if (terminal->pvt->tabstops != NULL) {
-			g_hash_table_destroy(terminal->pvt->tabstops);
-			terminal->pvt->tabstops = NULL;
-		}
+                _vte_buffer_clear_tabstops(buffer);
 	}
 }
 



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