aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-02-11 10:03:14 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-02-11 10:03:14 +0100
commit979d51bcb65ccceec95f34a10fdf6446ac97473c (patch)
treed06e2b6ed680a5f5a8279afc5fde58dc5a9f7037 /vis.c
parent534000b7831a6b536353053e47d582cf6c7f3053 (diff)
downloadvis-979d51bcb65ccceec95f34a10fdf6446ac97473c.tar.gz
vis-979d51bcb65ccceec95f34a10fdf6446ac97473c.tar.xz
vis: add support for different kind of text objects
Up until now text objects would only ever grow/expand if applied multiple times. The new SPLIT type allows text objects which cover a completely different range when applied with a count.
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/vis.c b/vis.c
index 96ee002..4c5124a 100644
--- a/vis.c
+++ b/vis.c
@@ -503,15 +503,22 @@ void action_do(Vis *vis, Action *a) {
else
c.range.start = c.range.end = pos;
for (int i = 0; i < count; i++) {
- Filerange r = a->textobj->range(txt, pos);
+ Filerange r;
+ if (a->textobj->txt)
+ r = a->textobj->txt(txt, pos);
+ else
+ r = a->textobj->vis(vis, txt, pos);
if (!text_range_valid(&r))
break;
- if (a->textobj->type == OUTER) {
+ if (a->textobj->type & OUTER) {
r.start--;
r.end++;
}
- c.range = text_range_union(&c.range, &r);
+ if (a->textobj->type & SPLIT)
+ c.range = r;
+ else
+ c.range = text_range_union(&c.range, &r);
if (i < count - 1)
pos = c.range.end + 1;