diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-05 07:32:41 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-05 07:32:41 +0200 |
| commit | abcb867f74efd37ec66490c201204c668920b2ab (patch) | |
| tree | 842a8d9fc34c96b4f6bd79ef4cb7ff801b38bedc | |
| parent | c0b411255115569c63430d0162920b53747a917a (diff) | |
| download | vis-abcb867f74efd37ec66490c201204c668920b2ab.tar.gz vis-abcb867f74efd37ec66490c201204c668920b2ab.tar.xz | |
Remember whether the register content is linewise
| -rw-r--r-- | config.def.h | 6 | ||||
| -rw-r--r-- | vis.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index b1b2029..fe585fa 100644 --- a/config.def.h +++ b/config.def.h @@ -42,6 +42,7 @@ enum { void op_delete(OperatorContext *c) { size_t len = c->range.end - c->range.start; + c->reg->linewise = c->linewise; register_put(c->reg, vis->win->text, &c->range); vis_delete(vis, c->range.start, len); window_cursor_to(vis->win->win, c->range.start); @@ -53,11 +54,14 @@ void op_change(OperatorContext *c) { } void op_yank(OperatorContext *c) { + c->reg->linewise = c->linewise; register_put(c->reg, vis->win->text, &c->range); } void op_paste(OperatorContext *c) { size_t pos = window_cursor_get(vis->win->win); + if (c->reg->linewise) + pos = text_line_next(vis->win->text, pos); vis_insert(vis, pos, c->reg->data, c->reg->len); window_cursor_to(vis->win->win, pos + c->reg->len); } @@ -260,6 +264,7 @@ static void operator(const Arg *arg) { if (action.op == op) { /* hacky way to handle double operators i.e. things like * dd, yy etc where the second char isn't a movement */ + action.linewise = true; action.textobj = moves_linewise[MOVE_LINE_DOWN]; action_do(&action); } else { @@ -334,6 +339,7 @@ void action_do(Action *a) { .count = a->count, .pos = pos, .reg = a->reg ? a->reg : &vis->registers[REG_DEFAULT], + .linewise = a->linewise, }; if (a->movement) { @@ -93,6 +93,7 @@ typedef struct { Register *reg; Filerange range; size_t pos; + bool linewise; } OperatorContext; typedef struct { |
