diff options
| author | Ryan Chipman <rchipman@mit.edu> | 2015-06-23 14:23:51 -0400 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-06-27 10:11:12 +0200 |
| commit | 807f4ea3e29030ed6379e5c866974d57458c2e42 (patch) | |
| tree | 7e4f40b259706852bb474a551a5bff26d2d7d81c /vis.c | |
| parent | 404cc487a8f817fb3b5da1366aa4b78e05fab3ae (diff) | |
| download | vis-807f4ea3e29030ed6379e5c866974d57458c2e42.tar.gz vis-807f4ea3e29030ed6379e5c866974d57458c2e42.tar.xz | |
Hook up :-commands & keybindings for earlier/later
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -341,6 +341,9 @@ static void mark_line(const Arg *arg); /* {un,re}do last action, redraw window */ static void undo(const Arg *arg); static void redo(const Arg *arg); +/* earlier, later action chronologically, redraw window */ +static void earlier(const Arg *arg); +static void later(const Arg *arg); /* either part of multiplier or a movement to begin of line */ static void zero(const Arg *arg); /* hange/delete from the current cursor position to the end of @@ -416,6 +419,10 @@ static bool cmd_write(Filerange*, enum CmdOpt, const char *argv[]); static bool cmd_saveas(Filerange*, enum CmdOpt, const char *argv[]); /* filter range through external program argv[1] */ static bool cmd_filter(Filerange*, enum CmdOpt, const char *argv[]); +/* switch to the previous saved state of the text, chronologically */ +static bool cmd_earlier(Filerange*, enum CmdOpt, const char *argv[]); +/* switch to the next saved state of the text, chronologically */ +static bool cmd_later(Filerange*, enum CmdOpt, const char *argv[]); static void action_reset(Action *a); static void switchmode_to(Mode *new_mode); @@ -947,6 +954,24 @@ static void redo(const Arg *arg) { } } +static void earlier(const Arg *arg) { + size_t pos = text_earlier(vis->win->file->text); + if (pos != EPOS) { + view_cursor_to(vis->win->view, pos); + /* redraw all windows in case some display the same file */ + editor_draw(vis); + } +} + +static void later(const Arg *arg) { + size_t pos = text_later(vis->win->file->text); + if (pos != EPOS) { + view_cursor_to(vis->win->view, pos); + /* redraw all windows in case some display the same file */ + editor_draw(vis); + } +} + static void zero(const Arg *arg) { if (vis->action.count == 0) movement(&(const Arg){ .i = MOVE_LINE_BEGIN }); @@ -1854,6 +1879,22 @@ static bool cmd_filter(Filerange *range, enum CmdOpt opt, const char *argv[]) { return status == 0; } +static bool cmd_earlier(Filerange *range, enum CmdOpt opt, const char *argv[]) { + if (argv[1]) + return false; + //TODO eventually support time arguments + text_earlier(vis->win->file->text); + return true; +} + +static bool cmd_later(Filerange *range, enum CmdOpt opt, const char *argv[]) { + if (argv[1]) + return false; + //TODO eventually support time arguments + text_later(vis->win->file->text); + return true; +} + static Filepos parse_pos(char **cmd) { size_t pos = EPOS; View *view = vis->win->view; |
