aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-10-21 23:47:58 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-10-22 19:50:24 +0200
commit549fcb4c05b6134ff0fd17ec502e0c23b2827a91 (patch)
tree5ed53dd7605375c3cd79ce21ebe251210b29eb01
parent4509a105bbe97db8b7d2b82b57f4d7413104b5c7 (diff)
downloadvis-549fcb4c05b6134ff0fd17ec502e0c23b2827a91.tar.gz
vis-549fcb4c05b6134ff0fd17ec502e0c23b2827a91.tar.xz
vis: remove yet more global state from motion functions
-rw-r--r--editor.h2
-rw-r--r--vis.c26
2 files changed, 14 insertions, 14 deletions
diff --git a/editor.h b/editor.h
index 6ae2cb2..a9cc4ae 100644
--- a/editor.h
+++ b/editor.h
@@ -82,11 +82,11 @@ typedef struct {
} Operator;
typedef struct {
- size_t (*cmd)(const Arg*); /* a custom movement based on user input from vis.c */
size_t (*cur)(Cursor*); /* a movement based on current window content from view.h */
size_t (*txt)(Text*, size_t pos); /* a movement form text-motions.h */
size_t (*file)(Vis*, File*, size_t pos);
size_t (*vis)(Vis*, Text*, size_t pos);
+ size_t (*view)(Vis*, View*);
enum {
LINEWISE = 1 << 0,
CHARWISE = 1 << 1,
diff --git a/vis.c b/vis.c
index 200554d..9609e4d 100644
--- a/vis.c
+++ b/vis.c
@@ -180,11 +180,11 @@ static size_t line(Vis*, Text *txt, size_t pos);
/* goto to byte action.count on current line */
static size_t column(Vis*, Text *txt, size_t pos);
/* goto the action.count-th line from top of the focused window */
-static size_t view_lines_top(const Arg *arg);
+static size_t view_lines_top(Vis*, View*);
/* goto the start of middle line of the focused window */
-static size_t view_lines_middle(const Arg *arg);
+static size_t view_lines_middle(Vis*, View*);
/* goto the action.count-th line from bottom of the focused window */
-static size_t view_lines_bottom(const Arg *arg);
+static size_t view_lines_bottom(Vis*, View*);
static Movement moves[] = {
[MOVE_LINE_UP] = { .cur = view_line_up, .type = LINEWISE },
@@ -236,9 +236,9 @@ static Movement moves[] = {
[MOVE_SEARCH_WORD_BACKWARD]= { .vis = search_word_backward, .type = JUMP },
[MOVE_SEARCH_FORWARD] = { .vis = search_forward, .type = JUMP },
[MOVE_SEARCH_BACKWARD] = { .vis = search_backward, .type = JUMP },
- [MOVE_WINDOW_LINE_TOP] = { .cmd = view_lines_top, .type = LINEWISE|JUMP|IDEMPOTENT },
- [MOVE_WINDOW_LINE_MIDDLE] = { .cmd = view_lines_middle, .type = LINEWISE|JUMP|IDEMPOTENT },
- [MOVE_WINDOW_LINE_BOTTOM] = { .cmd = view_lines_bottom, .type = LINEWISE|JUMP|IDEMPOTENT },
+ [MOVE_WINDOW_LINE_TOP] = { .view = view_lines_top, .type = LINEWISE|JUMP|IDEMPOTENT },
+ [MOVE_WINDOW_LINE_MIDDLE] = { .view = view_lines_middle, .type = LINEWISE|JUMP|IDEMPOTENT },
+ [MOVE_WINDOW_LINE_BOTTOM] = { .view = view_lines_bottom, .type = LINEWISE|JUMP|IDEMPOTENT },
};
/* these can be passed as int argument to textobj(&(const Arg){ .i = TEXT_OBJ_* }) */
@@ -761,16 +761,16 @@ static size_t column(Vis *vis, Text *txt, size_t pos) {
return text_line_offset(txt, pos, vis->action.count);
}
-static size_t view_lines_top(const Arg *arg) {
- return view_screenline_goto(vis->win->view, vis->action.count);
+static size_t view_lines_top(Vis *vis, View *view) {
+ return view_screenline_goto(view, vis->action.count);
}
-static size_t view_lines_middle(const Arg *arg) {
- int h = view_height_get(vis->win->view);
- return view_screenline_goto(vis->win->view, h/2);
+static size_t view_lines_middle(Vis *vis, View *view) {
+ int h = view_height_get(view);
+ return view_screenline_goto(view, h/2);
}
-static size_t view_lines_bottom(const Arg *arg) {
+static size_t view_lines_bottom(Vis *vis, View *view) {
int h = view_height_get(vis->win->view);
return view_screenline_goto(vis->win->view, h - vis->action.count);
}
@@ -1488,7 +1488,7 @@ static void action_do(Action *a) {
else if (a->movement->vis)
pos = a->movement->vis(vis, txt, pos);
else
- pos = a->movement->cmd(&a->arg);
+ pos = a->movement->view(vis, view);
if (pos == EPOS || a->movement->type & IDEMPOTENT)
break;
}