diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-13 18:39:01 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-13 18:39:01 +0200 |
| commit | 25ba078b62ada6276217ca35b12b8dabf3a2b439 (patch) | |
| tree | b5a25e3a1882c5eb36c7b2330fee27d7cd0847a9 /vis.c | |
| parent | 1ae7600bdc302da4647d5910bea8f2437646fb70 (diff) | |
| download | vis-25ba078b62ada6276217ca35b12b8dabf3a2b439.tar.gz vis-25ba078b62ada6276217ca35b12b8dabf3a2b439.tar.xz | |
Add movements 'H', 'M', 'L'
H moves to the n-th window line from top
M moves to the middle window line
L moves to the n-th window line from bottom
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -196,6 +196,9 @@ enum { MOVE_MARK_LINE, MOVE_SEARCH_FORWARD, MOVE_SEARCH_BACKWARD, + MOVE_WINDOW_LINE_TOP, + MOVE_WINDOW_LINE_MIDDLE, + MOVE_WINDOW_LINE_BOTTOM, }; /** movements which can be used besides the one in text-motions.h and window.h */ @@ -218,6 +221,12 @@ static size_t till_left(const Arg *arg); static size_t line(const Arg *arg); /* goto to byte action.count on current line */ static size_t column(const Arg *arg); +/* goto the action.count-th line from top of the focused window */ +static size_t window_line_top(const Arg *arg); +/* goto the start of middle line of the focused window */ +static size_t window_line_middle(const Arg *arg); +/* goto the action.count-th line from bottom of the focused window */ +static size_t window_line_bottom(const Arg *arg); static Movement moves[] = { [MOVE_LINE_UP] = { .win = window_line_up }, @@ -251,6 +260,9 @@ static Movement moves[] = { [MOVE_MARK_LINE] = { .cmd = mark_line_goto, .type = LINEWISE }, [MOVE_SEARCH_FORWARD] = { .cmd = search_forward, .type = LINEWISE }, [MOVE_SEARCH_BACKWARD] = { .cmd = search_backward, .type = LINEWISE }, + [MOVE_WINDOW_LINE_TOP] = { .cmd = window_line_top, .type = LINEWISE }, + [MOVE_WINDOW_LINE_MIDDLE] = { .cmd = window_line_middle,.type = LINEWISE }, + [MOVE_WINDOW_LINE_BOTTOM] = { .cmd = window_line_bottom,.type = LINEWISE }, }; /* these can be passed as int argument to textobj(&(const Arg){ .i = TEXT_OBJ_* }) */ @@ -504,6 +516,18 @@ static size_t column(const Arg *arg) { return it.pos; } +static size_t window_line_top(const Arg *arg) { + return window_line_goto(vis->win->win, action.count); +} + +static size_t window_line_middle(const Arg *arg) { + return window_line_goto(vis->win->win, vis->win->height / 2); +} + +static size_t window_line_bottom(const Arg *arg) { + return window_line_goto(vis->win->win, vis->win->height - action.count); +} + /** key bindings functions of type: void (*func)(const Arg*) */ static void repeat(const Arg *arg) { |
