diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-06-30 11:13:17 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-06-30 11:13:17 +0200 |
| commit | 60fe132d6c59d54021091af8e5aa09fcd4704562 (patch) | |
| tree | 506249a4ebd7a09c0e2433c2a920c8c89a1ca4a8 /vis.c | |
| parent | 82a10e051c593e133554ce9675169fd68bb02ad7 (diff) | |
| download | vis-60fe132d6c59d54021091af8e5aa09fcd4704562.tar.gz vis-60fe132d6c59d54021091af8e5aa09fcd4704562.tar.xz | |
Cleanup insert/replace mode input handling
View should only display the file content, but not modify it.
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 22 |
1 files changed, 5 insertions, 17 deletions
@@ -592,21 +592,10 @@ static size_t op_repeat_insert(OperatorContext *c) { } static size_t op_repeat_replace(OperatorContext *c) { - Text *txt = vis->win->file->text; - size_t chars = 0, len = vis->buffer_repeat.len; - if (!len) - return c->pos; const char *data = vis->buffer_repeat.data; - for (size_t i = 0; i < len; i++) { - if (ISUTF8(data[i])) - chars++; - } - - Iterator it = text_iterator_get(txt, c->pos); - while (chars-- > 0) - text_iterator_char_next(&it, NULL); - text_delete(txt, c->pos, it.pos - c->pos); - return op_repeat_insert(c); + size_t len = vis->buffer_repeat.len; + editor_replace(vis, c->pos, data, len); + return c->pos + len; } /** movement implementations of type: size_t (*move)(const Arg*) */ @@ -818,8 +807,7 @@ static void replace(const Arg *arg) { action_reset(&vis->action_prev); vis->action_prev.op = &ops[OP_REPEAT_REPLACE]; buffer_put(&vis->buffer_repeat, k.str, strlen(k.str)); - editor_delete_key(vis); - editor_insert_key(vis, k.str, strlen(k.str)); + editor_replace(vis, pos, k.str, strlen(k.str)); text_snapshot(vis->win->file->text); view_cursor_to(vis->win->view, pos); } @@ -1037,7 +1025,7 @@ static void prompt_backspace(const Arg *arg) { if (!cmd || !*cmd) prompt_enter(NULL); else - view_backspace_key(vis->win->view); + delete(&(const Arg){ .i = MOVE_CHAR_PREV }); free(cmd); } |
