billiob pushed a commit to branch master.

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

commit 3c47cc36e07507a72dcff23528911ddf29354317
Author: Boris Faure <[email protected]>
Date:   Mon Dec 24 17:01:11 2018 +0100

    termptyesc: CNL and margins + tests
---
 src/bin/termptyesc.c | 38 +++++++++++++++++++++++++++-----------
 tests/cnl.sh         | 36 ++++++++++++++++++++++++++++++++++++
 tests/tests.results  |  1 +
 3 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index c694f86..6efc8aa 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1111,6 +1111,31 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode 
**ptr,
      }
 }
 
+static void
+_handle_esc_csi_cnl(Termpty *ty, Eina_Unicode **ptr)
+{
+   Eina_Unicode *b = *ptr;
+   int arg = _csi_arg_get(ty, &b);
+   int max = ty->h;
+
+   if (arg == -CSI_ARG_ERROR)
+     return;
+   if (arg < 1)
+     arg = 1;
+
+   DBG("CNL - Cursor Next Line: %d", arg);
+   ty->termstate.wrapnext = 0;
+   ty->cursor_state.cy += arg;
+   if (ty->termstate.bottom_margin)
+     {
+        max = ty->termstate.bottom_margin;
+     }
+   TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy,
+                          ty->termstate.top_margin,
+                          max);
+   ty->cursor_state.cx = ty->termstate.left_margin;
+}
+
 static void
 _handle_esc_csi_dch(Termpty *ty, Eina_Unicode **ptr,
                     const Eina_Unicode * const end)
@@ -1712,17 +1737,8 @@ CUF:
              ty->cursor_state.cx = ty->termstate.left_margin;
           }
         break;
-      case 'E': // down relative N rows, and to col 0
-        arg = _csi_arg_get(ty, &b);
-        if (arg == -CSI_ARG_ERROR)
-          goto error;
-        if (arg < 1)
-          arg = 1;
-        DBG("CNL - Cursor Next Line: %d", arg);
-        ty->termstate.wrapnext = 0;
-        ty->cursor_state.cy += arg;
-        TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
-        ty->cursor_state.cx = 0;
+      case 'E':
+        _handle_esc_csi_cnl(ty, &b);
         break;
       case 'F': // up relative N rows, and to col 0
         arg = _csi_arg_get(ty, &b);
diff --git a/tests/cnl.sh b/tests/cnl.sh
new file mode 100755
index 0000000..ff72c62
--- /dev/null
+++ b/tests/cnl.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# fill space with E
+printf '\033[69;1;1;25;80$x'
+#set color
+printf '\033[46;31;3m'
+
+# move to 3; 3
+printf '\033[3;3H'
+printf 'a\033[Eb'
+
+printf 'c\033[2Ed'
+# 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$x'
+
+# move
+printf '\033[19;19H'
+printf 'e\033[5Ef'
+
+
+
+
+# set left/right margins:
+printf '\033[25;35s'
+# fill margin with @
+printf '\033[64;10;25;20;35$x'
+# restrict cursor
+printf '\033[?6h'
+# move
+printf '\033[10;10H'
+printf 'g\033[5Eh'
diff --git a/tests/tests.results b/tests/tests.results
index 33f9a43..d5e0992 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -32,3 +32,4 @@ sgr-long.sh ec0425b1daabaa59096c10939e79b105
 decsclm.sh 1ffcea3bfc4704d9091272dc59cbb311
 cha.sh 04092c42102eb0d71ae700ee47c9ac34
 dch.sh 40cf655681c098251f0dc3e7733c4db9
+cnl.sh 1f1512179c8e47e4bd880142774a3c66

-- 


Reply via email to