vt: implement (untested!) insert mode

\E4l is not horizontal index, but disable INSERT mode
This commit is contained in:
Daniel Eklöf 2019-07-03 21:16:41 +02:00
parent 1373d18dbc
commit 90dadfcc22
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 20 additions and 9 deletions

16
csi.c
View file

@ -484,16 +484,16 @@ csi_dispatch(struct terminal *term, uint8_t final)
break; break;
} }
case 'l': { case 'h':
/* Horizontal index */ /* smir - insert mode enable */
assert(false && "untested"); assert(false && "untested");
int param = param_get(term, 0, 1); term->insert_mode = true;
int col = term->cursor.col; break;
col = (col + param * 8) / 8 * 8; case 'l':
term_cursor_right(term, col - term->cursor.col); /* rmir - insert mode disable */
term->insert_mode = false;
break; break;
}
case 'r': { case 'r': {
int start = param_get(term, 0, 1); int start = param_get(term, 0, 1);

View file

@ -131,9 +131,11 @@ struct terminal {
pid_t slave; pid_t slave;
int ptmx; int ptmx;
bool hide_cursor;
enum decckm decckm; enum decckm decckm;
enum keypad_mode keypad_mode; enum keypad_mode keypad_mode;
bool hide_cursor;
bool auto_margin;
bool insert_mode;
bool bracketed_paste; bool bracketed_paste;
struct vt vt; struct vt vt;

9
vt.c
View file

@ -701,6 +701,15 @@ action(struct terminal *term, enum action action, uint8_t c)
struct cell *cell = &term->grid->cur_line[term->cursor.col]; struct cell *cell = &term->grid->cur_line[term->cursor.col];
term_damage_update(term, term->cursor.linear, 1); term_damage_update(term, term->cursor.linear, 1);
if (term->insert_mode) {
assert(false && "untested");
grid_memmove(
term->grid, term->cursor.linear + 1, term->cursor.linear,
term->cols - term->cursor.col - 1);
term_damage_update(
term, term->cursor.linear + 1, term->cols - term->cursor.col - 1);
}
if (term->vt.utf8.idx > 0) { if (term->vt.utf8.idx > 0) {
//LOG_DBG("print: UTF8: %.*s", (int)term->vt.utf8.idx, term->vt.utf8.data); //LOG_DBG("print: UTF8: %.*s", (int)term->vt.utf8.idx, term->vt.utf8.data);
memcpy(cell->c, term->vt.utf8.data, term->vt.utf8.idx); memcpy(cell->c, term->vt.utf8.data, term->vt.utf8.idx);