aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c13
-rw-r--r--vis.c9
-rw-r--r--vis.h3
3 files changed, 11 insertions, 14 deletions
diff --git a/main.c b/main.c
index 40de71b..6a2e593 100644
--- a/main.c
+++ b/main.c
@@ -45,9 +45,6 @@ static const char *repeat(Vis*, const char *keys, const Arg *arg);
static const char *replace(Vis*, const char *keys, const Arg *arg);
/* create a new cursor on the previous (arg->i < 0) or next (arg->i > 0) line */
static const char *cursors_new(Vis*, const char *keys, const Arg *arg);
-/* create new cursors in visual mode either at the start (arg-i < 0)
- * or end (arg->i > 0) of the selected lines */
-static const char *cursors_split(Vis*, const char *keys, const Arg *arg);
/* try to align all cursors on the same column */
static const char *cursors_align(Vis*, const char *keys, const Arg *arg);
/* remove all but the primary cursor and their selections */
@@ -860,12 +857,12 @@ static KeyAction vis_action[] = {
[VIS_ACTION_CURSORS_NEW_LINES_BEGIN] = {
"cursors-new-lines-begin",
"Create a new cursor at the start of every line covered by selection",
- cursors_split, { .i = -1 }
+ operator, { .i = OP_CURSOR_SOL }
},
[VIS_ACTION_CURSORS_NEW_LINES_END] = {
"cursors-new-lines-end",
"Create a new cursor at the end of every line covered by selection",
- cursors_split, { .i = +1 }
+ operator, { .i = OP_CURSOR_EOL }
},
[VIS_ACTION_CURSORS_NEW_MATCH_NEXT] = {
"cursors-new-match-next",
@@ -1099,12 +1096,6 @@ static const char *cursors_new(Vis *vis, const char *keys, const Arg *arg) {
return keys;
}
-static const char *cursors_split(Vis *vis, const char *keys, const Arg *arg) {
- vis->action.arg = *arg;
- vis_operator(vis, OP_CURSOR);
- return keys;
-}
-
static const char *cursors_align(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis->win->view;
Text *txt = vis->win->file->text;
diff --git a/vis.c b/vis.c
index 134b332..8265182 100644
--- a/vis.c
+++ b/vis.c
@@ -576,7 +576,7 @@ static Operator ops[] = {
[OP_JOIN] = { op_join },
[OP_REPEAT_INSERT] = { op_repeat_insert },
[OP_REPEAT_REPLACE] = { op_repeat_replace },
- [OP_CURSOR] = { op_cursor },
+ [OP_CURSOR_SOL] = { op_cursor },
};
/** movements which can be used besides the one in text-motions.h and view.h */
@@ -1170,7 +1170,7 @@ static size_t op_cursor(Vis *vis, Text *txt, OperatorContext *c) {
Cursor *cursor = view_cursors_new(view);
if (cursor) {
size_t pos;
- if (c->arg->i > 0)
+ if (c->arg->i == OP_CURSOR_EOL)
pos = text_line_finish(txt, line);
else
pos = text_line_start(txt, line);
@@ -2808,6 +2808,11 @@ bool vis_operator(Vis *vis, enum VisOperator id) {
vis->action.arg.i = id;
id = OP_CASE_SWAP;
break;
+ case OP_CURSOR_SOL:
+ case OP_CURSOR_EOL:
+ vis->action.arg.i = id;
+ id = OP_CURSOR_SOL;
+ break;
default:
break;
}
diff --git a/vis.h b/vis.h
index e1361d6..d6e5546 100644
--- a/vis.h
+++ b/vis.h
@@ -138,11 +138,12 @@ enum VisOperator {
OP_JOIN,
OP_REPEAT_INSERT,
OP_REPEAT_REPLACE,
- OP_CURSOR,
+ OP_CURSOR_SOL,
OP_CASE_SWAP,
/* pseudo operators: keep them at the end to save space in array definition */
OP_CASE_LOWER,
OP_CASE_UPPER,
+ OP_CURSOR_EOL,
};
/* TODO: overhaul repeatable infrastructure: