From 979d51bcb65ccceec95f34a10fdf6446ac97473c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 11 Feb 2016 10:03:14 +0100 Subject: 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. --- vis.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'vis.c') 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; -- cgit v1.2.3