diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-22 06:09:07 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-22 06:09:07 +0200 |
| commit | 637b1adbdda1af761518b90b52fb6ae7798584bc (patch) | |
| tree | 01c10bf0b2c573ce65806e80e4a2ddb0daecd66e | |
| parent | ddd80ea3ca108858ebd053339871c6fa251f9a8d (diff) | |
| download | vis-637b1adbdda1af761518b90b52fb6ae7798584bc.tar.gz vis-637b1adbdda1af761518b90b52fb6ae7798584bc.tar.xz | |
Add support for the '<', '>' marks
| -rw-r--r-- | README | 8 | ||||
| -rw-r--r-- | config.def.h | 4 | ||||
| -rw-r--r-- | editor.c | 10 | ||||
| -rw-r--r-- | editor.h | 2 | ||||
| -rw-r--r-- | text.c | 2 |
5 files changed, 21 insertions, 5 deletions
@@ -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 */ }, }; @@ -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*)) { @@ -86,6 +86,8 @@ enum Mark { MARK_x, MARK_y, MARK_z, + MARK_SELECTION_START, + MARK_SELECTION_END, }; struct Editor { @@ -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 */ }; |
