aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2018-12-24 18:10:20 +0100
committerBoris Faure <billiob@gmail.com>2018-12-27 22:14:44 +0100
commite23d78e10249bea1f0ab221a2fa1e9b8a5b72b0b (patch)
tree170139dec6d78e5e9fd97533d3f3c946bd7b934e
parenttermptyesc: CNL and margins + tests (diff)
downloadterminology-e23d78e10249bea1f0ab221a2fa1e9b8a5b72b0b.tar.gz
termptyesc: cpl and margins + tests
-rw-r--r--src/bin/termptyesc.c37
-rwxr-xr-xtests/cpl.sh36
-rw-r--r--tests/tests.results1
3 files changed, 64 insertions, 10 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 6efc8aa..4874132 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1137,6 +1137,31 @@ _handle_esc_csi_cnl(Termpty *ty, Eina_Unicode **ptr)
}
static void
+_handle_esc_csi_cpl(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("CPL - Cursor Previous 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)
{
@@ -1740,16 +1765,8 @@ CUF:
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);
- if (arg == -CSI_ARG_ERROR)
- goto error;
- TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
- DBG("CPL - Cursor Previous 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 'F':
+ _handle_esc_csi_cpl(ty, &b);
break;
case 'G': // to column N
arg = _csi_arg_get(ty, &b);
diff --git a/tests/cpl.sh b/tests/cpl.sh
new file mode 100755
index 0000000..8243784
--- /dev/null
+++ b/tests/cpl.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 7; 7
+printf '\033[7;7H'
+printf 'a\033[Fb'
+
+printf 'c\033[2Fd'
+# 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[12;19H'
+printf 'e\033[5Ff'
+
+
+
+
+# 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[2;2H'
+printf 'g\033[5Fh'
diff --git a/tests/tests.results b/tests/tests.results
index d5e0992..94723ed 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -33,3 +33,4 @@ decsclm.sh 1ffcea3bfc4704d9091272dc59cbb311
cha.sh 04092c42102eb0d71ae700ee47c9ac34
dch.sh 40cf655681c098251f0dc3e7733c4db9
cnl.sh 1f1512179c8e47e4bd880142774a3c66
+cpl.sh 9145c88adb762a6a59c5bf69191b949e