billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=5ab7a6f827d141262a9528b465f0c127fa24cc59

commit 5ab7a6f827d141262a9528b465f0c127fa24cc59
Author: Aleksandar Popadić <[email protected]>
Date:   Wed Dec 25 12:07:07 2013 +0100

    Do not let CUU and CUD scroll off screen.
    
    Summary:
    ISO 6429 is a bit vague here but I don't think that the cursor should
    be let go off screen.
    
    Test Plan: terminology -g80x30, vttest, 1 -> test failed
    
    Reviewers: billiob
    
    Reviewed By: billiob
    
    Differential Revision: https://phab.enlightenment.org/D409
---
 src/bin/termptyesc.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index a81715f..54696f4 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -378,25 +378,19 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
Eina_Unicode *ce)
       case 'A': // cursor up N
       case 'e': // cursor up N
         arg = _csi_arg_get(&b);
-        if (arg < 1) arg = 1;
         DBG("cursor up %d", arg);
         ty->state.wrapnext = 0;
-        for (i = 0; i < arg; i++)
-          {
-             ty->state.cy--;
-             _termpty_text_scroll_rev_test(ty, EINA_FALSE);
-          }
+        ty->state.cy -= arg;
+        ty->state.cy = MAX(0, ty->state.cy);
+        ty->state.cy = MIN(ty->h - 1, ty->state.cy);
         break;
       case 'B': // cursor down N
         arg = _csi_arg_get(&b);
-        if (arg < 1) arg = 1;
         DBG("cursor down %d", arg);
         ty->state.wrapnext = 0;
-        for (i = 0; i < arg; i++)
-          {
-             ty->state.cy++;
-             _termpty_text_scroll_test(ty, EINA_FALSE);
-          }
+        ty->state.cy += arg;
+        ty->state.cy = MAX(0, ty->state.cy);
+        ty->state.cy = MIN(ty->h - 1, ty->state.cy);
         break;
       case 'D': // cursor left N
         arg = _csi_arg_get(&b);

-- 


Reply via email to