termptyesc: correctly handle tab forward. Closes T4992
This commit is contained in:
parent
f3dd6f62fb
commit
b9d5a55aa4
|
@ -114,6 +114,24 @@ _csi_arg_get(Eina_Unicode **ptr)
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
_handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
|
_handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
|
||||||
{
|
{
|
||||||
|
@ -132,12 +150,8 @@ _handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
|
||||||
return;
|
return;
|
||||||
case 0x09: // HT '\t' (horizontal tab)
|
case 0x09: // HT '\t' (horizontal tab)
|
||||||
DBG("->HT");
|
DBG("->HT");
|
||||||
|
_tab_forward(ty, 1);
|
||||||
ty->termstate.had_cr = 0;
|
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;
|
return;
|
||||||
case 0x0a: // LF '\n' (new line)
|
case 0x0a: // LF '\n' (new line)
|
||||||
case 0x0b: // VT '\v' (vertical tab)
|
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);
|
ERR("Tabulation Clear (TBC) with invalid argument: %d", arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
{
|
{
|
||||||
int cx = ty->cursor_state.cx;
|
int cx = ty->cursor_state.cx;
|
||||||
|
|
||||||
arg = _csi_arg_get(&b);
|
arg = _csi_arg_get(&b);
|
||||||
DBG("Cursor Backward Tabulation (CBT): %d", arg);
|
DBG("Cursor Backward Tabulation (CBT): %d", arg);
|
||||||
if (arg < 1) arg = 1;
|
if (arg < 1) arg = 1;
|
||||||
|
|
||||||
for (; arg > 0; arg--)
|
for (; arg > 0; arg--)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
cx--;
|
cx--;
|
||||||
}
|
}
|
||||||
while ((cx >= 0) && (!TAB_TEST(ty, cx)));
|
while ((cx >= 0) && (!TAB_TEST(ty, cx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ty->cursor_state.cx = cx;
|
ty->cursor_state.cx = cx;
|
||||||
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
goto unhandled;
|
goto unhandled;
|
||||||
}
|
}
|
||||||
cc++;
|
cc++;
|
||||||
return cc - c;
|
return cc - c;
|
||||||
|
|
Loading…
Reference in New Issue