diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-23 14:38:45 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-26 12:13:44 +0200 |
| commit | d7a7a3efde175e944cc6943170c9f60467850060 (patch) | |
| tree | 3d415c3b8892af2e453414fdcf73aace3285c2c9 /config.def.h | |
| parent | 5e016233a9fe77258edd85a2dc746d20e6db46a0 (diff) | |
| download | vis-d7a7a3efde175e944cc6943170c9f60467850060.tar.gz vis-d7a7a3efde175e944cc6943170c9f60467850060.tar.xz | |
vis: add infrastructure to support multiple cursors/selections
This cleans up the existing selection handling code and adds the
necessary bits to eventually support multiple cursors/selections.
The cursor position is kept track of using marks, which means
retrieving the cursor position is no longer a constant time operation.
Furthermore the terminal cursor is no longer used, instead the whole
window is redrawn after every cursor movement.
Diffstat (limited to 'config.def.h')
| -rw-r--r-- | config.def.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/config.def.h b/config.def.h index 3007b60..f8f07bf 100644 --- a/config.def.h +++ b/config.def.h @@ -440,14 +440,15 @@ static KeyBinding vis_mode_visual[] = { static void vis_mode_visual_enter(Mode *old) { if (!old->visual) { - view_selection_start(vis->win->view); + for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c)) + view_cursors_selection_start(c); vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_TEXTOBJ]; } } static void vis_mode_visual_leave(Mode *new) { if (!new->visual) { - view_selection_clear(vis->win->view); + view_selections_clear(vis->win->view); vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE]; } } @@ -459,10 +460,9 @@ static KeyBinding vis_mode_visual_line[] = { }; static void vis_mode_visual_line_enter(Mode *old) { - View *view = vis->win->view; - view_cursor_to(view, text_line_begin(vis->win->file->text, view_cursor_get(view))); if (!old->visual) { - view_selection_start(view); + for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c)) + view_cursors_selection_start(c); vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_TEXTOBJ]; } movement(&(const Arg){ .i = MOVE_LINE_END }); @@ -470,7 +470,7 @@ static void vis_mode_visual_line_enter(Mode *old) { static void vis_mode_visual_line_leave(Mode *new) { if (!new->visual) { - view_selection_clear(vis->win->view); + view_selections_clear(vis->win->view); vis_modes[VIS_MODE_OPERATOR].parent = &vis_modes[VIS_MODE_MOVE]; } else { view_cursor_to(vis->win->view, view_cursor_get(vis->win->view)); @@ -478,7 +478,7 @@ static void vis_mode_visual_line_leave(Mode *new) { } static KeyBinding vis_mode_readline[] = { - { { KEY(BACKSPACE) }, call, { .f = editor_backspace_key } }, + { { KEY(BACKSPACE) }, delete, { .i = MOVE_CHAR_PREV } }, { { NONE(ESC) }, switchmode, { .i = VIS_MODE_NORMAL } }, { { CONTROL('c') }, switchmode, { .i = VIS_MODE_NORMAL } }, { { CONTROL('D') }, delete , { .i = MOVE_CHAR_NEXT } }, |
