aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-22 06:09:07 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-22 06:09:07 +0200
commit637b1adbdda1af761518b90b52fb6ae7798584bc (patch)
tree01c10bf0b2c573ce65806e80e4a2ddb0daecd66e
parentddd80ea3ca108858ebd053339871c6fa251f9a8d (diff)
downloadvis-637b1adbdda1af761518b90b52fb6ae7798584bc.tar.gz
vis-637b1adbdda1af761518b90b52fb6ae7798584bc.tar.xz
Add support for the '<', '>' marks
-rw-r--r--README8
-rw-r--r--config.def.h4
-rw-r--r--editor.c10
-rw-r--r--editor.h2
-rw-r--r--text.c2
5 files changed, 21 insertions, 5 deletions
diff --git a/README b/README
index 60c68a3..6926c1e 100644
--- a/README
+++ b/README
@@ -389,8 +389,12 @@ and their current support in vis.
Marks
-----
- Only the 26 lower case marks [a-z] are supported. No marks across files
- are supported. Marks are not preserved over editing sessions.
+ [a-z] general purpose marks
+ < start of the last selected visual area in current buffer
+ > end of the last selected visual area in current buffer
+
+ No marks across files are supported. Marks are not preserved over
+ editing sessions.
Registers
---------
diff --git a/config.def.h b/config.def.h
index a774a1d..46ff32b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -281,6 +281,8 @@ static KeyBinding vis_marks[] = {
{ { NONE('`'), NONE('x') }, mark, { .i = MARK_x } },
{ { NONE('`'), NONE('y') }, mark, { .i = MARK_y } },
{ { NONE('`'), NONE('z') }, mark, { .i = MARK_z } },
+ { { NONE('`'), NONE('<') }, mark, { .i = MARK_SELECTION_START } },
+ { { NONE('`'), NONE('>') }, mark, { .i = MARK_SELECTION_END } },
{ /* empty last element, array terminator */ },
};
@@ -311,6 +313,8 @@ static KeyBinding vis_marks_line[] = {
{ { NONE('\''), NONE('x') }, mark_line, { .i = MARK_x } },
{ { NONE('\''), NONE('y') }, mark_line, { .i = MARK_y } },
{ { NONE('\''), NONE('z') }, mark_line, { .i = MARK_z } },
+ { { NONE('\''), NONE('<') }, mark_line, { .i = MARK_SELECTION_START } },
+ { { NONE('\''), NONE('>') }, mark_line, { .i = MARK_SELECTION_END } },
{ /* empty last element, array terminator */ },
};
diff --git a/editor.c b/editor.c
index 367c40b..4128ffa 100644
--- a/editor.c
+++ b/editor.c
@@ -55,8 +55,14 @@ static void editor_window_statusbar_draw(EditorWin *win) {
win->editor->statusbar(win);
}
-static void editor_window_cursor_moved(Win *win, void *data) {
- editor_window_statusbar_draw(data);
+static void editor_window_cursor_moved(Win *winwin, void *data) {
+ EditorWin *win = data;
+ Filerange sel = window_selection_get(winwin);
+ if (text_range_valid(&sel) && sel.start != sel.end) {
+ text_mark_set(win->text, MARK_SELECTION_START, sel.start);
+ text_mark_set(win->text, MARK_SELECTION_END, sel.end);
+ }
+ editor_window_statusbar_draw(win);
}
void editor_statusbar_set(Editor *ed, void (*statusbar)(EditorWin*)) {
diff --git a/editor.h b/editor.h
index 5eeab8e..a607bda 100644
--- a/editor.h
+++ b/editor.h
@@ -86,6 +86,8 @@ enum Mark {
MARK_x,
MARK_y,
MARK_z,
+ MARK_SELECTION_START,
+ MARK_SELECTION_END,
};
struct Editor {
diff --git a/text.c b/text.c
index e613ccb..fdcf1cf 100644
--- a/text.c
+++ b/text.c
@@ -120,7 +120,7 @@ struct Text {
struct stat info; /* stat as proped on load time */
int fd; /* the file descriptor of the original mmap-ed data */
LineCache lines; /* mapping between absolute pos in bytes and logical line breaks */
- const char *marks[26]; /* a mark is a pointer into an underlying buffer */
+ const char *marks[32]; /* a mark is a pointer into an underlying buffer */
int newlines; /* 0: unknown, 1: \n, -1: \r\n */
};