aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor.c8
-rw-r--r--editor.h2
2 files changed, 9 insertions, 1 deletions
diff --git a/editor.c b/editor.c
index f3e1197..8033f23 100644
--- 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
index 3704d37..b612629 100644
--- 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*);