aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2019-01-01 20:19:17 +0100
committerBoris Faure <billiob@gmail.com>2019-01-01 20:19:17 +0100
commit36682a1b4e0f0227d4d72e7c7f4be60ccd7f751b (patch)
tree5194507f917cc197f36116c71ceeaa395941fecb /src
parenttermptyesc: cleanup (diff)
downloadterminology-36682a1b4e0f0227d4d72e7c7f4be60ccd7f751b.tar.gz
termptyesc: CHA has to take into account DECOM + tests
Diffstat (limited to 'src')
-rw-r--r--src/bin/termptyesc.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 1ef9357..8c1d5a3 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -2451,6 +2451,35 @@ _handle_esc_csi_cub(Termpty *ty, Eina_Unicode **ptr)
}
}
+static void
+_handle_esc_csi_cha(Termpty *ty, Eina_Unicode **ptr)
+{
+ Eina_Unicode *b = *ptr;
+ int arg = _csi_arg_get(ty, &b);
+ int min = 0;
+ int max = ty->w;
+
+ DBG("CHA - Cursor Horizontal Absolute: %d", arg);
+ if (arg == -CSI_ARG_ERROR)
+ return;
+ if (arg < 1)
+ arg = 1;
+ ty->termstate.wrapnext = 0;
+ if (ty->termstate.restrict_cursor)
+ {
+ if (ty->termstate.left_margin)
+ {
+ arg += ty->termstate.left_margin;
+ }
+ if (ty->termstate.right_margin)
+ {
+ max = ty->termstate.right_margin;
+ }
+ }
+ ty->cursor_state.cx = arg - 1;
+ TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, min, max);
+}
+
static int
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
{
@@ -2504,17 +2533,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
case 'F':
_handle_esc_csi_cpl(ty, &b);
break;
- case 'G': // to column N
- arg = _csi_arg_get(ty, &b);
- DBG("CHA - Cursor Horizontal Absolute: %d", arg);
- if (arg == -CSI_ARG_ERROR)
- goto error;
- if (arg < 1)
- arg = 1;
- DBG("to column %d", arg);
- ty->termstate.wrapnext = 0;
- ty->cursor_state.cx = arg - 1;
- TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
+ case 'G':
+ _handle_esc_csi_cha(ty, &b);
break;
case 'H':
_handle_esc_csi_cursor_pos_set(ty, &b, cc);