vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit ecac50f1a59f9a9a216e13460663c6df39171bf7
parent 82bf7752373a04e99d3b820b555e69b2cdaad88c
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat, 13 Sep 2014 22:35:26 +0200

Rename text_insert_raw to text_insert

Diffstat:
Meditor.c | 4++--
Mtext.c | 6+-----
Mtext.h | 3+--
Mvis.c | 2+-
Mwindow.c | 4++--
5 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/editor.c b/editor.c @@ -412,7 +412,7 @@ void editor_delete_key(Editor *ed) { } void editor_insert(Editor *ed, size_t pos, const char *c, size_t len) { - text_insert_raw(ed->win->text, pos, c, len); + text_insert(ed->win->text, pos, c, len); editor_windows_invalidate(ed, pos, pos + len); } @@ -512,7 +512,7 @@ void editor_prompt_hide(Editor *ed) { void editor_prompt_set(Editor *ed, const char *line) { Text *text = ed->prompt->win->text; editor_prompt_clear(ed->prompt); - text_insert_raw(text, 0, line, strlen(line)); + text_insert(text, 0, line, strlen(line)); editor_window_draw(ed->prompt->win); } diff --git a/text.c b/text.c @@ -491,7 +491,7 @@ static void change_free(Change *c) { * | | |short| | existing text | | | * \-+ <-- +-----+ <-- +---------------+ <-- +-/ */ -bool text_insert_raw(Text *txt, size_t pos, const char *data, size_t len) { +bool text_insert(Text *txt, size_t pos, const char *data, size_t len) { if (pos > txt->size) return false; if (pos < txt->lines.pos) @@ -544,10 +544,6 @@ bool text_insert_raw(Text *txt, size_t pos, const char *data, size_t len) { return true; } -bool text_insert(Text *txt, size_t pos, const char *data) { - return text_insert_raw(txt, pos, data, strlen(data)); -} - size_t text_undo(Text *txt) { size_t pos = -1; /* taking a snapshot makes sure that txt->current_action is reset */ diff --git a/text.h b/text.h @@ -33,8 +33,7 @@ Text *text_load(const char *file); const char *text_filename_get(Text*); /* associate a filename with the yet unnamed buffer */ void text_filename_set(Text*, const char *filename); -bool text_insert(Text*, size_t pos, const char *data); -bool text_insert_raw(Text*, size_t pos, const char *data, size_t len); +bool text_insert(Text*, size_t pos, const char *data, size_t len); bool text_delete(Text*, size_t pos, size_t len); void text_snapshot(Text*); /* undo/redos to the last snapshoted state. returns the position where diff --git a/vis.c b/vis.c @@ -983,7 +983,7 @@ static bool cmd_read(const char *argv[]) { if (data == MAP_FAILED) goto err; - text_insert_raw(vis->win->text, pos, data, info.st_size); + text_insert(vis->win->text, pos, data, info.st_size); pos += info.st_size; err: if (fd > 2) diff --git a/window.c b/window.c @@ -692,7 +692,7 @@ size_t window_backspace_key(Win *win) { size_t window_insert_key(Win *win, const char *c, size_t len) { size_t pos = win->cursor.pos; - text_insert_raw(win->text, pos, c, len); + text_insert(win->text, pos, c, len); if (win->cursor.line == win->bottomline && memchr(c, '\n', len)) window_scroll_lines_down(win, 1); else @@ -711,7 +711,7 @@ size_t window_replace_key(Win *win, const char *c, size_t len) { size_t oldlen = line->cells[cursor->col].len; text_delete(win->text, pos, oldlen); } - text_insert_raw(win->text, pos, c, len); + text_insert(win->text, pos, c, len); if (cursor->line == win->bottomline && memchr(c, '\n', len)) window_scroll_lines_down(win, 1); else