[vte] emulation: Fix absolute cursor movement with origin mode



commit a2a49dfda338d7ca9d836de9e3777d5c02f96ac8
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri Jul 25 14:53:20 2014 +0200

    emulation: Fix absolute cursor movement with origin mode

 src/vteseq.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/vteseq.c b/src/vteseq.c
index 818b82f..8a16981 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -824,9 +824,7 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
                break;
        case 6:
                /* Reposition the cursor in its new home position. */
-               terminal->pvt->screen->cursor_current.col = 0;
-               terminal->pvt->screen->cursor_current.row =
-                       terminal->pvt->screen->insert_delta;
+                _vte_terminal_home_cursor (terminal);
                break;
        case 47:
        case 1047:
@@ -1073,7 +1071,7 @@ static void
 vte_sequence_handler_cursor_position (VteTerminal *terminal, GValueArray *params)
 {
        GValue *row, *col;
-       long rowval, colval, origin;
+        long rowval, colval, origin, rowmax;
        VteScreen *screen;
 
        screen = terminal->pvt->screen;
@@ -1087,11 +1085,13 @@ vte_sequence_handler_cursor_position (VteTerminal *terminal, GValueArray *params
                        if (screen->origin_mode &&
                            screen->scrolling_restricted) {
                                origin = screen->scrolling_region.start;
+                                rowmax = screen->scrolling_region.end;
                        } else {
                                origin = 0;
+                                rowmax = terminal->pvt->row_count - 1;
                        }
                         rowval = g_value_get_long(row) - 1 + origin;
-                       rowval = CLAMP(rowval, 0, terminal->pvt->row_count - 1);
+                        rowval = CLAMP(rowval, origin, rowmax);
                }
                if (params->n_values >= 2) {
                        col = g_value_array_get_nth(params, 1);
@@ -1191,7 +1191,7 @@ vte_sequence_handler_line_position_absolute (VteTerminal *terminal, GValueArray
 {
        VteScreen *screen;
        GValue *value;
-       long val, origin;
+        long val, origin, rowmax;
        screen = terminal->pvt->screen;
        /* We only care if there's a parameter in there. */
        if ((params != NULL) && (params->n_values > 0)) {
@@ -1201,11 +1201,13 @@ vte_sequence_handler_line_position_absolute (VteTerminal *terminal, GValueArray
                        if (screen->origin_mode &&
                            screen->scrolling_restricted) {
                                origin = screen->scrolling_region.start;
+                                rowmax = screen->scrolling_region.end;
                        } else {
                                origin = 0;
+                                rowmax = terminal->pvt->row_count - 1;
                        }
                         val = g_value_get_long(value) - 1 + origin;
-                       val = CLAMP(val, 0, terminal->pvt->row_count - 1);
+                        val = CLAMP(val, origin, rowmax);
                        screen->cursor_current.row = screen->insert_delta + val;
                }
        }


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