[vte] Simplify code
- From: Behdad Esfahbod <behdad src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vte] Simplify code
- Date: Thu, 27 Aug 2009 17:44:44 +0000 (UTC)
commit 54e717f081f365ac0e9b2a9947e50893c7666807
Author: Behdad Esfahbod <behdad behdad org>
Date: Wed Aug 26 00:00:17 2009 -0400
Simplify code
src/vte.c | 9 +++++----
src/vteseq.c | 21 ++++++---------------
2 files changed, 11 insertions(+), 19 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index 875c3d3..29e3c24 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -295,17 +295,18 @@ vte_g_array_fill(GArray *array, gconstpointer item, guint final_size)
}
/* Insert a blank line at an arbitrary position. */
-static void
+static VteRowData *
vte_insert_line_internal(VteTerminal *terminal, glong position)
{
/* Pad out the line data to the insertion point. */
- while (_vte_ring_next(terminal->pvt->screen->row_data) < position)
+ while (_vte_ring_next(terminal->pvt->screen->row_data) < position) {
_vte_ring_append(terminal->pvt->screen->row_data);
+ }
/* If we haven't inserted a line yet, insert a new one. */
if (_vte_ring_next(terminal->pvt->screen->row_data) >= position) {
- _vte_ring_insert(terminal->pvt->screen->row_data, position);
+ return _vte_ring_insert(terminal->pvt->screen->row_data, position);
} else {
- _vte_ring_append(terminal->pvt->screen->row_data);
+ return _vte_ring_append(terminal->pvt->screen->row_data);
}
}
diff --git a/src/vteseq.c b/src/vteseq.c
index a13150b..dacc255 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -114,7 +114,7 @@ vte_g_array_fill(GArray *array, gpointer item, guint final_size)
}
/* Insert a blank line at an arbitrary position. */
-static void
+static VteRowData *
vte_insert_line_internal(VteTerminal *terminal, glong position)
{
/* Pad out the line data to the insertion point. */
@@ -123,9 +123,9 @@ vte_insert_line_internal(VteTerminal *terminal, glong position)
}
/* If we haven't inserted a line yet, insert a new one. */
if (_vte_ring_next(terminal->pvt->screen->row_data) >= position) {
- _vte_ring_insert(terminal->pvt->screen->row_data, position);
+ return _vte_ring_insert(terminal->pvt->screen->row_data, position);
} else {
- _vte_ring_append(terminal->pvt->screen->row_data);
+ return _vte_ring_append(terminal->pvt->screen->row_data);
}
}
@@ -981,10 +981,7 @@ vte_sequence_handler_al (VteTerminal *terminal, GValueArray *params)
/* Clear a line off the end of the region and add one to the
* top of the region. */
vte_remove_line_internal(terminal, end);
- vte_insert_line_internal(terminal, start);
- /* Get the data for the new row. */
- rowdata = _vte_ring_index(screen->row_data, start);
- g_assert(rowdata != NULL);
+ rowdata = vte_insert_line_internal(terminal, start);
/* Add enough cells to it so that it has the default columns. */
vte_g_array_fill(rowdata->cells, &screen->fill_defaults,
terminal->column_count);
@@ -2850,10 +2847,7 @@ vte_sequence_handler_insert_lines (VteTerminal *terminal, GValueArray *params)
/* Clear a line off the end of the region and add one to the
* top of the region. */
vte_remove_line_internal(terminal, end);
- vte_insert_line_internal(terminal, row);
- /* Get the data for the new row. */
- rowdata = _vte_ring_index(screen->row_data, row);
- g_assert(rowdata != NULL);
+ rowdata = vte_insert_line_internal(terminal, row);
/* Add enough cells to it so that it has the default colors. */
vte_g_array_fill(rowdata->cells,
&screen->fill_defaults,
@@ -2899,10 +2893,7 @@ vte_sequence_handler_delete_lines (VteTerminal *terminal, GValueArray *params)
/* Insert a line at the end of the region and remove one from
* the top of the region. */
vte_remove_line_internal(terminal, row);
- vte_insert_line_internal(terminal, end);
- /* Get the data for the new row. */
- rowdata = _vte_ring_index(screen->row_data, end);
- g_assert(rowdata != NULL);
+ rowdata = vte_insert_line_internal(terminal, end);
/* Add enough cells to it so that it has the default colors. */
vte_g_array_fill(rowdata->cells,
&screen->fill_defaults,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]