aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-30 19:57:35 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-30 19:57:35 +0200
commit14ab569ac03d5fd1e641948dbfc3decd5b74421c (patch)
treedec101004d1650ef85a484d9985cdcbb61e59d2a /vis.c
parentbd3176f1881402e5c50d060eb8d1f9317e45c472 (diff)
downloadvis-14ab569ac03d5fd1e641948dbfc3decd5b74421c.tar.gz
vis-14ab569ac03d5fd1e641948dbfc3decd5b74421c.tar.xz
Clean up visual mode handling
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/vis.c b/vis.c
index 7b93eae..b0733f1 100644
--- a/vis.c
+++ b/vis.c
@@ -76,6 +76,7 @@ struct Mode {
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 */
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 */
};
typedef struct {
@@ -809,7 +810,7 @@ static void linewise(const Arg *arg) {
static void operator(const Arg *arg) {
Operator *op = &ops[arg->i];
- if (mode == &vis_modes[VIS_MODE_VISUAL] || mode == &vis_modes[VIS_MODE_VISUAL_LINE]) {
+ if (mode->visual) {
action.op = op;
action_do(&action);
return;
@@ -1152,7 +1153,7 @@ static void action_do(Action *a) {
}
}
}
- } else if (mode == &vis_modes[VIS_MODE_VISUAL] || mode == &vis_modes[VIS_MODE_VISUAL_LINE]) {
+ } else if (mode->visual) {
c.range = window_selection_get(win);
if (!text_range_valid(&c.range))
c.range.start = c.range.end = pos;
@@ -1162,7 +1163,7 @@ static void action_do(Action *a) {
a->op->func(&c);
if (mode == &vis_modes[VIS_MODE_OPERATOR])
switchmode_to(mode_prev);
- else if (mode == &vis_modes[VIS_MODE_VISUAL] || mode == &vis_modes[VIS_MODE_VISUAL_LINE])
+ else if (mode->visual)
switchmode(&(const Arg){ .i = VIS_MODE_NORMAL });
text_snapshot(txt);
}