aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-07-08 09:52:56 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-07-08 09:52:56 +0200
commitad10da5cc094204eb6f319841ab73246b689abb4 (patch)
tree9493aadbf020088befc922d61187c80c72f0f2dc
parent5c600e15c1c1ab64f385de918c93d2bdb23955d5 (diff)
downloadvis-ad10da5cc094204eb6f319841ab73246b689abb4.tar.gz
vis-ad10da5cc094204eb6f319841ab73246b689abb4.tar.xz
vis: cleanup marks implementation
We now use ' to refer to marks. Mark a is set using 'am and restored using 'aM while this is slightly harder to type than ma and 'a it is consistent with register usage for yank/put and allows a default mark to be used which is handy for quick selection manipulation primitives.
-rw-r--r--Makefile2
-rw-r--r--config.def.h10
-rw-r--r--main.c96
-rw-r--r--vis-lua.c4
-rw-r--r--vis-marks.c103
-rw-r--r--vis-motions.c31
-rw-r--r--vis-registers.c53
-rw-r--r--vis.c17
-rw-r--r--vis.h53
9 files changed, 161 insertions, 208 deletions
diff --git a/Makefile b/Makefile
index f08871a..350d20c 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ REGEX_SRC ?= text-regex.c
SRC = array.c buffer.c libutf.c main.c map.c ring-buffer.c \
sam.c text.c text-motions.c text-objects.c text-util.c \
ui-terminal.c view.c vis.c vis-lua.c vis-modes.c vis-motions.c \
- vis-operators.c vis-registers.c vis-prompt.c vis-text-objects.c $(REGEX_SRC)
+ vis-operators.c vis-registers.c vis-marks.c vis-prompt.c vis-text-objects.c $(REGEX_SRC)
ELF = vis vis-menu vis-digraph
EXECUTABLES = $(ELF) vis-clipboard vis-complete vis-open
diff --git a/config.def.h b/config.def.h
index e106b52..d5fef01 100644
--- a/config.def.h
+++ b/config.def.h
@@ -39,8 +39,6 @@ static const KeyBinding bindings_motions[] = {
{ "*", ACTION(CURSOR_SEARCH_WORD_FORWARD) },
{ ")", ACTION(CURSOR_SENTENCE_NEXT) },
{ "(", ACTION(CURSOR_SENTENCE_PREV) },
- { "`", ACTION(MARK_GOTO) },
- { "'", ACTION(MARK_GOTO_LINE) },
{ "?", ACTION(PROMPT_SEARCH_BACKWARD) },
{ "/", ACTION(PROMPT_SEARCH_FORWARD) },
{ ";", ACTION(TOTILL_REPEAT) },
@@ -141,8 +139,8 @@ static const KeyBinding bindings_textobjects[] = {
};
static const KeyBinding bindings_selections[] = {
- { "s", ACTION(SELECTIONS_SAVE) },
- { "S", ACTION(SELECTIONS_RESTORE) },
+ { "m", ACTION(SELECTIONS_SAVE) },
+ { "M", ACTION(SELECTIONS_RESTORE) },
{ "|", ACTION(SELECTIONS_UNION) },
{ "&", ACTION(SELECTIONS_INTERSECT) },
{ "!", ACTION(SELECTIONS_COMPLEMENT) },
@@ -177,6 +175,7 @@ static const KeyBinding bindings_operators[] = {
{ "<", ACTION(OPERATOR_SHIFT_LEFT) },
{ ">", ACTION(OPERATOR_SHIFT_RIGHT) },
{ "\"", ACTION(REGISTER) },
+ { "'", ACTION(MARK) },
{ "c", ACTION(OPERATOR_CHANGE) },
{ "d", ACTION(OPERATOR_DELETE) },
{ "g~", ACTION(OPERATOR_CASE_SWAP) },
@@ -247,12 +246,11 @@ static const KeyBinding bindings_normal[] = {
{ "g+", ACTION(LATER) },
{ "gn", ALIAS("vgn") },
{ "gN", ALIAS("vgN") },
- { "gv", ALIAS("\"^Sv") },
+ { "gv", ALIAS("'^Mv") },
{ "I", ACTION(INSERT_LINE_START) },
{ "i", ACTION(MODE_INSERT) },
{ "J", ACTION(JOIN_LINES) },
{ "gJ", ACTION(JOIN_LINES_TRIM) },
- { "m", ACTION(MARK_SET) },
{ "<M-C-j>", ACTION(CURSORS_NEW_LINE_BELOW_LAST) },
{ "<M-C-k>", ACTION(CURSORS_NEW_LINE_ABOVE_FIRST) },
{ "O", ACTION(OPEN_LINE_ABOVE) },
diff --git a/main.c b/main.c
index 3dd9d81..0ae5941 100644
--- a/main.c
+++ b/main.c
@@ -38,8 +38,6 @@ static const char *switchmode(Vis*, const char *keys, const Arg *arg);
static const char *insertmode(Vis*, const char *keys, const Arg *arg);
/* switch to replace mode after performing movement indicated by arg->i */
static const char *replacemode(Vis*, const char *keys, const Arg *arg);
-/* set mark indicated by keys to current cursor position */
-static const char *mark_set(Vis*, const char *keys, const Arg *arg);
/* add a new line either before or after the one where the cursor currently is */
static const char *openline(Vis*, const char *keys, const Arg *arg);
/* join lines from current cursor position to movement indicated by arg */
@@ -116,8 +114,8 @@ static const char *textobj(Vis*, const char *keys, const Arg *arg);
static const char *selection_end(Vis*, const char *keys, const Arg *arg);
/* use register indicated by keys for the current operator */
static const char *reg(Vis*, const char *keys, const Arg *arg);
-/* perform arg->i motion with a mark indicated by keys as argument */
-static const char *mark_motion(Vis*, const char *keys, const Arg *arg);
+/* use mark indicated by keys for the current action */
+static const char *mark(Vis*, const char *keys, const Arg *arg);
/* {un,re}do last action, redraw window */
static const char *undo(Vis*, const char *keys, const Arg *arg);
static const char *redo(Vis*, const char *keys, const Arg *arg);
@@ -222,9 +220,7 @@ enum {
VIS_ACTION_LATER,
VIS_ACTION_MACRO_RECORD,
VIS_ACTION_MACRO_REPLAY,
- VIS_ACTION_MARK_SET,
- VIS_ACTION_MARK_GOTO,
- VIS_ACTION_MARK_GOTO_LINE,
+ VIS_ACTION_MARK,
VIS_ACTION_REDRAW,
VIS_ACTION_REPLACE_CHAR,
VIS_ACTION_TOTILL_REPEAT,
@@ -705,20 +701,10 @@ static const KeyAction vis_action[] = {
VIS_HELP("Replay macro, execute the content of the given register")
macro_replay,
},
- [VIS_ACTION_MARK_SET] = {
- "vis-mark-set",
- VIS_HELP("Set given mark at current cursor position")
- mark_set,
- },
- [VIS_ACTION_MARK_GOTO] = {
- "vis-mark-goto",
- VIS_HELP("Goto the position of the given mark")
- mark_motion, { .i = VIS_MOVE_MARK }
- },
- [VIS_ACTION_MARK_GOTO_LINE] = {
- "vis-mark-goto-line",
- VIS_HELP("Goto first non-blank character of the line containing the given mark")
- mark_motion, { .i = VIS_MOVE_MARK_LINE }
+ [VIS_ACTION_MARK] = {
+ "vis-mark",
+ VIS_HELP("Use given mark for next action")
+ mark,
},
[VIS_ACTION_REDRAW] = {
"vis-redraw",
@@ -1666,9 +1652,9 @@ static const char *selections_trim(Vis *vis, const char *keys, const Arg *arg) {
static const char *selections_save(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
- enum VisRegister reg = vis_register_used(vis);
+ enum VisMark mark = vis_mark_used(vis);
Array sel = view_selections_get_all(view);
- vis_register_selections_set(vis, reg, &sel);
+ vis_mark_set(vis, mark, &sel);
array_release(&sel);
vis_cancel(vis);
return keys;
@@ -1677,44 +1663,19 @@ static const char *selections_save(Vis *vis, const char *keys, const Arg *arg) {
static const char *selections_restore(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
bool anchored = view_selections_anchored(view_selections_primary_get(view));
- enum VisRegister reg = vis_register_used(vis);
- Array sel = vis_register_selections_get(vis, reg);
+ enum VisMark mark = vis_mark_used(vis);
+ Array sel = vis_mark_get(vis, mark);
view_selections_set_all(view, &sel, anchored);
array_release(&sel);
vis_cancel(vis);
return keys;
}
-static int ranges_comparator(const void *a, const void *b) {
- const Filerange *r1 = a, *r2 = b;
- if (!text_range_valid(r1))
- return text_range_valid(r2) ? 1 : 0;
- if (!text_range_valid(r2))
- return -1;
- return (r1->start < r2->start || (r1->start == r2->start && r1->end < r2->end)) ? -1 : 1;
-}
-
-static void normalize(Array *a) {
- array_sort(a, ranges_comparator);
- Filerange *prev = NULL, *r = array_get(a, 0);
- for (size_t i = 0; r; r = array_get(a, i)) {
- if (text_range_size(r) == 0) {
- array_remove(a, i);
- } else if (prev && text_range_overlap(prev, r)) {
- *prev = text_range_union(prev, r);
- array_remove(a, i);
- } else {
- prev = r;
- i++;
- }
- }
-}
-
static const char *selections_union(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
bool anchored = view_selections_anchored(view_selections_primary_get(view));
- enum VisRegister reg = vis_register_used(vis);
- Array a = vis_register_selections_get(vis, reg);
+ enum VisMark mark = vis_mark_used(vis);
+ Array a = vis_mark_get(vis, mark);
Array b = view_selections_get_all(view);
Array sel;
array_init_from(&sel, &a);
@@ -1780,8 +1741,8 @@ static void intersect(Array *ret, Array *a, Array *b) {
static const char *selections_intersect(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
bool anchored = view_selections_anchored(view_selections_primary_get(view));
- enum VisRegister reg = vis_register_used(vis);
- Array a = vis_register_selections_get(vis, reg);
+ enum VisMark mark = vis_mark_used(vis);
+ Array a = vis_mark_get(vis, mark);
Array b = view_selections_get_all(view);
Array sel;
array_init_from(&sel, &a);
@@ -1833,9 +1794,9 @@ static const char *selections_complement(Vis *vis, const char *keys, const Arg *
static const char *selections_minus(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
bool anchored = view_selections_anchored(view_selections_primary_get(view));
- enum VisRegister reg = vis_register_used(vis);
+ enum VisMark mark = vis_mark_used(vis);
Array a = view_selections_get_all(view);
- Array b = vis_register_selections_get(vis, reg);
+ Array b = vis_mark_get(vis, mark);
Array sel;
array_init_from(&sel, &a);
Array b_complement;
@@ -1912,9 +1873,9 @@ static Filerange combine_rightmost(const Filerange *r1, const Filerange *r2) {
static const char *selections_combine(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
bool anchored = view_selections_anchored(view_selections_primary_get(view));
- enum VisRegister reg = vis_register_used(vis);
+ enum VisMark mark = vis_mark_used(vis);
Array a = view_selections_get_all(view);
- Array b = vis_register_selections_get(vis, reg);
+ Array b = vis_mark_get(vis, mark);
Array sel;
array_init_from(&sel, &a);
@@ -1925,7 +1886,7 @@ static const char *selections_combine(Vis *vis, const char *keys, const Arg *arg
array_add(&sel, &new);
}
- normalize(&sel);
+ vis_mark_normalize(&sel);
view_selections_set_all(view, &sel, anchored);
vis_cancel(vis);
@@ -2037,24 +1998,13 @@ static const char *reg(Vis *vis, const char *keys, const Arg *arg) {
return keys+1;
}
-static const char *mark_set(Vis *vis, const char *keys, const Arg *arg) {
- if (!keys[0])
- return NULL;
- if (keys[1])
- return vis_keys_next(vis, keys);
- View *view = vis_view(vis);
- Array sel = view_selections_get_all(view);
- vis_register_selections_set(vis, vis_mark_from(vis, keys[0]), &sel);
- array_release(&sel);
- return keys+1;
-}
-
-static const char *mark_motion(Vis *vis, const char *keys, const Arg *arg) {
+static const char *mark(Vis *vis, const char *keys, const Arg *arg) {
if (!keys[0])
return NULL;
if (keys[1])
return vis_keys_next(vis, keys);
- vis_motion(vis, arg->i, vis_mark_from(vis, keys[0]));
+ enum VisMark mark = vis_mark_from(vis, keys[0]);
+ vis_mark(vis, mark);
return keys+1;
}
diff --git a/vis-lua.c b/vis-lua.c
index 91ad645..be14b18 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -2256,7 +2256,7 @@ static int file_marks_index(lua_State *L) {
enum VisMark mark = vis_mark_from(vis, symbol[0]);
if (mark == VIS_MARK_INVALID)
goto err;
- Array arr = vis_register_selections_get(vis, mark);
+ Array arr = vis_mark_get(vis, mark);
range = array_get(&arr, 0);
array_release(&arr);
err:
@@ -2279,7 +2279,7 @@ static int file_marks_newindex(lua_State *L) {
array_init_sized(&arr, sizeof(Filerange));
Filerange range = text_range_new(pos, pos);
array_add(&arr, &range);
- vis_register_selections_set(vis, mark, &arr);
+ vis_mark_set(vis, mark, &arr);
array_release(&arr);
}
return 0;
diff --git a/vis-marks.c b/vis-marks.c
new file mode 100644
index 0000000..edf0757
--- /dev/null
+++ b/vis-marks.c
@@ -0,0 +1,103 @@
+#include "vis-core.h"
+
+static int ranges_comparator(const void *a, const void *b) {
+ const Filerange *r1 = a, *r2 = b;
+ if (!text_range_valid(r1))
+ return text_range_valid(r2) ? 1 : 0;
+ if (!text_range_valid(r2))
+ return -1;
+ return (r1->start < r2->start || (r1->start == r2->start && r1->end < r2->end)) ? -1 : 1;
+}
+
+void vis_mark_normalize(Array *a) {
+ array_sort(a, ranges_comparator);
+ Filerange *prev = NULL, *r = array_get(a, 0);
+ for (size_t i = 0; r; r = array_get(a, i)) {
+ if (text_range_size(r) == 0) {
+ array_remove(a, i);
+ } else if (prev && text_range_overlap(prev, r)) {
+ *prev = text_range_union(prev, r);
+ array_remove(a, i);
+ } else {
+ prev = r;
+ i++;
+ }
+ }
+}
+
+void marks_init(Array *arr) {
+ array_init_sized(arr, sizeof(SelectionRegion));
+}
+
+void mark_release(Array *arr) {
+ if (!arr)
+ return;
+ array_release(arr);
+}
+
+
+static Array *mark_from(Vis *vis, enum VisMark id) {
+ if (id == VIS_MARK_SELECTION && vis->win)
+ return &vis->win->saved_selections;
+ File *file = vis->win->file;
+ if (id < LENGTH(file->marks))
+ return &file->marks[id];
+ return NULL;
+}
+
+enum VisMark vis_mark_used(Vis *vis) {
+ return vis->action.mark;
+}
+
+void vis_mark(Vis *vis, enum VisMark mark) {
+ if (mark < LENGTH(vis->win->file->marks))
+ vis->action.mark = mark;
+}
+
+Array vis_mark_get(Vis *vis, enum VisMark id) {
+ Array sel;
+ array_init_sized(&sel, sizeof(Filerange));
+ Array *mark = mark_from(vis, id);
+ if (!mark)
+ return sel;
+ View *view = vis->win->view;
+ size_t len = array_length(mark);
+ array_reserve(&sel, len);
+ for (size_t i = 0; i < len; i++) {
+ SelectionRegion *sr = array_get(mark, i);
+ Filerange r = view_regions_restore(view, sr);
+ if (text_range_valid(&r))
+ array_add(&sel, &r);
+ }
+ vis_mark_normalize(&sel);
+ return sel;
+}
+
+void vis_mark_set(Vis *vis, enum VisMark id, Array *sel) {
+ Array *mark = mark_from(vis, id);
+ if (!mark)
+ return;
+ array_clear(mark);
+ View *view = vis->win->view;
+ for (size_t i = 0, len = array_length(sel); i < len; i++) {
+ SelectionRegion ss;
+ Filerange *r = array_get(sel, i);
+ if (view_regions_save(view, r, &ss))
+ array_add(mark, &ss);
+ }
+}
+
+enum VisMark vis_mark_from(Vis *vis, char mark) {
+ if (mark >= 'a' && mark <= 'z')
+ return VIS_MARK_a + mark - 'a';
+ for (size_t i = 0; i < LENGTH(vis_marks); i++) {
+ if (vis_marks[i].name == mark)
+ return i;
+ }
+ return VIS_MARK_INVALID;
+}
+
+const MarkDef vis_marks[] = {
+ [VIS_MARK_DEFAULT] = { '"', VIS_HELP("Default mark") },
+ [VIS_MARK_SELECTION] = { '^', VIS_HELP("Last selections") },
+};
diff --git a/vis-motions.c b/vis-motions.c
index b07585b..5b55288 100644
--- a/vis-motions.c
+++ b/vis-motions.c
@@ -107,19 +107,6 @@ static size_t longword_next(Vis *vis, Text *txt, size_t pos) {
return common_word_next(vis, txt, pos, VIS_MOVE_LONGWORD_END_NEXT);
}
-static size_t mark_goto(Vis *vis, File *file, Selection *sel) {
- Array *marks = &file->marks[vis->action.mark];
- size_t idx = view_selections_number(sel);
- SelectionRegion *sr = array_get(marks, idx);
- if (!sr)
- return EPOS;
- return text_mark_get(file->text, sr->cursor);
-}
-
-static size_t mark_line_goto(Vis *vis, File *file, Selection *sel) {
- return text_line_start(file->text, mark_goto(vis, file, sel));
-}
-
static size_t to(Vis *vis, Text *txt, size_t pos) {
char c;
if (pos == text_line_end(txt, pos))
@@ -394,16 +381,6 @@ bool vis_motion(Vis *vis, enum VisMotion motion, ...) {
goto err;
}
break;
- case VIS_MOVE_MARK:
- case VIS_MOVE_MARK_LINE:
- {
- int mark = va_arg(ap, int);
- if (VIS_MARK_a <= mark && mark < VIS_MARK_INVALID)
- vis->action.mark = mark;
- else
- goto err;
- break;
- }
default:
break;
}
@@ -605,14 +582,6 @@ const Movement vis_motions[] = {
.vis = till,
.type = INCLUSIVE|COUNT_EXACT,
},
- [VIS_MOVE_MARK] = {
- .file = mark_goto,
- .type = JUMP|IDEMPOTENT,
- },
- [VIS_MOVE_MARK_LINE] = {
- .file = mark_line_goto,
- .type = LINEWISE|JUMP|IDEMPOTENT,
- },
[VIS_MOVE_SEARCH_WORD_FORWARD] = {
.vis = search_word_forward,
.type = JUMP,
diff --git a/vis-registers.c b/vis-registers.c
index 9976b3b..742194b 100644
--- a/vis-registers.c
+++ b/vis-registers.c
@@ -42,16 +42,6 @@ void register_release(Register *reg) {
array_release(&reg->values);
}
-void marks_init(Array *arr) {
- array_init_sized(arr, sizeof(SelectionRegion));
-}
-
-void mark_release(Array *arr) {
- if (!arr)
- return;
- array_release(arr);
-}
-
const char *register_slot_get(Vis *vis, Register *reg, size_t slot, size_t *len) {
if (len)
*len = 0;
@@ -228,15 +218,6 @@ enum VisRegister vis_register_used(Vis *vis) {
return vis->action.reg - vis->registers;
}
-static Array *mark_from(Vis *vis, enum VisMark id) {
- if (id == VIS_MARK_SELECTION && vis->win)
- return &vis->win->saved_selections;
- File *file = vis->win->file;
- if (id < LENGTH(file->marks))
- return &file->marks[id];
- return NULL;
-}
-
static Register *register_from(Vis *vis, enum VisRegister id) {
if (VIS_REG_A <= id && id <= VIS_REG_Z)
id = VIS_REG_a + id - VIS_REG_A;
@@ -264,39 +245,6 @@ const char *vis_register_slot_get(Vis *vis, enum VisRegister id, size_t slot, si
return NULL;
}
-Array vis_register_selections_get(Vis *vis, enum VisRegister id) {
- Array sel;
- array_init_sized(&sel, sizeof(Filerange));
- Array *mark = mark_from(vis, id);
- if (!mark)
- return sel;
- View *view = vis->win->view;
- size_t len = array_length(mark);
- array_reserve(&sel, len);
- for (size_t i = 0; i < len; i++) {
- SelectionRegion *sr = array_get(mark, i);
- Filerange r = view_regions_restore(view, sr);
- if (text_range_valid(&r))
- array_add(&sel, &r);
- }
- //selections_normalize(&sel);
- return sel;
-}
-
-void vis_register_selections_set(Vis *vis, enum VisRegister id, Array *sel) {
- Array *mark = mark_from(vis, id);
- if (!mark)
- return;
- array_clear(mark);
- View *view = vis->win->view;
- for (size_t i = 0, len = array_length(sel); i < len; i++) {
- SelectionRegion ss;
- Filerange *r = array_get(sel, i);
- if (view_regions_save(view, r, &ss))
- array_add(mark, &ss);
- }
-}
-
const RegisterDef vis_registers[] = {
[VIS_REG_DEFAULT] = { '"', VIS_HELP("Unnamed register") },
[VIS_REG_ZERO] = { '0', VIS_HELP("Yank register") },
@@ -317,5 +265,4 @@ const RegisterDef vis_registers[] = {
[VIS_REG_COMMAND] = { ':', VIS_HELP("Last :-command") },
[VIS_REG_SHELL] = { '!', VIS_HELP("Last shell command given to either <, >, |, or !") },
[VIS_REG_NUMBER] = { '#', VIS_HELP("Register number") },
- [VIS_REG_SELECTION] = { '^', VIS_HELP("Last selections") },
};
diff --git a/vis.c b/vis.c
index 5424f40..cc09455 100644
--- a/vis.c
+++ b/vis.c
@@ -28,11 +28,6 @@
#include "vis-core.h"
#include "sam.h"
-const MarkDef vis_marks[] = {
- [VIS_MARK_DEFAULT] = { '"', VIS_HELP("Default mark") },
- [VIS_MARK_SELECTION] = { '^', VIS_HELP("Last selections") },
-};
-
static void macro_replay(Vis *vis, const Macro *macro);
static void macro_replay_internal(Vis *vis, const Macro *macro);
static void vis_keys_push(Vis *vis, const char *input, size_t pos, bool record);
@@ -252,7 +247,7 @@ void window_selection_save(Win *win) {
Vis *vis = win->vis;
View *view = win->view;
Array sel = view_selections_get_all(view);
- vis_register_selections_set(vis, VIS_REG_SELECTION, &sel);
+ vis_mark_set(vis, VIS_MARK_SELECTION, &sel);
array_release(&sel);
}
@@ -1533,16 +1528,6 @@ void vis_repeat(Vis *vis) {
vis_file_snapshot(vis, vis->win->file);
}
-enum VisMark vis_mark_from(Vis *vis, char mark) {
- if (mark >= 'a' && mark <= 'z')
- return VIS_MARK_a + mark - 'a';
- for (size_t i = 0; i < LENGTH(vis_marks); i++) {
- if (vis_marks[i].name == mark)
- return i;
- }
- return VIS_MARK_INVALID;
-}
-
int vis_count_get(Vis *vis) {
return vis->action.count;
}
diff --git a/vis.h b/vis.h
index c53c245..ab81e02 100644
--- a/vis.h
+++ b/vis.h
@@ -501,8 +501,6 @@ enum VisMotion {
VIS_MOVE_RIGHT_TILL,
VIS_MOVE_FILE_BEGIN,
VIS_MOVE_FILE_END,
- VIS_MOVE_MARK,
- VIS_MOVE_MARK_LINE,
VIS_MOVE_SEARCH_WORD_FORWARD,
VIS_MOVE_SEARCH_WORD_BACKWARD,
VIS_MOVE_SEARCH_REPEAT_FORWARD,
@@ -546,10 +544,6 @@ enum VisMotion {
* - ``VIS_MOVE_{LEFT,RIGHT}_{TO,TILL}``
*
* The character to search for as ``const char *``.
- *
- * - `VIS_MOVE_MARK` and `VIS_MOVE_MARK_LINE`
- *
- * A valid ``enum VisMark``.
*/
bool vis_motion(Vis*, enum VisMotion, ...);
@@ -690,12 +684,36 @@ enum VisMark {
/** Translate single character mark name to corresponding constant. */
enum VisMark vis_mark_from(Vis*, char mark);
/**
- * Set a mark.
+ * Specify mark to use.
* @rst
- * .. note:: The same semantics as for `text_mark_set` apply.
+ * .. note:: If none is specified `VIS_MARK_DEFAULT` will be used.
* @endrst
*/
-void vis_mark_set(Vis*, enum VisMark mark, size_t pos);
+void vis_mark(Vis*, enum VisMark);
+enum VisMark vis_mark_used(Vis*);
+/**
+ * Store a set of ``Filerange``s in a mark.
+ *
+ * @param id The register to use.
+ * @param sel The array containing the file ranges.
+ */
+void vis_mark_set(Vis*, enum VisMark id, Array *sel);
+/**
+ * Get an array of file ranges stored in the mark.
+ *
+ * @rst
+ * .. warning:: The caller must eventually free the Array by calling
+ * ``array_release``.
+ * @endrst
+ */
+Array vis_mark_get(Vis*, enum VisMark id);
+/**
+ * Normalize an Array of Fileranges.
+ *
+ * Removes invalid ranges, merges overlapping ones and sorts
+ * according to the start position.
+ */
+void vis_mark_normalize(Array*);
/** @} */
/** Register specifiers. */
@@ -719,7 +737,6 @@ enum VisRegister {
VIS_REG_COMMAND, /* last used :-command ": */
VIS_REG_SHELL, /* last used shell command given to either <, >, |, or ! */
VIS_REG_NUMBER, /* cursor number */
- VIS_REG_SELECTION, /* last used selections */
VIS_REG_a, VIS_REG_b, VIS_REG_c, VIS_REG_d, VIS_REG_e,
VIS_REG_f, VIS_REG_g, VIS_REG_h, VIS_REG_i, VIS_REG_j,
VIS_REG_k, VIS_REG_l, VIS_REG_m, VIS_REG_n, VIS_REG_o,
@@ -758,22 +775,6 @@ const char *vis_register_slot_get(Vis*, enum VisRegister, size_t slot, size_t *l
/** Set register content. */
bool vis_register_put(Vis*, enum VisRegister, const char *data, size_t len);
bool vis_register_slot_put(Vis*, enum VisRegister, size_t slot, const char *data, size_t len);
-/**
- * Store a set of ``Filerange``s in a register.
- *
- * @param id The register to use.
- * @param sel The array containing the file ranges.
- */
-void vis_register_selections_set(Vis*, enum VisRegister id, Array *sel);
-/**
- * Get an array of file ranges stored in the register.
- *
- * @rst
- * .. warning:: The caller must eventually free the Array by calling
- * ``array_release``.
- * @endrst
- */
-Array vis_register_selections_get(Vis*, enum VisRegister id);
/**
* @}