diff options
| -rw-r--r-- | config.def.h | 4 | ||||
| -rw-r--r-- | vis.c | 41 |
2 files changed, 45 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 1024b3f..09ba706 100644 --- a/config.def.h +++ b/config.def.h @@ -67,6 +67,8 @@ static Command cmds[] = { { { "wq", }, cmd_wq, CMD_OPT_FORCE }, { { "write", "w" }, cmd_write, CMD_OPT_FORCE }, { { "xit", }, cmd_xit, CMD_OPT_FORCE }, + { { "earlier" }, cmd_earlier, CMD_OPT_NONE }, + { { "later" }, cmd_later, CMD_OPT_NONE }, { { "!", }, cmd_filter, CMD_OPT_NONE }, { /* array terminator */ }, }; @@ -407,6 +409,8 @@ static KeyBinding vis_mode_normal[] = { { { NONE('X') }, delete, { .i = MOVE_CHAR_PREV } }, { { NONE('u') }, undo, { NULL } }, { { CONTROL('R') }, redo, { NULL } }, + { { NONE('g'), NONE('+') }, later, { NULL } }, + { { NONE('g'), NONE('-') }, earlier, { NULL } }, { { CONTROL('L') }, call, { .f = editor_draw } }, { { NONE(':') }, prompt_cmd, { .s = "" } }, { { NONE('Z'), NONE('Z') }, cmd, { .s = "wq" } }, @@ -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; |
