From d3b3e218edcaa950477645a9add92c83cd0543b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 6 Jan 2015 21:28:39 +0100 Subject: Rudimentary change list (accessible via g; and g,) --- editor.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'editor.c') diff --git a/editor.c b/editor.c index ef59242..e472351 100644 --- a/editor.c +++ b/editor.c @@ -172,6 +172,34 @@ void editor_window_jumplist_invalidate(EditorWin *win) { ringbuf_invalidate(win->jumplist); } +size_t editor_window_changelist_prev(EditorWin *win) { + size_t pos = window_cursor_get(win->win); + if (pos != win->changelist.pos) + win->changelist.index = 0; + else + win->changelist.index++; + size_t newpos = text_history_get(win->text, win->changelist.index); + if (newpos == EPOS) + win->changelist.index--; + else + win->changelist.pos = newpos; + return win->changelist.pos; +} + +size_t editor_window_changelist_next(EditorWin *win) { + size_t pos = window_cursor_get(win->win); + if (pos != win->changelist.pos) + win->changelist.index = 0; + else if (win->changelist.index > 0) + win->changelist.index--; + size_t newpos = text_history_get(win->text, win->changelist.index); + if (newpos == EPOS) + win->changelist.index++; + else + win->changelist.pos = newpos; + return win->changelist.pos; +} + void editor_resize(Editor *ed, int width, int height) { ed->width = width; ed->height = height; -- cgit v1.2.3