diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-09-15 16:31:31 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-10-05 15:57:14 +0200 |
| commit | d7b3fd62d0be7b860b9213380f303afb29046008 (patch) | |
| tree | 60e8d67e2985ba711877df406b8386ff8554f904 /vis.c | |
| parent | d9bc41389e754389fadca0e2ef2f1a578368fc99 (diff) | |
| download | vis-d7b3fd62d0be7b860b9213380f303afb29046008.tar.gz vis-d7b3fd62d0be7b860b9213380f303afb29046008.tar.xz | |
vis: convert mark handling to new input handling code
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 49 |
1 files changed, 37 insertions, 12 deletions
@@ -725,12 +725,6 @@ static size_t search_backward(Text *txt, size_t pos) { return text_search_backward(txt, pos, vis->search_pattern); } -static const char *mark_set(const char *keys, const Arg *arg) { - size_t pos = view_cursor_get(vis->win->view); - vis->win->file->marks[arg->i] = text_mark_set(vis->win->file->text, pos); - return keys; -} - static size_t mark_goto(File *txt, size_t pos) { return text_mark_get(txt->text, txt->marks[vis->action.mark]); } @@ -1123,17 +1117,48 @@ static const char *reg(const char *keys, const Arg *arg) { return key2register(keys, &vis->action.reg); } +static const char *key2mark(const char *keys, int *mark) { + *mark = -1; + if (!keys[0]) + return NULL; + if (keys[0] >= 'a' && keys[0] <= 'z') + *mark = keys[0] - 'a'; + else if (keys[0] == '<') + *mark = MARK_SELECTION_START; + else if (keys[0] == '>') + *mark = MARK_SELECTION_END; + return keys+1; +} + +static const char *mark_set(const char *keys, const Arg *arg) { + int mark; + keys = key2mark(keys, &mark); + if (mark != -1) { + size_t pos = view_cursor_get(vis->win->view); + vis->win->file->marks[mark] = text_mark_set(vis->win->file->text, pos); + } + return keys; +} + static const char *mark(const char *keys, const Arg *arg) { - vis->action.mark = arg->i; - vis->action.movement = &moves[MOVE_MARK]; - action_do(&vis->action); + int mark; + keys = key2mark(keys, &mark); + if (mark != -1) { + vis->action.mark = mark; + vis->action.movement = &moves[MOVE_MARK]; + action_do(&vis->action); + } return keys; } static const char *mark_line(const char *keys, const Arg *arg) { - vis->action.mark = arg->i; - vis->action.movement = &moves[MOVE_MARK_LINE]; - action_do(&vis->action); + int mark; + keys = key2mark(keys, &mark); + if (mark != -1) { + vis->action.mark = mark; + vis->action.movement = &moves[MOVE_MARK_LINE]; + action_do(&vis->action); + } return keys; } |
