billiob pushed a commit to branch master.

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

commit e117ff9153e491222754e9b835963ad660831e92
Author: Boris Faure <bill...@gmail.com>
Date:   Mon Jun 5 11:54:26 2017 +0200

    termptyesc: correctly handle cursor wrt right/left margins
---
 src/bin/termptyesc.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index c808669..78c2e36 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -788,7 +788,7 @@ _handle_esc_csi_decslrm(Termpty *ty, Eina_Unicode **b)
     right = 0;
 
   ty->termstate.left_margin = left  - 1;
-  ty->termstate.right_margin = right - 1;
+  ty->termstate.right_margin = right;
   _move_cursor_to_origin(ty);
 
   return;
@@ -838,6 +838,8 @@ _handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode 
**b,
        cx, cy);
    cx--;
    cy--;
+   if (ty->termstate.restrict_cursor)
+     cx += ty->termstate.left_margin;
    TERMPTY_RESTRICT_FIELD(cx, 0, ty->w);
    if (ty->termstate.restrict_cursor)
      cy += ty->termstate.top_margin;
@@ -918,9 +920,9 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
Eina_Unicode *ce)
         ty->cursor_state.cy = MIN(ty->h - 1, ty->cursor_state.cy + arg);
         TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
         if (ty->termstate.restrict_cursor && (ty->termstate.bottom_margin != 0)
-            && (ty->cursor_state.cy > ty->termstate.bottom_margin))
+            && (ty->cursor_state.cy >= ty->termstate.bottom_margin))
           {
-             ty->cursor_state.cy = ty->termstate.bottom_margin;
+             ty->cursor_state.cy = ty->termstate.bottom_margin - 1;
           }
         break;
       case 'D': // cursor left N
@@ -930,6 +932,11 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
Eina_Unicode *ce)
         ty->termstate.wrapnext = 0;
         ty->cursor_state.cx -= arg;
         TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
+        if (ty->termstate.restrict_cursor && (ty->termstate.left_margin != 0)
+            && (ty->cursor_state.cx < ty->termstate.left_margin))
+          {
+             ty->cursor_state.cx = ty->termstate.left_margin;
+          }
         break;
       case 'C': // cursor right N
       case 'a': // cursor right N
@@ -939,6 +946,11 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
Eina_Unicode *ce)
         ty->termstate.wrapnext = 0;
         ty->cursor_state.cx += arg;
         TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
+        if (ty->termstate.restrict_cursor && (ty->termstate.right_margin != 0)
+            && (ty->cursor_state.cx >= ty->termstate.right_margin))
+          {
+             ty->cursor_state.cx = ty->termstate.right_margin - 1;
+          }
         break;
       case 'H': // cursor pos set (CUP)
       case 'f': // cursor pos set (HVP)

-- 


Reply via email to