diff --git a/src/bin/termpty.c b/src/bin/termpty.c index 80e29390..f7449a8b 100644 --- a/src/bin/termpty.c +++ b/src/bin/termpty.c @@ -1507,8 +1507,10 @@ termpty_cell_codepoint_att_fill(Termpty *ty, Eina_Unicode codepoint, for (i = 0; i < n; i++) { + int had_tabmarker = dst[i].att.tab; _handle_block_codepoint_overwrite(ty, dst[i].codepoint, codepoint); dst[i] = local; + dst[i].att.tab = had_tabmarker; } } diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 14fe55db..1188d8d4 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: