aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2019-01-11 23:29:42 +0100
committerBoris Faure <billiob@gmail.com>2019-01-11 23:30:43 +0100
commit89a6a9d6529137529487b744055224886a99598a (patch)
tree382f5a7e3db3d2c6e9ac7f248ada174fb7915715
parenttermptyesc: extract TBC to its own function + tests (diff)
downloadterminology-89a6a9d6529137529487b744055224886a99598a.tar.gz
termptyesc: extract ECH handler to its own function + test
Test is not fully working at the moment. There seems to be an issue with appending text outside margins
-rw-r--r--src/bin/termptyesc.c22
-rwxr-xr-xtests/ech.sh85
-rw-r--r--tests/tests.results1
3 files changed, 101 insertions, 7 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index f0e324e..e6e3fed 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -2790,6 +2790,19 @@ _handle_esc_csi_tbc(Termpty *ty, Eina_Unicode **ptr)
}
}
+static void
+_handle_esc_csi_ech(Termpty *ty, Eina_Unicode **ptr)
+{
+ Eina_Unicode *b = *ptr;
+ int arg = _csi_arg_get(ty, &b);
+
+ if (arg == -CSI_ARG_ERROR)
+ return;
+ DBG("ECH - Erase Character: %d", arg);
+ TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);
+ termpty_clear_line(ty, TERMPTY_CLR_END, arg);
+}
+
static int
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
{
@@ -2891,13 +2904,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
else
_handle_esc_csi_ctc(ty, &b);
break;
- case 'X': // erase N chars
- arg = _csi_arg_get(ty, &b);
- if (arg == -CSI_ARG_ERROR)
- goto error;
- TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);
- DBG("ECH: erase %d chars", arg);
- termpty_clear_line(ty, TERMPTY_CLR_END, arg);
+ case 'X':
+ _handle_esc_csi_ech(ty, &b);
break;
case 'Z':
{
diff --git a/tests/ech.sh b/tests/ech.sh
new file mode 100755
index 0000000..5134e75
--- /dev/null
+++ b/tests/ech.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+# fill space
+PL=1
+for _ in $(seq 0 23); do
+ PL=$((PL+1))
+ if [ $PL -gt 9 ] ; then
+ PL=1
+ fi
+ printf '%s' "$PL"
+ for _ in $(seq 2 $PL); do
+ printf '#'
+ done
+ PR=$((9 - PL))
+ for _ in $(seq 0 6); do
+ printf '\033[0;1m\-'
+ printf '\033[0;46;1;4m/'
+ printf '\033[0;46;1;4m|'
+ printf '\033[0;1;4;7m\\'
+ printf '\033[0m~'
+ printf '\033[0;1m_'
+ printf '\033[0;31;7m>'
+ printf '\033[0;31;4;7m^'
+ printf '\033[0;1;7m<'
+ done
+ printf '\033[0m'
+ for _ in $(seq 1 $PR); do
+ printf '#'
+ done
+ printf '%s' "$PR"
+done
+
+# set color
+printf '\033[43;32;3m'
+
+# move
+printf '\033[1;10H'
+# ECH 0
+printf '1>\033[0X'
+# move
+printf '\033[3;10H'
+# ECH default
+printf '2>\033[X'
+# move
+printf '\033[5;10H'
+# ECH 3
+printf '3>\033[3X'
+
+
+# set top/bottom margins:
+printf '\033[8;14r'
+# allow left/right margins
+printf '\033[?69h'
+# set left/right margins:
+printf '\033[5;75s'
+
+# move
+printf '\033[7;10H'
+# outside margins (top)
+printf '4>\033[X'
+# move
+printf '\033[8;1H'
+# outside margins(left)
+printf '5>\033[X'
+# move
+printf '\033[15;10H'
+# outside margins(bottom)
+printf '6>\033[X'
+# move
+printf '\033[8;76H'
+# outside margins(right)
+printf '7>\033[X'
+
+# move
+printf '\033[9;10H'
+# ECH full line
+printf '8>\033[88888X'
+
+# restrict cursor
+printf '\033[?6h'
+
+# move
+printf '\033[4;4H'
+# ECH still goes outside margins
+printf '9>\033[888X'
diff --git a/tests/tests.results b/tests/tests.results
index da071f0..3191137 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -65,3 +65,4 @@ sd.sh 4bfda7ec3e6192acab077de2bc270525
decst8c.sh 0ea805e8f4c2626ce66c566a10548d0f
ctc.sh d35eeacdb2e99f5ac8cc3c4e8d72f8b0
tbc.sh d0216e4056e5ab1cb4d411b6d6074785
+ech.sh 6257d40c467d63cc7883c380357d87f7