aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/termptyesc.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2016-12-18 19:17:42 +0100
committerBoris Faure <billiob@gmail.com>2016-12-18 19:17:42 +0100
commitb9d5a55aa42e15aa13ca381bd05a9617b2ca9fae (patch)
treec70a5271ea21403f23f5d001bec067047059ca1e /src/bin/termptyesc.c
parenttermpty: Tab markers are the same for each line. Ref 4992 (diff)
downloadterminology-b9d5a55aa42e15aa13ca381bd05a9617b2ca9fae.tar.gz
termptyesc: correctly handle tab forward. Closes https://phab.enlightenment.org/T4992
Diffstat (limited to 'src/bin/termptyesc.c')
-rw-r--r--src/bin/termptyesc.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index a293289..774bc79 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -115,6 +115,24 @@ _csi_arg_get(Eina_Unicode **ptr)
}
static void
+_tab_forward(Termpty *ty, int n)
+{
+ int cx = ty->cursor_state.cx;
+
+ for (; n > 0; n--)
+ {
+ do
+ {
+ cx++;
+ }
+ while ((cx < ty->w) && (!TAB_TEST(ty, cx)));
+ }
+
+ ty->cursor_state.cx = cx;
+ TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
+}
+
+static void
_handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
{
switch (*cc)
@@ -132,12 +150,8 @@ _handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
return;
case 0x09: // HT '\t' (horizontal tab)
DBG("->HT");
+ _tab_forward(ty, 1);
ty->termstate.had_cr = 0;
- //TERMPTY_SCREEN(ty, ty->cursor_state.cx, ty->cursor_state.cy).att.tab = 1;
- ty->termstate.wrapnext = 0;
- ty->cursor_state.cx += 8;
- ty->cursor_state.cx = (ty->cursor_state.cx / 8) * 8;
- TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
return;
case 0x0a: // LF '\n' (new line)
case 0x0b: // VT '\v' (vertical tab)
@@ -1093,29 +1107,35 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
ERR("Tabulation Clear (TBC) with invalid argument: %d", arg);
}
break;
- case 'Z':
- {
- int cx = ty->cursor_state.cx;
+ case 'Z':
+ {
+ int cx = ty->cursor_state.cx;
- arg = _csi_arg_get(&b);
- DBG("Cursor Backward Tabulation (CBT): %d", arg);
- if (arg < 1) arg = 1;
+ arg = _csi_arg_get(&b);
+ DBG("Cursor Backward Tabulation (CBT): %d", arg);
+ if (arg < 1) arg = 1;
- for (; arg > 0; arg--)
- {
- do
- {
- cx--;
- }
- while ((cx >= 0) && (!TAB_TEST(ty, cx)));
- }
+ for (; arg > 0; arg--)
+ {
+ do
+ {
+ cx--;
+ }
+ while ((cx >= 0) && (!TAB_TEST(ty, cx)));
+ }
- ty->cursor_state.cx = cx;
- TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
- }
- break;
+ ty->cursor_state.cx = cx;
+ TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
+ }
+ break;
+ case 'I':
+ arg = _csi_arg_get(&b);
+ if (arg < 1) arg = 1;
+ DBG("Cursor Forward Tabulation (CHT): %d", arg);
+ _tab_forward(ty, arg);
+ break;
default:
- goto unhandled;
+ goto unhandled;
}
cc++;
return cc - c;