vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit b2d25fdd78b8f72e81d76da3de0855336a628b10 parent 522d74ff1ae94239c694714e47318ee9b5870c5c Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 16 Jul 2014 14:30:42 +0200 Implement replacement/overwrite Diffstat:
| M | editor.c | | | 8 | ++++++++ |
| M | editor.h | | | 2 | +- |
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/editor.c b/editor.c @@ -414,6 +414,14 @@ bool editor_delete(Editor *ed, size_t pos, size_t len) { return true; } +bool editor_replace(Editor *ed, size_t pos, char *c) { + // TODO argument validation: pos etc. + size_t len = strlen(c); + editor_delete(ed, pos, len); + editor_insert(ed, pos, c); + return true; +} + void editor_snapshot(Editor *ed) { ed->current_action = NULL; } diff --git a/editor.h b/editor.h @@ -9,8 +9,8 @@ typedef enum { typedef Iterate (*iterator_callback_t)(void *, size_t pos, const char *content, size_t len); - bool editor_insert(Editor*, size_t pos, char *c); +bool editor_replace(Editor*, size_t pos, char *c); bool editor_delete(Editor*, size_t pos, size_t len); bool editor_undo(Editor*); bool editor_redo(Editor*);