[vte] emulation: Migrating from terminfo: cursor moving operations



commit 60c0bca2f00cd55ea1eb42fd59fa017b62197c9d
Author: Egmont Koblinger <egmont gmail com>
Date:   Mon May 19 14:46:41 2014 +0200

    emulation: Migrating from terminfo: cursor moving operations
    
    Hardwire the behavior of cursor moving operations, rather than relying on
    terminfo.
    
    Remove support for nonstandard "move cursor to lower left corner".

 src/caps.c         |    2 +-
 src/vteseq-2.gperf |   24 +++---
 src/vteseq-n.gperf |   10 +-
 src/vteseq.c       |  236 ++++++++++++++++++++++------------------------------
 4 files changed, 118 insertions(+), 154 deletions(-)
---
diff --git a/src/caps.c b/src/caps.c
index 6aab339..ae94f39 100644
--- a/src/caps.c
+++ b/src/caps.c
@@ -76,7 +76,7 @@ struct _vte_capability_string _vte_xterm_capability_strings[] = {
        {ESC ">", "normal-keypad", 0},
        {ESC "D", "index", 0},
        {ESC "E", "next-line", 0},
-       {ESC "F", "cursor-lower-left", 0},
+        /* {ESC "F", "cursor-lower-left", 0}, */
        {ESC "H", "tab-set", 0},
        {ESC "M", "reverse-index", 0},
        /* {ESC "N", "single-shift-g2", 0}, */
diff --git a/src/vteseq-2.gperf b/src/vteseq-2.gperf
index e0444b7..5198f6d 100644
--- a/src/vteseq-2.gperf
+++ b/src/vteseq-2.gperf
@@ -76,7 +76,7 @@ struct vteseq_2_struct {
 "AL", VTE_SEQUENCE_HANDLER(vte_sequence_handler_AL)
 "DC", VTE_SEQUENCE_HANDLER(vte_sequence_handler_DC)
 "DL", VTE_SEQUENCE_HANDLER(vte_sequence_handler_DL)
-"DO", VTE_SEQUENCE_HANDLER(vte_sequence_handler_DO)
+#"DO", VTE_SEQUENCE_HANDLER(vte_sequence_handler_DO)
 #"F1", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
 #"F2", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
 #"F3", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
@@ -136,7 +136,7 @@ struct vteseq_2_struct {
 #"K3", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
 #"K4", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
 #"K5", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
-"LE", VTE_SEQUENCE_HANDLER(vte_sequence_handler_LE)
+#"LE", VTE_SEQUENCE_HANDLER(vte_sequence_handler_LE)
 #"LF", VTE_SEQUENCE_HANDLER_NULL
 #"LO", VTE_SEQUENCE_HANDLER_NULL
 #"MC", VTE_SEQUENCE_HANDLER_NULL
@@ -144,13 +144,13 @@ struct vteseq_2_struct {
 #"MR", VTE_SEQUENCE_HANDLER_NULL
 #"RA", VTE_SEQUENCE_HANDLER_NULL
 #"RF", VTE_SEQUENCE_HANDLER_NULL
-"RI", VTE_SEQUENCE_HANDLER(vte_sequence_handler_RI)
+#"RI", VTE_SEQUENCE_HANDLER(vte_sequence_handler_RI)
 #"RX", VTE_SEQUENCE_HANDLER_NULL
 #"SA", VTE_SEQUENCE_HANDLER_NULL
 #"SF", VTE_SEQUENCE_HANDLER(vte_sequence_handler_SF)
 #"SR", VTE_SEQUENCE_HANDLER(vte_sequence_handler_SR)
 #"SX", VTE_SEQUENCE_HANDLER_NULL
-"UP", VTE_SEQUENCE_HANDLER(vte_sequence_handler_UP)
+#"UP", VTE_SEQUENCE_HANDLER(vte_sequence_handler_UP)
 #"XF", VTE_SEQUENCE_HANDLER_NULL
 "ae", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ae)
 "al", VTE_SEQUENCE_HANDLER(vte_sequence_handler_al)
@@ -163,13 +163,13 @@ struct vteseq_2_struct {
 "cc", VTE_SEQUENCE_HANDLER(vte_sequence_handler_noop)
 "cd", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cd)
 "ce", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ce)
-"ch", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ch)
-"cl", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cl)
-"cm", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cm)
+#"ch", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ch)
+#"cl", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cl)
+#"cm", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cm)
 #"cr", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cr)
 "cs", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cs)
 #"ct", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ct)
