aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bin/termptyesc.c59
-rwxr-xr-xtests/sd.sh71
-rwxr-xr-xtests/su.sh71
-rw-r--r--tests/tests.results2
4 files changed, 186 insertions, 17 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index b33dba9..252227c 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -2655,6 +2655,43 @@ _handle_esc_csi_dl(Termpty *ty, Eina_Unicode **ptr)
ty->cursor_state.cx = ty->termstate.left_margin;
}
+static void
+_handle_esc_csi_su(Termpty *ty, Eina_Unicode **ptr)
+{
+ Eina_Unicode *b = *ptr;
+ int arg = _csi_arg_get(ty, &b);
+ int i;
+
+ if (arg == -CSI_ARG_ERROR)
+ return;
+
+ TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
+ DBG("SU - Scroll Up: %d", arg);
+ for (i = 0; i < arg; i++)
+ termpty_text_scroll(ty, EINA_TRUE);
+}
+
+static void
+_handle_esc_csi_sd(Termpty *ty, Eina_Unicode **ptr)
+{
+ Eina_Unicode *b = *ptr;
+ int arg = _csi_arg_get(ty, &b);
+ int i;
+
+ if (arg == -CSI_ARG_ERROR)
+ return;
+ if (arg == 0)
+ {
+ WRN("Track Mouse: TODO");
+ return;
+ }
+
+ TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
+ DBG("SD - Scroll Down: %d", arg);
+ for (i = 0; i < arg; i++)
+ termpty_text_scroll_rev(ty, EINA_TRUE);
+}
+
static int
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
{
@@ -2735,26 +2772,14 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
case 'M':
_handle_esc_csi_dl(ty, &b);
break;
- case 'P': // erase and scrollback N chars
+ case 'P':
_handle_esc_csi_dch(ty, &b);
break;
- case 'S': // scroll up N lines
- arg = _csi_arg_get(ty, &b);
- if (arg == -CSI_ARG_ERROR)
- goto error;
- TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
- DBG("scroll up %d lines", arg);
- for (i = 0; i < arg; i++)
- termpty_text_scroll(ty, EINA_TRUE);
+ case 'S':
+ _handle_esc_csi_su(ty, &b);
break;
- case 'T': // scroll down N lines
- arg = _csi_arg_get(ty, &b);
- if (arg == -CSI_ARG_ERROR)
- goto error;
- TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
- DBG("scroll down %d lines", arg);
- for (i = 0; i < arg; i++)
- termpty_text_scroll_rev(ty, EINA_TRUE);
+ case 'T':
+ _handle_esc_csi_sd(ty, &b);
break;
case 'X': // erase N chars
arg = _csi_arg_get(ty, &b);
diff --git a/tests/sd.sh b/tests/sd.sh
new file mode 100755
index 0000000..8c75766
--- /dev/null
+++ b/tests/sd.sh
@@ -0,0 +1,71 @@
+#!/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;34;3m'
+
+# move
+printf '\033[1;10H'
+# SD 0
+printf '\033[0T1'
+# move
+printf '\033[3;10H'
+# SD default
+printf '\033[T2'
+# move
+printf '\033[5;10H'
+# SD 2
+printf '\033[2T3'
+
+# 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 '\033[T4'
+# move
+printf '\033[8;4H'
+# outside margins(left)
+printf '\033[T5'
+# move
+printf '\033[15;10H'
+# outside margins(bottom)
+printf '\033[T6'
+# move
+printf '\033[8;76H'
+# outside margins(right)
+printf '\033[T7'
diff --git a/tests/su.sh b/tests/su.sh
new file mode 100755
index 0000000..4a11aab
--- /dev/null
+++ b/tests/su.sh
@@ -0,0 +1,71 @@
+#!/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;34;3m'
+
+# move
+printf '\033[1;10H'
+# SU 0
+printf '\033[0S1'
+# move
+printf '\033[3;10H'
+# SU default
+printf '\033[S2'
+# move
+printf '\033[5;10H'
+# SU 2
+printf '\033[2S3'
+
+# 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 '\033[S4'
+# move
+printf '\033[8;4H'
+# outside margins(left)
+printf '\033[S5'
+# move
+printf '\033[15;10H'
+# outside margins(bottom)
+printf '\033[S6'
+# move
+printf '\033[8;76H'
+# outside margins(right)
+printf '\033[S7'
diff --git a/tests/tests.results b/tests/tests.results
index cb6c653..9aeca30 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -60,3 +60,5 @@ ed-4.sh 574f37ac24ead26ef86c03d7dfae3152
el.sh abca9d5e5990bed6bd72a7ab9f72b849
il.sh 1788258650a94f2568d05f749b6cf578
dl.sh e1e0ba19345d2ebf888f5a3e37f27037
+su.sh 591185f42b75daa61726217033a17eaf
+sd.sh 4bfda7ec3e6192acab077de2bc270525