aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-17 10:20:59 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-17 10:20:59 +0000
commit616e506f2e12983d1d5eeb7eca66e32b5aa876d9 (patch)
treebb2ef2ece0490e9ae5350e7e2f4958a4f0504f32
parentcsi: implement 'HPA' - Horizontal Position Absolute (diff)
csi: fix bad implementation of CBT (back tab)
* It takes a parameter, that indicates the number of tab stops to move through * Use the tab stops defined in the tab stops list, not hard coded mod 8 columns.
-rw-r--r--csi.c19
-rw-r--r--vt.c1
2 files changed, 14 insertions, 6 deletions
diff --git a/csi.c b/csi.c
index a0c909cc..74e68513 100644
--- a/csi.c
+++ b/csi.c
@@ -611,13 +611,20 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
}
- case 'Z': {
- /* Back tab */
- int col = term->cursor.point.col;
- col = (col - 8 + 7) / 8 * 8;
- term_cursor_right(term, col - term->cursor.point.col);
+ case 'Z':
+ /* CBT - Back tab (param is number of tab stops to move back through) */
+ for (int i = 0; i < vt_param_get(term, 0, 1); i++) {
+ int new_col = 0;
+ tll_rforeach(term->tab_stops, it) {
+ if (it->item < term->cursor.point.col) {
+ new_col = it->item;
+ break;
+ }
+ }
+ assert(term->cursor.point.col >= new_col);
+ term_cursor_left(term, term->cursor.point.col - new_col);
+ }
break;
- }
case 'h':
/* Set mode */
diff --git a/vt.c b/vt.c
index cad4cbcf..bcce4052 100644
--- a/vt.c
+++ b/vt.c
@@ -875,6 +875,7 @@ action(struct terminal *term, enum action _action, uint8_t c)
break;
}
}
+ assert(new_col >= term->cursor.point.col);
term_cursor_right(term, new_col - term->cursor.point.col);
break;
}