-"cv", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cv)
+#"cv", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cv)
 "dc", VTE_SEQUENCE_HANDLER(vte_sequence_handler_dc)
 "dl", VTE_SEQUENCE_HANDLER(vte_sequence_handler_dl)
 "dm", VTE_SEQUENCE_HANDLER(vte_sequence_handler_noop)
@@ -182,7 +182,7 @@ struct vteseq_2_struct {
 "ff", VTE_SEQUENCE_HANDLER(vte_sequence_handler_noop)
 #"fs", VTE_SEQUENCE_HANDLER_NULL
 #"hd", VTE_SEQUENCE_HANDLER_NULL
-"ho", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ho)
+#"ho", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ho)
 #"hu", VTE_SEQUENCE_HANDLER_NULL
 #"i1", VTE_SEQUENCE_HANDLER_NULL
 #"i3", VTE_SEQUENCE_HANDLER_NULL
@@ -240,7 +240,7 @@ struct vteseq_2_struct {
 #"l9", VTE_SEQUENCE_HANDLER_NULL
 #"la", VTE_SEQUENCE_HANDLER_NULL
 #"le", VTE_SEQUENCE_HANDLER(vte_sequence_handler_le)
-"ll", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ll)
+#"ll", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ll)
 "mb", VTE_SEQUENCE_HANDLER(vte_sequence_handler_mb)
 "md", VTE_SEQUENCE_HANDLER(vte_sequence_handler_md)
 "me", VTE_SEQUENCE_HANDLER(vte_sequence_handler_me)
@@ -250,7 +250,7 @@ struct vteseq_2_struct {
 #"mo", VTE_SEQUENCE_HANDLER_NULL
 "mp", VTE_SEQUENCE_HANDLER(vte_sequence_handler_mp)
 "mr", VTE_SEQUENCE_HANDLER(vte_sequence_handler_mr)
-"nd", VTE_SEQUENCE_HANDLER(vte_sequence_handler_nd)
+#"nd", VTE_SEQUENCE_HANDLER(vte_sequence_handler_nd)
 #"nw", VTE_SEQUENCE_HANDLER(vte_sequence_handler_nw)
 #"pO", VTE_SEQUENCE_HANDLER_NULL
 #"pc", VTE_SEQUENCE_HANDLER_NULL
@@ -282,7 +282,7 @@ struct vteseq_2_struct {
 #"ts", VTE_SEQUENCE_HANDLER_NULL
 "uc", VTE_SEQUENCE_HANDLER(vte_sequence_handler_uc)
 "ue", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ue)
-"up", VTE_SEQUENCE_HANDLER(vte_sequence_handler_up)
+#"up", VTE_SEQUENCE_HANDLER(vte_sequence_handler_up)
 "us", VTE_SEQUENCE_HANDLER(vte_sequence_handler_us)
 "vb", VTE_SEQUENCE_HANDLER(vte_sequence_handler_vb)
 "ve", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ve)
diff --git a/src/vteseq-n.gperf b/src/vteseq-n.gperf
index 94aefe6..f95f813 100644
--- a/src/vteseq-n.gperf
+++ b/src/vteseq-n.gperf
@@ -32,7 +32,7 @@ struct vteseq_n_struct {
 "tab-set", VTE_SEQUENCE_HANDLER(vte_sequence_handler_tab_set)
 "decreset", VTE_SEQUENCE_HANDLER(vte_sequence_handler_decreset)
 "set-mode", VTE_SEQUENCE_HANDLER(vte_sequence_handler_set_mode)
-"cursor-up", VTE_SEQUENCE_HANDLER(vte_sequence_handler_UP)
+"cursor-up", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_up)
 "form-feed", VTE_SEQUENCE_HANDLER(vte_sequence_handler_form_feed)
 "next-line", VTE_SEQUENCE_HANDLER(vte_sequence_handler_next_line)
 "save-mode", VTE_SEQUENCE_HANDLER(vte_sequence_handler_save_mode)
@@ -42,7 +42,7 @@ struct vteseq_n_struct {
 #"media-copy", VTE_SEQUENCE_HANDLER_NULL
 "reset-mode", VTE_SEQUENCE_HANDLER(vte_sequence_handler_reset_mode)
 "soft-reset", VTE_SEQUENCE_HANDLER(vte_sequence_handler_soft_reset)
-"cursor-down", VTE_SEQUENCE_HANDLER(vte_sequence_handler_DO)
+"cursor-down", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_down)
 #"memory-lock", VTE_SEQUENCE_HANDLER_NULL
 "save-cursor", VTE_SEQUENCE_HANDLER(vte_sequence_handler_sc)
 "scroll-down", VTE_SEQUENCE_HANDLER(vte_sequence_handler_scroll_down)
@@ -62,12 +62,12 @@ struct vteseq_n_struct {
 #"7-bit-controls", VTE_SEQUENCE_HANDLER_NULL
 #"8-bit-controls", VTE_SEQUENCE_HANDLER_NULL
 #"change-logfile", VTE_SEQUENCE_HANDLER_NULL
-"cursor-forward", VTE_SEQUENCE_HANDLER(vte_sequence_handler_RI)
+"cursor-forward", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_forward)
 #"dec-media-copy", VTE_SEQUENCE_HANDLER_NULL
 "restore-cursor", VTE_SEQUENCE_HANDLER(vte_sequence_handler_rc)
 "set-icon-title", VTE_SEQUENCE_HANDLER(vte_sequence_handler_set_icon_title)
 "cursor-back-tab", VTE_SEQUENCE_HANDLER(vte_sequence_handler_back_tab)
-"cursor-backward", VTE_SEQUENCE_HANDLER(vte_sequence_handler_LE)
+"cursor-backward", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_backward)
 "cursor-position", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_position)
 "cursor-position-top-row", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_position_top_row)
 #"single-shift-g2", VTE_SEQUENCE_HANDLER_NULL
@@ -77,7 +77,7 @@ struct vteseq_n_struct {
 "erase-characters", VTE_SEQUENCE_HANDLER(vte_sequence_handler_erase_characters)
 "erase-in-display", VTE_SEQUENCE_HANDLER(vte_sequence_handler_erase_in_display)
 "set-window-title", VTE_SEQUENCE_HANDLER(vte_sequence_handler_set_window_title)
-"cursor-lower-left", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_lower_left)
+#"cursor-lower-left", VTE_SEQUENCE_HANDLER_NULL
 "delete-characters", VTE_SEQUENCE_HANDLER(vte_sequence_handler_DC)
 "application-keypad", VTE_SEQUENCE_HANDLER(vte_sequence_handler_application_keypad)
 #"change-font-number", VTE_SEQUENCE_HANDLER_NULL
diff --git a/src/vteseq.c b/src/vteseq.c
index f71c09a..e896a87 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -1143,43 +1143,33 @@ vte_sequence_handler_ce (VteTerminal *terminal, GValueArray *params)
                              screen->cursor_current.row, 1);
 }
 
-/* Move the cursor to the given column (horizontal position). */
+/* Move the cursor to the given column (horizontal position), 1-based. */
 static void
