[vte] Rename _vte_row_data_set_length() to _vte_row_data_shrink()
- From: Behdad Esfahbod <behdad src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vte] Rename _vte_row_data_set_length() to _vte_row_data_shrink()
- Date: Thu, 27 Aug 2009 17:45:20 +0000 (UTC)
commit a2c132d6ffa528cbfde0ccd0ed35e08900182ffe
Author: Behdad Esfahbod <behdad behdad org>
Date: Wed Aug 26 18:45:36 2009 -0400
Rename _vte_row_data_set_length() to _vte_row_data_shrink()
src/ring.h | 4 ++--
src/vte.c | 15 +++------------
src/vteseq.c | 23 ++++++++++-------------
3 files changed, 15 insertions(+), 27 deletions(-)
---
diff --git a/src/ring.h b/src/ring.h
index bffc495..a990e86 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -109,7 +109,7 @@ typedef struct _VteRowData {
_vte_row_data_append (__row, __cell); \
} G_STMT_END
-#define _vte_row_data_set_length(__row, __len) g_array_set_size ((__row)->_cells, __len)
+#define _vte_row_data_shrink(__row, __max_len) g_array_set_size ((__row)->_cells, MIN((__row)->_cells->len, (unsigned int)(__max_len)))
#if 0
const vtecell *_vte_row_data_get (VteRowData *row, unsigned int col);
@@ -119,7 +119,7 @@ void _vte_row_data_insert (VteRowData *row, int pos, const vtecell *cell);
void _vte_row_data_append (VteRowData *row, const vtecell *cell);
void _vte_row_data_remove (VteRowData *row, unsigned int col);
void _vte_row_data_fill (VteRowData *row, const vtecell *cell, int len);
-void _vte_row_data_set_length (VteRowData *row, int len);
+void _vte_row_data_shrink (VteRowData *row, int max_len);
#endif
diff --git a/src/vte.c b/src/vte.c
index a70101e..e800401 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -2269,16 +2269,9 @@ static VteRowData *
vte_terminal_ensure_cursor(VteTerminal *terminal)
{
VteRowData *row;
- const VteScreen *screen;
- glong v;
row = _vte_terminal_ensure_row (terminal);
-
- screen = terminal->pvt->screen;
- v = screen->cursor_current.col;
-
- if (G_UNLIKELY ((glong) _vte_row_data_length (row) < v)) /* pad */
- _vte_row_data_fill (row, &basic_cell, v);
+ _vte_row_data_fill (row, &basic_cell, terminal->pvt->screen->cursor_current.col);
return row;
}
@@ -3039,8 +3032,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
for (i = 0; i < columns; i++)
_vte_row_data_insert (row, col + i, &screen->color_defaults);
} else {
- if (G_LIKELY ((glong) _vte_row_data_length (row) < col + columns))
- _vte_row_data_set_length (row, col + columns);
+ _vte_row_data_fill (row, &basic_cell, col + columns);
}
/* Convert any wide characters we may have broken into single
@@ -3096,8 +3088,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
pcell->attr = attr;
col++;
}
- if (G_UNLIKELY ((long) _vte_row_data_length (row) > terminal->column_count))
- _vte_row_data_set_length (row, terminal->column_count);
+ _vte_row_data_shrink (row, terminal->column_count);
/* Signal that this part of the window needs drawing. */
if (G_UNLIKELY (invalidate_now)) {
diff --git a/src/vteseq.c b/src/vteseq.c
index dc89b96..670db9d 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -305,9 +305,8 @@ _vte_terminal_clear_current_line (VteTerminal *terminal)
rowdata = _vte_ring_index(screen->row_data, screen->cursor_current.row);
g_assert(rowdata != NULL);
/* Remove it. */
- _vte_row_data_set_length (rowdata, 0);
- /* Add enough cells to the end of the line to fill out the
- * row. */
+ _vte_row_data_shrink (rowdata, 0);
+ /* Add enough cells to the end of the line to fill out the row. */
_vte_row_data_fill (rowdata, &screen->fill_defaults, terminal->column_count);
rowdata->soft_wrapped = 0;
/* Repaint this row. */
@@ -336,7 +335,7 @@ _vte_terminal_clear_above_current (VteTerminal *terminal)
rowdata = _vte_ring_index(screen->row_data, i);
g_assert(rowdata != NULL);
/* Remove it. */
- _vte_row_data_set_length (rowdata, 0);
+ _vte_row_data_shrink (rowdata, 0);
/* Add new cells until we fill the row. */
_vte_row_data_fill (rowdata, &screen->fill_defaults, terminal->column_count);
rowdata->soft_wrapped = 0;
@@ -1042,10 +1041,8 @@ vte_sequence_handler_cd (VteTerminal *terminal, GValueArray *params)
/* Get the data for the row we're clipping. */
rowdata = _vte_ring_index(screen->row_data, i);
/* Clear everything to the right of the cursor. */
- if ((rowdata != NULL) &&
- ((glong) _vte_row_data_length (rowdata) > screen->cursor_current.col)) {
- _vte_row_data_set_length (rowdata, screen->cursor_current.col);
- }
+ if (rowdata)
+ _vte_row_data_shrink (rowdata, screen->cursor_current.col);
}
/* Now for the rest of the lines. */
for (i = screen->cursor_current.row + 1;
@@ -1054,8 +1051,8 @@ vte_sequence_handler_cd (VteTerminal *terminal, GValueArray *params)
/* Get the data for the row we're removing. */
rowdata = _vte_ring_index(screen->row_data, i);
/* Remove it. */
- if (rowdata != NULL)
- _vte_row_data_set_length (rowdata, 0);
+ if (rowdata)
+ _vte_row_data_shrink (rowdata, 0);
}
/* Now fill the cleared areas. */
for (i = screen->cursor_current.row;
@@ -1095,7 +1092,7 @@ vte_sequence_handler_ce (VteTerminal *terminal, GValueArray *params)
/* Remove the data at the end of the array until the current column
* is the end of the array. */
if ((glong) _vte_row_data_length (rowdata) > screen->cursor_current.col) {
- _vte_row_data_set_length (rowdata, screen->cursor_current.col);
+ _vte_row_data_shrink (rowdata, screen->cursor_current.col);
/* We've modified the display. Make a note of it. */
terminal->pvt->text_deleted_flag = TRUE;
}
@@ -2069,7 +2066,7 @@ vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
if (cell->attr.fragment || cell->c != 0)
break;
}
- _vte_row_data_set_length (rowdata, i);
+ _vte_row_data_shrink (rowdata, i);
}
if ((glong) _vte_row_data_length (rowdata) <= col)
@@ -2981,7 +2978,7 @@ vte_sequence_handler_screen_alignment_test (VteTerminal *terminal, GValueArray *
rowdata = _vte_ring_index(screen->row_data, row);
g_assert(rowdata != NULL);
/* Clear this row. */
- _vte_row_data_set_length (rowdata, 0);
+ _vte_row_data_shrink (rowdata, 0);
_vte_terminal_emit_text_deleted(terminal);
/* Fill this row. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]