diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-04 22:22:39 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-04 22:22:39 +0200 |
| commit | 33812921a2294637e4635d5b8426fc47f69a05a5 (patch) | |
| tree | fea0b77a032b80b0211fb9a7110ee01ef2aa3955 /config.def.h | |
| parent | 3bfd0792b7116eacd5f9c46070b6fee236d4b956 (diff) | |
| download | vis-33812921a2294637e4635d5b8426fc47f69a05a5.tar.gz vis-33812921a2294637e4635d5b8426fc47f69a05a5.tar.xz | |
Implement movement to a given line
Diffstat (limited to 'config.def.h')
| -rw-r--r-- | config.def.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h index 190b1b4..1a5c3e3 100644 --- a/config.def.h +++ b/config.def.h @@ -92,6 +92,14 @@ static size_t till_left(const Arg *arg) { return text_char_next(vis->win->text, to_left(arg)); } +static size_t line(const Arg *arg) { + if (action.count == 0) + return text_size(vis->win->text); + size_t pos = text_pos_by_lineno(vis->win->text, action.count); + action.count = 0; + return pos; +} + static Operator ops[] = { [OP_DELETE] = { op_delete, false }, [OP_CHANGE] = { op_change, false }, @@ -106,6 +114,7 @@ enum { MOVE_LINE_START, MOVE_LINE_FINISH, MOVE_LINE_END, + MOVE_LINE, MOVE_CHAR_PREV, MOVE_CHAR_NEXT, MOVE_WORD_START_PREV, @@ -134,6 +143,7 @@ static Movement moves[] = { [MOVE_LINE_START] = { .txt = text_line_start, .type = LINEWISE }, [MOVE_LINE_FINISH] = { .txt = text_line_finish, .type = LINEWISE }, [MOVE_LINE_END] = { .txt = text_line_end, .type = LINEWISE }, + [MOVE_LINE] = { .cmd = line, .type = LINEWISE }, [MOVE_CHAR_PREV] = { .win = window_char_prev }, [MOVE_CHAR_NEXT] = { .win = window_char_next }, [MOVE_WORD_START_PREV] = { .txt = text_word_start_prev, .type = CHARWISE }, @@ -454,7 +464,7 @@ static KeyBinding vis_movements[] = { { { NONE('(') }, movement, { .i = MOVE_SENTENCE_PREV } }, { { NONE(')') }, movement, { .i = MOVE_SENTENCE_NEXT } }, { { NONE('g'), NONE('g') }, movement, { .i = MOVE_FILE_BEGIN } }, - { { NONE('G') }, movement, { .i = MOVE_FILE_END } }, + { { NONE('G') }, movement, { .i = MOVE_LINE } }, { { NONE('f') }, movement_key, { .i = MOVE_RIGHT_TO } }, { { NONE('F') }, movement_key, { .i = MOVE_LEFT_TO } }, { { NONE('t') }, movement_key, { .i = MOVE_RIGHT_TILL } }, |
