diff options
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | vis.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index f8f07bf..950fd54 100644 --- a/config.def.h +++ b/config.def.h @@ -421,6 +421,7 @@ static KeyBinding vis_mode_normal[] = { static KeyBinding vis_mode_visual[] = { { { KEY(BACKSPACE) }, operator, { .i = OP_DELETE } }, { { KEY(DELETE) }, operator, { .i = OP_DELETE } }, + { { CONTROL('O') }, operator, { .i = OP_CURSOR } }, { { NONE(ESC) }, switchmode, { .i = VIS_MODE_NORMAL } }, { { CONTROL('c') }, switchmode, { .i = VIS_MODE_NORMAL } }, { { NONE('v') }, switchmode, { .i = VIS_MODE_NORMAL } }, @@ -56,6 +56,7 @@ static size_t op_case_change(OperatorContext *c); static size_t op_join(OperatorContext *c); static size_t op_repeat_insert(OperatorContext *c); static size_t op_repeat_replace(OperatorContext *c); +static size_t op_cursor(OperatorContext *c); /* these can be passed as int argument to operator(&(const Arg){ .i = OP_*}) */ enum { @@ -69,6 +70,7 @@ enum { OP_JOIN, OP_REPEAT_INSERT, OP_REPEAT_REPLACE, + OP_CURSOR, }; static Operator ops[] = { @@ -82,6 +84,7 @@ static Operator ops[] = { [OP_JOIN] = { op_join }, [OP_REPEAT_INSERT] = { op_repeat_insert }, [OP_REPEAT_REPLACE] = { op_repeat_replace }, + [OP_CURSOR] = { op_cursor }, }; #define PAGE INT_MAX @@ -568,6 +571,18 @@ static size_t op_case_change(OperatorContext *c) { return c->pos; } +static size_t op_cursor(OperatorContext *c) { + Text *txt = vis->win->file->text; + View *view = vis->win->view; + Filerange r = text_range_linewise(txt, &c->range); + for (size_t line = text_range_line_first(txt, &r); line != EPOS; line = text_range_line_next(txt, &r, line)) { + Cursor *cursor = view_cursors_new(view); + if (cursor) + view_cursors_to(cursor, text_line_start(txt, line)); + } + return EPOS; +} + static size_t op_join(OperatorContext *c) { Text *txt = vis->win->file->text; size_t pos = text_line_begin(txt, c->range.end), prev_pos; |
