aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/termptyesc.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2016-12-15 22:57:30 +0100
committerBoris Faure <billiob@gmail.com>2016-12-15 23:11:22 +0100
commitfae0d7ccee8f6f1696cae2f83f05f3477a781228 (patch)
tree2a52b89fa8037f4bf6ba89147d0b8570d8db1f42 /src/bin/termptyesc.c
parentterm pty fd - properly shut down without a 100% cpu hang (diff)
downloadterminology-fae0d7ccee8f6f1696cae2f83f05f3477a781228.tar.gz
termptyesc: handle correctly Cursor Back Tab. Ref https://phab.enlightenment.org/T4992
Diffstat (limited to 'src/bin/termptyesc.c')
-rw-r--r--src/bin/termptyesc.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 14fe55d..1188d8d 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1077,35 +1077,30 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
break;
*/
case 'g': // clear tabulation
+ /* TODO: handle correctly */
arg = _csi_arg_get(&b);
DBG("Tabulation Clear (TBC): %d", arg);
break;
- case 'Z': // Cursor Back Tab
+ case 'Z':
{
- int idx, size, cx = ty->cursor_state.cx, cy = ty->cursor_state.cy;
+ int cx = ty->cursor_state.cx, cy = ty->cursor_state.cy;
arg = _csi_arg_get(&b);
+ DBG("Cursor Backward Tabulation (CBT): %d", arg);
if (arg < 1) arg = 1;
- size = ty->w * cy + cx + 1;
- for (idx = size - 1; idx >= 0; idx--)
+ for (; arg > 0; arg--)
{
- if (TERMPTY_SCREEN(ty, cx, cy).att.tab) arg--;
- cx--;
- if (cx < 0)
+ do
{
- cx = ty->w - 1;
- cy--;
+ cx--;
}
- if (!arg) break;
- }
- if (!arg)
- {
- ty->cursor_state.cx = cx;
- TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
- ty->cursor_state.cy = cy;
- TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
+ while ((cx >= 0) &&
+ ((!TERMPTY_SCREEN(ty, cx, cy).att.tab) && (cx % 8 != 0)));
}
+
+ ty->cursor_state.cx = cx;
+ TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
}
break;
default: