From 2c8fcaa8fbb17b99aa5b0f8bfbbe0451dfa509f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 19 Apr 2017 13:11:52 +0200 Subject: 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. in insert mode has not yet been adapted and register handling in general needs to be cleaned up further. Fix #527 --- vis-operators.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'vis-operators.c') 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; -- cgit v1.2.3