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; }