aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h30
-rw-r--r--editor.h8
-rw-r--r--vis.c8
3 files changed, 23 insertions, 23 deletions
diff --git a/config.def.h b/config.def.h
index ed395bc..4a79f98 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1144,15 +1144,15 @@ static KeyBinding vis_operators[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_operator_enter(Mode *old) {
+static void vis_mode_operator_enter(Vis *vis, Mode *old) {
vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_OPERATOR_OPTION];
}
-static void vis_mode_operator_leave(Mode *new) {
+static void vis_mode_operator_leave(Vis *vis, Mode *new) {
vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE];
}
-static void vis_mode_operator_input(const char *str, size_t len) {
+static void vis_mode_operator_input(Vis *vis, const char *str, size_t len) {
/* invalid operator */
action_reset(&vis->action);
switchmode_to(vis->mode_prev);
@@ -1254,7 +1254,7 @@ static KeyBinding vis_mode_visual[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_visual_enter(Mode *old) {
+static void vis_mode_visual_enter(Vis *vis, Mode *old) {
if (!old->visual) {
for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c))
view_cursors_selection_start(c);
@@ -1262,7 +1262,7 @@ static void vis_mode_visual_enter(Mode *old) {
}
}
-static void vis_mode_visual_leave(Mode *new) {
+static void vis_mode_visual_leave(Vis *vis, Mode *new) {
if (!new->visual) {
view_selections_clear(vis->win->view);
vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE];
@@ -1275,7 +1275,7 @@ static KeyBinding vis_mode_visual_line[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_visual_line_enter(Mode *old) {
+static void vis_mode_visual_line_enter(Vis *vis, Mode *old) {
if (!old->visual) {
for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c))
view_cursors_selection_start(c);
@@ -1284,7 +1284,7 @@ static void vis_mode_visual_line_enter(Mode *old) {
movement(NULL, &(const Arg){ .i = MOVE_LINE_END });
}
-static void vis_mode_visual_line_leave(Mode *new) {
+static void vis_mode_visual_line_leave(Vis *vis, Mode *new) {
if (!new->visual) {
view_selections_clear(vis->win->view);
vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE];
@@ -1313,16 +1313,16 @@ static KeyBinding vis_mode_prompt[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_prompt_input(const char *str, size_t len) {
+static void vis_mode_prompt_input(Vis *vis, const char *str, size_t len) {
editor_insert_key(vis, str, len);
}
-static void vis_mode_prompt_enter(Mode *old) {
+static void vis_mode_prompt_enter(Vis *vis, Mode *old) {
if (old->isuser && old != &vis_modes[VIS_MODE_PROMPT])
vis->mode_before_prompt = old;
}
-static void vis_mode_prompt_leave(Mode *new) {
+static void vis_mode_prompt_leave(Vis *vis, Mode *new) {
if (new->isuser)
editor_prompt_hide(vis);
}
@@ -1345,16 +1345,16 @@ static KeyBinding vis_mode_insert[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_insert_leave(Mode *old) {
+static void vis_mode_insert_leave(Vis *vis, Mode *old) {
/* make sure we can recover the current state after an editing operation */
text_snapshot(vis->win->file->text);
}
-static void vis_mode_insert_idle(void) {
+static void vis_mode_insert_idle(Vis *vis) {
text_snapshot(vis->win->file->text);
}
-static void vis_mode_insert_input(const char *str, size_t len) {
+static void vis_mode_insert_input(Vis *vis, const char *str, size_t len) {
static size_t oldpos = EPOS;
size_t pos = view_cursor_get(vis->win->view);
if (pos != oldpos)
@@ -1370,12 +1370,12 @@ static KeyBinding vis_mode_replace[] = {
{ /* empty last element, array terminator */ },
};
-static void vis_mode_replace_leave(Mode *old) {
+static void vis_mode_replace_leave(Vis *vis, Mode *old) {
/* make sure we can recover the current state after an editing operation */
text_snapshot(vis->win->file->text);
}
-static void vis_mode_replace_input(const char *str, size_t len) {
+static void vis_mode_replace_input(Vis *vis, const char *str, size_t len) {
static size_t oldpos = EPOS;
size_t pos = view_cursor_get(vis->win->view);
if (pos != oldpos)
diff --git a/editor.h b/editor.h
index 26f07e8..655ef07 100644
--- a/editor.h
+++ b/editor.h
@@ -53,10 +53,10 @@ struct Mode {
const char *status; /* name displayed in the window status bar */
const char *help; /* short description used by :help */
bool isuser; /* whether this is a user or internal mode */
- void (*enter)(Mode *old); /* called right before the mode becomes active */
- void (*leave)(Mode *new); /* called right before the mode becomes inactive */
- void (*input)(const char*, size_t); /* called whenever a key is not found in this mode and all its parent modes */
- void (*idle)(void); /* called whenever a certain idle time i.e. without any user input elapsed */
+ void (*enter)(Vis*, Mode *old); /* called right before the mode becomes active */
+ void (*leave)(Vis*, Mode *new); /* called right before the mode becomes inactive */
+ void (*input)(Vis*, const char*, size_t); /* called whenever a key is not found in this mode and all its parent modes */
+ void (*idle)(Vis*); /* called whenever a certain idle time i.e. without any user input elapsed */
time_t idle_timeout; /* idle time in seconds after which the registered function will be called */
bool visual; /* whether text selection is possible in this mode */
};
diff --git a/vis.c b/vis.c
index c3d03a8..22eec74 100644
--- a/vis.c
+++ b/vis.c
@@ -1587,12 +1587,12 @@ static void switchmode_to(Mode *new_mode) {
if (vis->mode == new_mode)
return;
if (vis->mode->leave)
- vis->mode->leave(new_mode);
+ vis->mode->leave(vis, new_mode);
if (vis->mode->isuser)
vis->mode_prev = vis->mode;
vis->mode = new_mode;
if (new_mode->enter)
- new_mode->enter(vis->mode_prev);
+ new_mode->enter(vis, vis->mode_prev);
vis->win->ui->draw_status(vis->win->ui);
}
@@ -2699,7 +2699,7 @@ static const char *keypress(const char *input) {
}
}
if (!action && vis->mode->input)
- vis->mode->input(start, end - start);
+ vis->mode->input(vis, start, end - start);
start = cur = end;
}
}
@@ -2779,7 +2779,7 @@ static void mainloop() {
if (!FD_ISSET(STDIN_FILENO, &fds)) {
if (vis->mode->idle)
- vis->mode->idle();
+ vis->mode->idle(vis);
timeout = NULL;
continue;
}