aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2019-01-20 13:15:54 +0100
committerBoris Faure <billiob@gmail.com>2019-01-20 18:44:08 +0100
commit7dccab5481f61c664bf21b78d90318f27178874d (patch)
treec563f568ef0cfc5e7c396f57b3bf6d11ba34327a /src
parenttermptyesc: add debug on CUD or VPR (diff)
downloadterminology-7dccab5481f61c664bf21b78d90318f27178874d.tar.gz
termptyesc: export VPA handler to its own function + tests
Diffstat (limited to 'src')
-rw-r--r--src/bin/termptyesc.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 2e134d4..1ef2089 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -2962,6 +2962,25 @@ _handle_esc_csi_uts(Termpty *ty, Eina_Unicode **ptr)
TAB_UNSET(ty, arg);
}
+static void
+_handle_esc_csi_vpa(Termpty *ty, Eina_Unicode **ptr)
+{
+ Eina_Unicode *b = *ptr;
+ int arg = _csi_arg_get(ty, &b);
+ int max = ty->h + 1;
+
+ if (arg == -CSI_ARG_ERROR)
+ return;
+ DBG("VPA - Cursor Vertical Position Absolute: %d", arg);
+ if (ty->termstate.restrict_cursor && (ty->termstate.bottom_margin > 0))
+ {
+ max = ty->termstate.bottom_margin + 1;
+ }
+ TERMPTY_RESTRICT_FIELD(arg, 1, max);
+ ty->termstate.wrapnext = 0;
+ ty->cursor_state.cy = arg - 1;
+}
+
static int
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
{
@@ -3085,17 +3104,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
if (*(cc-1) == ' ')
_handle_esc_csi_uts(ty, &b);
else
- {
- arg = _csi_arg_get(ty, &b);
- if (arg == -CSI_ARG_ERROR)
- goto error;
- if (arg < 1)
- arg = 1;
- DBG("to row %d", arg);
- ty->termstate.wrapnext = 0;
- ty->cursor_state.cy = arg - 1;
- TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
- }
+ _handle_esc_csi_vpa(ty, &b);
break;
case 'e':
_handle_esc_csi_cud_or_vpr(ty, &b, cc);