billiob pushed a commit to branch master.

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

commit 36682a1b4e0f0227d4d72e7c7f4be60ccd7f751b
Author: Boris Faure <[email protected]>
Date:   Tue Jan 1 20:19:17 2019 +0100

    termptyesc: CHA has to take into account DECOM + tests
---
 src/bin/termptyesc.c | 42 +++++++++++++++++++++++++++++++-----------
 tests/cha.sh         | 38 +++++++++++++++++++++++++++++++++++---
 2 files changed, 66 insertions(+), 14 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 1ef9357..8c1d5a3 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -2451,6 +2451,35 @@ _handle_esc_csi_cub(Termpty *ty, Eina_Unicode **ptr)
      }
 }
 
+static void
+_handle_esc_csi_cha(Termpty *ty, Eina_Unicode **ptr)
+{
+   Eina_Unicode *b = *ptr;
+   int arg = _csi_arg_get(ty, &b);
+   int min = 0;
+   int max = ty->w;
+
+   DBG("CHA - Cursor Horizontal Absolute: %d", arg);
+   if (arg == -CSI_ARG_ERROR)
+     return;
+   if (arg < 1)
+     arg = 1;
+   ty->termstate.wrapnext = 0;
+   if (ty->termstate.restrict_cursor)
+     {
+        if (ty->termstate.left_margin)
+          {
+             arg += ty->termstate.left_margin;
+          }
+        if (ty->termstate.right_margin)
+          {
+             max = ty->termstate.right_margin;
+          }
+     }
+   ty->cursor_state.cx = arg - 1;
+   TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, min, max);
+}
+
 static int
 _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
 {
@@ -2504,17 +2533,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
const Eina_Unicode *ce)
       case 'F':
         _handle_esc_csi_cpl(ty, &b);
         break;
-      case 'G': // to column N
-        arg = _csi_arg_get(ty, &b);
-        DBG("CHA - Cursor Horizontal Absolute: %d", arg);
-        if (arg == -CSI_ARG_ERROR)
-          goto error;
-        if (arg < 1)
-          arg = 1;
-        DBG("to column %d", arg);
-        ty->termstate.wrapnext = 0;
-        ty->cursor_state.cx = arg - 1;
-        TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
+      case 'G':
+        _handle_esc_csi_cha(ty, &b);
         break;
       case 'H':
         _handle_esc_csi_cursor_pos_set(ty, &b, cc);
diff --git a/tests/cha.sh b/tests/cha.sh
index 85e98c7..4bca96b 100755
--- a/tests/cha.sh
+++ b/tests/cha.sh
@@ -6,6 +6,38 @@ printf '\033[69;1;1;25;80\044x'
 #set color
 printf '\033[46;31;3m'
 
-printf '\033[3G1'
-printf '\033[G2'
-printf '\033[444444G3'
+# arg = 3
+printf '\033[1;10H1\033[3G1'
+
+# no arg
+printf '\033[2;10H2\033[G2'
+
+# go too far
+printf '\033[3;10H3\033[3333G3'
+
+# arg == 0
+printf '\033[4;10H4\033[0G4'
+
+# set top/bottom margins:
+printf '\033[10;20r'
+# allow left/right margins
+printf '\033[?69h'
+# set left/right margins:
+printf '\033[5;15s'
+# fill margin with @
+printf '\033[64;10;5;20;15\044x'
+
+# From inside to outside
+printf '\033[12;12HA\033[20GA'
+
+# From outside (on the left) to outside (on the right)
+printf '\033[12;2HB\033[40GB'
+
+# restrict cursor
+printf '\033[?6h'
+
+# From inside to inside
+printf '\033[4;4HC\033[6GC'
+
+# From inside to outside
+printf '\033[5;2HD\033[40GD'

-- 


Reply via email to