From c1a4c0186a244c5efe3e3a9404a3c2e995d9b9b2 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 3 Jun 2009 23:37:30 +0000 Subject: [PATCH] Support insert mode by using insert character to shift the cells before writing as normal. --- screen-write.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/screen-write.c b/screen-write.c index 700e150c..d7d56d97 100644 --- a/screen-write.c +++ b/screen-write.c @@ -663,6 +663,7 @@ screen_write_cell( u_int width, xx, i; struct grid_cell tmp_gc, *tmp_gc2; size_t size; + int insert = 0; /* Ignore padding. */ if (gc->flags & GRID_FLAG_PADDING) @@ -714,6 +715,13 @@ screen_write_cell( gc = &tmp_gc; } + /* If in insert mode, make space for the cells. */ + if (s->mode & MODE_INSERT && s->cx <= screen_size_x(s) - width) { + xx = screen_size_x(s) - s->cx - width; + grid_move_cells(s->grid, s->cx + width, s->cx, s->cy, xx); + insert = 1; + } + /* Check this will fit on the current line; scroll if not. */ if (s->cx > screen_size_x(s) - width) { screen_write_carriagereturn(ctx); @@ -747,6 +755,8 @@ screen_write_cell( s->cx += width; /* Draw to the screen if necessary. */ + if (insert) + tty_write_cmd(ctx->wp, TTY_INSERTCHARACTER, width); if (screen_check_selection(s, s->cx - width, s->cy)) { s->sel.cell.data = gc->data; tty_write_cmd(ctx->wp, TTY_CELL, &s->sel.cell, &gu);