diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-04-19 13:11:52 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-04-19 13:42:25 +0200 |
| commit | 2c8fcaa8fbb17b99aa5b0f8bfbbe0451dfa509f3 (patch) | |
| tree | 1160dd96040c19f2a6da365e29240d978c6067ca /vis-operators.c | |
| parent | a2316394d35eb548545730cbf2b57b27e733214c (diff) | |
| download | vis-2c8fcaa8fbb17b99aa5b0f8bfbbe0451dfa509f3.tar.gz vis-2c8fcaa8fbb17b99aa5b0f8bfbbe0451dfa509f3.tar.xz | |
vis: restructure register handling
Decouple register content from cursors. Previously each cursor had
exactly one corresponding register. Now each register can save a
list of values whose lifetime is not tied to the cursor.
If multiple cursors exist and a put with a register holding only
a single value is performed, then this value is inserted at every
cursor location. If there are fewer values available than cursors,
then only the matching ones will be used. If a register holding
multiple values is inserted in a single cursor context, only the
first value will be used. Another option would be to join all
existing values. The details of this behavior might be changed
in the future.
<C-r> in insert mode has not yet been adapted and register handling
in general needs to be cleaned up further.
Fix #527
Diffstat (limited to 'vis-operators.c')
| -rw-r--r-- | vis-operators.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/vis-operators.c b/vis-operators.c index 1ef32c3..38ac7c8 100644 --- a/vis-operators.c +++ b/vis-operators.c @@ -8,7 +8,7 @@ static size_t op_delete(Vis *vis, Text *txt, OperatorContext *c) { c->reg->linewise = c->linewise; - register_put_range(vis, c->reg, txt, &c->range); + register_slot_put_range(vis, c->reg, c->reg_slot, txt, &c->range); text_delete_range(txt, &c->range); size_t pos = c->range.start; if (c->linewise && pos == text_size(txt)) @@ -26,10 +26,10 @@ static size_t op_change(Vis *vis, Text *txt, OperatorContext *c) { static size_t op_yank(Vis *vis, Text *txt, OperatorContext *c) { c->reg->linewise = c->linewise; - register_put_range(vis, c->reg, txt, &c->range); + register_slot_put_range(vis, c->reg, c->reg_slot, txt, &c->range); if (c->reg == &vis->registers[VIS_REG_DEFAULT]) { vis->registers[VIS_REG_ZERO].linewise = c->reg->linewise; - register_put_range(vis, &vis->registers[VIS_REG_ZERO], txt, &c->range); + register_slot_put_range(vis, &vis->registers[VIS_REG_ZERO], c->reg_slot, txt, &c->range); } return c->linewise ? c->pos : c->range.start; } @@ -59,7 +59,7 @@ static size_t op_put(Vis *vis, Text *txt, OperatorContext *c) { } size_t len; - const char *data = register_get(vis, c->reg, &len); + const char *data = register_slot_get(vis, c->reg, c->reg_slot, &len); for (int i = 0; i < c->count; i++) { char nl; @@ -298,7 +298,7 @@ bool vis_operator(Vis *vis, enum VisOperator id, ...) { break; case VIS_OP_REPLACE: { - Macro *macro = &vis->registers[VIS_REG_DOT].buf; + Macro *macro = macro_get(vis, VIS_REG_DOT); macro_reset(macro); macro_append(macro, va_arg(ap, char*)); vis->action.arg.s = macro->data; |
