aboutsummaryrefslogtreecommitdiff
path: root/csi.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-17 09:19:28 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-17 09:19:28 +0000
commit20684afa8ca5bae9e3ba0f37855e5954d44e0c50 (patch)
treee64769fccf45e563302fa8d2e145531c4b655e5e /csi.c
parentkeymap: use hex instead of octal (diff)
csi: implement \E[@ (ICH - insert characters)
Diffstat (limited to 'csi.c')
-rw-r--r--csi.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/csi.c b/csi.c
index 9f89ccd2..d9d20d13 100644
--- a/csi.c
+++ b/csi.c
@@ -498,7 +498,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
}
case 'P': {
- /* DCH: Delete character */
+ /* DCH: Delete character(s) */
/* Number of characters to delete */
int count = min(
@@ -511,22 +511,37 @@ csi_dispatch(struct terminal *term, uint8_t final)
memmove(&term->grid->cur_row->cells[term->cursor.col],
&term->grid->cur_row->cells[term->cursor.col + count],
remaining * sizeof(term->grid->cur_row->cells[0]));
-#if 0
- term_damage_update(term, term->cursor.linear, remaining);
-#else
term->grid->cur_row->dirty = true;
-#endif
/* Erase the remainder of the line */
term_erase(
term,
&(struct coord){term->cursor.col + remaining, term->cursor.row},
&(struct coord){term->cols - 1, term->cursor.row});
-#if 0
+ break;
+ }
+
+ case '@': {
+ /* ICH: insert character(s) */
+
+ /* Number of characters to insert */
+ int count = min(
+ vt_param_get(term, 0, 1), term->cols - term->cursor.col);
+
+ /* Characters to move */
+ int remaining = term->cols - (term->cursor.col + count);
+
+ /* Push existing characters */
+ memmove(&term->grid->cur_row->cells[term->cursor.col + count],
+ &term->grid->cur_row->cells[term->cursor.col],
+ remaining * sizeof(term->grid->cur_row->cells[0]));
+ term->grid->cur_row->dirty = true;
+
+ /* Erase (insert space characters) */
term_erase(
- term, term->cursor.linear + remaining,
- term->cursor.linear + remaining + count);
-#endif
+ term,
+ &term->cursor,
+ &(struct coord){term->cursor.col + count - 1, term->cursor.row});
break;
}
@@ -547,12 +562,6 @@ csi_dispatch(struct terminal *term, uint8_t final)
term,
&term->cursor,
&(struct coord){term->cursor.col + count - 1, term->cursor.row});
-
-#if 0
- memset(&term->grid->cur_line[term->cursor.col],
- 0, count * sizeof(term->grid->cur_line[0]));
- term_damage_erase(term, term->cursor.linear, count);
-#endif
break;
}