-vte_sequence_handler_ch (VteTerminal *terminal, GValueArray *params)
+vte_sequence_handler_cursor_character_absolute (VteTerminal *terminal, GValueArray *params)
 {
        VteScreen *screen;
        GValue *value;
        long val;
 
        screen = terminal->pvt->screen;
-       /* We only care if there's a parameter in there. */
+
+        val = 0;
        if ((params != NULL) && (params->n_values > 0)) {
                value = g_value_array_get_nth(params, 0);
                if (G_VALUE_HOLDS_LONG(value)) {
-                       val = CLAMP(g_value_get_long(value),
+                        val = CLAMP(g_value_get_long(value) - 1,
                                    0,
                                    terminal->pvt->column_count - 1);
-                       /* Move the cursor. */
-                       screen->cursor_current.col = val;
-                       _vte_terminal_cleanup_tab_fragments_at_cursor (terminal);
                }
        }
-}
-
-/* Clear the screen and home the cursor. */
-static void
-vte_sequence_handler_cl (VteTerminal *terminal, GValueArray *params)
-{
-       _vte_terminal_clear_screen (terminal);
-       _vte_terminal_home_cursor (terminal);
 
-       /* We've modified the display.  Make a note of it. */
-       terminal->pvt->text_deleted_flag = TRUE;
+        screen->cursor_current.col = val;
+        _vte_terminal_cleanup_tab_fragments_at_cursor (terminal);
 }
 
-/* Move the cursor to the given position. */
+/* Move the cursor to the given position, 1-based. */
 static void
-vte_sequence_handler_cm (VteTerminal *terminal, GValueArray *params)
+vte_sequence_handler_cursor_position (VteTerminal *terminal, GValueArray *params)
 {
        GValue *row, *col;
        long rowval, colval, origin;
@@ -1199,13 +1189,13 @@ vte_sequence_handler_cm (VteTerminal *terminal, GValueArray *params)
                        } else {
                                origin = 0;
                        }
-                       rowval = g_value_get_long(row) + origin;
+                        rowval = g_value_get_long(row) - 1 + origin;
                        rowval = CLAMP(rowval, 0, terminal->pvt->row_count - 1);
                }
                if (params->n_values >= 2) {
                        col = g_value_array_get_nth(params, 1);
                        if (G_VALUE_HOLDS_LONG(col)) {
-                               colval = g_value_get_long(col);
+                                colval = g_value_get_long(col) - 1;
                                colval = CLAMP(colval, 0, terminal->pvt->column_count - 1);
                        }
                }
@@ -1315,37 +1305,25 @@ vte_sequence_handler_cS (VteTerminal *terminal, GValueArray *params)
                                           screen->insert_delta + end);
 }
 
-/* Move the cursor to the lower left-hand corner. */
-static void
-vte_sequence_handler_cursor_lower_left (VteTerminal *terminal, GValueArray *params)
-{
-       VteScreen *screen;
-       long row;
-       screen = terminal->pvt->screen;
-       row = MAX(0, terminal->pvt->row_count - 1);
-       screen->cursor_current.row = screen->insert_delta + row;
-       screen->cursor_current.col = 0;
-}
-
-/* Move the cursor to the beginning of the next line, no scrolling. */
+/* Move the cursor to the beginning of the Nth next line, no scrolling. */
 static void
 vte_sequence_handler_cursor_next_line (VteTerminal *terminal, GValueArray *params)
 {
        terminal->pvt->screen->cursor_current.col = 0;
-       vte_sequence_handler_DO (terminal, params);
+        vte_sequence_handler_cursor_down (terminal, params);
 }
 
-/* Move the cursor to the beginning of the previous line, no scrolling. */
+/* Move the cursor to the beginning of the Nth previous line, no scrolling. */
 static void
 vte_sequence_handler_cursor_preceding_line (VteTerminal *terminal, GValueArray *params)
 {
        terminal->pvt->screen->cursor_current.col = 0;
-       vte_sequence_handler_UP (terminal, params);
+        vte_sequence_handler_cursor_up (terminal, params);
 }
 
-/* Move the cursor to the given row (vertical position). */
+/* Move the cursor to the given row (vertical position), 1-based. */
 static void
-vte_sequence_handler_cv (VteTerminal *terminal, GValueArray *params)
+vte_sequence_handler_line_position_absolute (VteTerminal *terminal, GValueArray *params)
 {
        VteScreen *screen;
        GValue *value;
@@ -1362,7 +1340,7 @@ vte_sequence_handler_cv (VteTerminal *terminal, GValueArray *params)
                        } else {
                                origin = 0;
                        }
-                       val = g_value_get_long(value) + origin;
+                        val = g_value_get_long(value) - 1 + origin;
                        val = CLAMP(val, 0, terminal->pvt->row_count - 1);
                        screen->cursor_current.row = screen->insert_delta + val;
                }
@@ -1461,32 +1439,33 @@ vte_sequence_handler_DL (VteTerminal *terminal, GValueArray *params)
        vte_sequence_handler_dl (terminal, params);
 }
 
-/* Cursor down, no scrolling. */
+/* Cursor down N lines, no scrolling. */
 static void
-vte_sequence_handler_do (VteTerminal *terminal, GValueArray *params)
+vte_sequence_handler_cursor_down (VteTerminal *terminal, GValueArray *params)
 {
-       long start, end;
+        long end;
        VteScreen *screen;
+        GValue *value;
+        long val;
 
        screen = terminal->pvt->screen;
 
        if (screen->scrolling_restricted) {
-               start = screen->insert_delta + screen->scrolling_region.start;
                end = screen->insert_delta + screen->scrolling_region.end;
        } else {
-               start = screen->insert_delta;
-               end = start + terminal->pvt->row_count - 1;
+                end = screen->insert_delta + terminal->pvt->row_count - 1;
        }
 
-       /* Move the cursor down. */
-       screen->cursor_current.row = MIN(screen->cursor_current.row + 1, end);
-}
+        val = 1;
+        if (params != NULL && params->n_values >= 1) {
+                value = g_value_array_get_nth(params, 0);
+                if (G_VALUE_HOLDS_LONG(value)) {
+                        val = CLAMP(g_value_get_long(value),
+                                    1, terminal->pvt->row_count);
+                }
+        }
 
-/* Cursor down, no scrolling. */
-static void
-vte_sequence_handler_DO (VteTerminal *terminal, GValueArray *params)
-{
-       vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_do);
+        screen->cursor_current.row = MIN(screen->cursor_current.row + val, end);
 }
 
 /* Start using alternate character set. */
@@ -1562,13 +1541,6 @@ vte_sequence_handler_form_feed (VteTerminal *terminal, GValueArray *params)
         vte_sequence_handler_line_feed (terminal, params);
 }
 
-/* Move the cursor to the home position. */
-static void
-vte_sequence_handler_ho (VteTerminal *terminal, GValueArray *params)
-{
-       _vte_terminal_home_cursor (terminal);
-}
-
 /* Insert a character. */
 static void
 vte_sequence_handler_ic (VteTerminal *terminal, GValueArray *params)
@@ -1599,7 +1571,7 @@ vte_sequence_handler_im (VteTerminal *terminal, GValueArray *params)
        terminal->pvt->screen->insert_mode = TRUE;
 }
 
-/* Cursor down, with scrolling. */
+/* Cursor down 1 line, with scrolling. */
 static void
 vte_sequence_handler_index (VteTerminal *terminal, GValueArray *params)
 {
@@ -1634,23 +1606,24 @@ vte_sequence_handler_backspace (VteTerminal *terminal, GValueArray *params)
        }
 }
 
-/* Move the cursor left N columns. */
+/* Cursor left N columns. */
 static void
-vte_sequence_handler_LE (VteTerminal *terminal, GValueArray *params)
-{
-        vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_backspace);
-}
-
-/* Move the cursor to the lower left corner of the display. */
-static void
-vte_sequence_handler_ll (VteTerminal *terminal, GValueArray *params)
+vte_sequence_handler_cursor_backward (VteTerminal *terminal, GValueArray *params)
 {
        VteScreen *screen;
-       screen = terminal->pvt->screen;
-       screen->cursor_current.row = MAX(screen->insert_delta,
-                                        screen->insert_delta +
-                                        terminal->pvt->row_count - 1);
-       screen->cursor_current.col = 0;
+        GValue *value;
+        long val;
+
+        screen = terminal->pvt->screen;
+
+        val = 1;
+        if (params != NULL && params->n_values >= 1) {
+                value = g_value_array_get_nth(params, 0);
+                if (G_VALUE_HOLDS_LONG(value)) {
+                        val = MAX(g_value_get_long(value), 1);
+                }
+        }
+        screen->cursor_current.col = MAX(screen->cursor_current.col - val, 1);
 }
 
 /* Blink on. */
@@ -1706,15 +1679,29 @@ vte_sequence_handler_mr (VteTerminal *terminal, GValueArray *params)
        terminal->pvt->screen->defaults.attr.reverse = 1;
 }
 
-/* Cursor right. */
+/* Cursor right N columns. */
 static void
-vte_sequence_handler_nd (VteTerminal *terminal, GValueArray *params)
+vte_sequence_handler_cursor_forward (VteTerminal *terminal, GValueArray *params)
 {
        VteScreen *screen;
+        GValue *value;
+        long val;
+
        screen = terminal->pvt->screen;
-       if ((screen->cursor_current.col + 1) < terminal->pvt->column_count) {
+
+        val = 1;
+        if (params != NULL && params->n_values >= 1) {
+                value = g_value_array_get_nth(params, 0);
+                if (G_VALUE_HOLDS_LONG(value)) {
+                        val = CLAMP(g_value_get_long(value),
+                                    1, terminal->pvt->column_count);
+                }
+        }
+        /* The cursor can be further to the right, don't move in that case. */
+        if (screen->cursor_current.col < terminal->pvt->column_count) {
                /* There's room to move right. */
-               screen->cursor_current.col++;
+                screen->cursor_current.col = MIN(screen->cursor_current.col + val,
+                                                 terminal->pvt->column_count - 1);
        }
 }
 
@@ -1746,13 +1733,6 @@ vte_sequence_handler_rc (VteTerminal *terminal, GValueArray *params)
                                           terminal->pvt->row_count - 1);
 }
 
-/* Cursor right N characters. */
-static void
-vte_sequence_handler_RI (VteTerminal *terminal, GValueArray *params)
-{
-       vte_sequence_handler_multiple_r(terminal, params, vte_sequence_handler_nd);
-}
-
 /* Save cursor (position). */
 static void
 vte_sequence_handler_sc (VteTerminal *terminal, GValueArray *params)
@@ -1904,7 +1884,7 @@ vte_sequence_handler_se (VteTerminal *terminal, GValueArray *params)
         terminal->pvt->screen->defaults.attr.reverse = 0;
 }
 
-/* Cursor down, with scrolling. */
+/* Cursor down 1 line, with scrolling. */
 static void
 vte_sequence_handler_line_feed (VteTerminal *terminal, GValueArray *params)
 {
@@ -2111,7 +2091,7 @@ vte_sequence_handler_uc (VteTerminal *terminal, GValueArray *params)
                                      column, cell->attr.columns,
                                      screen->cursor_current.row, 1);
                /* Move the cursor right. */
-               vte_sequence_handler_nd (terminal, params);
+               vte_sequence_handler_cursor_forward (terminal, params);
        }
 
        /* We've modified the display without changing the text.  Make a note
@@ -2126,12 +2106,14 @@ vte_sequence_handler_ue (VteTerminal *terminal, GValueArray *params)
        terminal->pvt->screen->defaults.attr.underline = 0;
 }
 
-/* Cursor up, no scrolling. */
+/* Cursor up N lines, no scrolling. */
 static void
-vte_sequence_handler_up (VteTerminal *terminal, GValueArray *params)
+vte_sequence_handler_cursor_up (VteTerminal *terminal, GValueArray *params)
 {
        VteScreen *screen;
        long start;
+        GValue *value;
+        long val;
 
        screen = terminal->pvt->screen;
 
@@ -2141,14 +2123,16 @@ vte_sequence_handler_up (VteTerminal *terminal, GValueArray *params)
                start = screen->insert_delta;
        }
 
-       screen->cursor_current.row = MAX(screen->cursor_current.row - 1, start);
-}
+        val = 1;
+        if (params != NULL && params->n_values >= 1) {
+                value = g_value_array_get_nth(params, 0);
+                if (G_VALUE_HOLDS_LONG(value)) {
+                        val = CLAMP(g_value_get_long(value),
+                                    1, terminal->pvt->row_count);
+                }
+        }
 
-/* Cursor up N lines, no scrolling. */
-static void
-vte_sequence_handler_UP (VteTerminal *terminal, GValueArray *params)
-{
-       vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_up);
+        screen->cursor_current.row = MAX(screen->cursor_current.row - val, start);
 }
 
 /* Underline start. */
@@ -2447,36 +2431,7 @@ vte_sequence_handler_character_attributes (VteTerminal *terminal, GValueArray *p
                terminal->pvt->screen->defaults.attr.back;
 }
 
-/* Move the cursor to the given column, 1-based. */
-static void
-vte_sequence_handler_cursor_character_absolute (VteTerminal *terminal, GValueArray *params)
-{
-       VteScreen *screen;
-       GValue *value;
-       long val;
-
-       screen = terminal->pvt->screen;
-
-        val = 0;
-       if ((params != NULL) && (params->n_values > 0)) {
-               value = g_value_array_get_nth(params, 0);
-               if (G_VALUE_HOLDS_LONG(value)) {
-                       val = CLAMP(g_value_get_long(value),
-                                   1, terminal->pvt->column_count) - 1;
-               }
-       }
-
-        screen->cursor_current.col = val;
-       _vte_terminal_cleanup_tab_fragments_at_cursor (terminal);
-}
-
-/* Move the cursor to the given position, 1-based. */
-static void
-vte_sequence_handler_cursor_position (VteTerminal *terminal, GValueArray *params)
-{
-       vte_sequence_handler_offset(terminal, params, -1, vte_sequence_handler_cm);
-}
-
+/* Move the cursor to the given column in the top row, 1-based. */
 static void
 vte_sequence_handler_cursor_position_top_row (VteTerminal *terminal, GValueArray *params)
 {
@@ -2487,7 +2442,7 @@ vte_sequence_handler_cursor_position_top_row (VteTerminal *terminal, GValueArray
 
         g_value_array_insert (params, 0, &value);
 
-        vte_sequence_handler_offset(terminal, params, -1, vte_sequence_handler_cm);
+        vte_sequence_handler_cursor_position(terminal, params);
 }
 
 /* Request terminal attributes. */
@@ -2678,16 +2633,25 @@ vte_sequence_handler_normal_keypad (VteTerminal *terminal, GValueArray *params)
        terminal->pvt->keypad_mode = VTE_KEYMODE_NORMAL;
 }
 
-/* Move the cursor. */
+/* Move the cursor to the given column (horizontal position), 1-based. */
 static void
 vte_sequence_handler_character_position_absolute (VteTerminal *terminal, GValueArray *params)
 {
-       vte_sequence_handler_offset(terminal, params, -1, vte_sequence_handler_ch);
-}
-static void
-vte_sequence_handler_line_position_absolute (VteTerminal *terminal, GValueArray *params)
-{
-       vte_sequence_handler_offset(terminal, params, -1, vte_sequence_handler_cv);
+        VteScreen *screen;
+        GValue *value;
+        long val;
+
+        screen = terminal->pvt->screen;
+        /* We only care if there's a parameter in there. */
+        if ((params != NULL) && (params->n_values > 0)) {
+                value = g_value_array_get_nth(params, 0);
+                if (G_VALUE_HOLDS_LONG(value)) {
+                        val = g_value_get_long(value);
+                        if (val > 0) {
+                                vte_sequence_handler_cursor_character_absolute (terminal, params);
+                        }
+                }
+        }
 }
 
 /* Set certain terminal attributes. */


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