From a9db1caf19d34f13319a3ebf92100c2c92015582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 11 Feb 2016 10:32:49 +0100 Subject: vis: implement gn and gN text objects The behaviour when no match is found is not yet optimal. --- vis-text-objects.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'vis-text-objects.c') diff --git a/vis-text-objects.c b/vis-text-objects.c index a4fe36f..14f299d 100644 --- a/vis-text-objects.c +++ b/vis-text-objects.c @@ -9,6 +9,14 @@ void vis_textobject(Vis *vis, enum VisTextObject id) { } } +static Filerange search_forward(Vis *vis, Text *txt, size_t pos) { + return text_object_search_forward(txt, pos, vis->search_pattern); +} + +static Filerange search_backward(Vis *vis, Text *txt, size_t pos) { + return text_object_search_backward(txt, pos, vis->search_pattern); +} + TextObject vis_textobjects[] = { [VIS_TEXTOBJECT_INNER_WORD] = { .txt = text_object_word }, [VIS_TEXTOBJECT_OUTER_WORD] = { .txt = text_object_word_outer }, @@ -36,5 +44,7 @@ TextObject vis_textobjects[] = { [VIS_TEXTOBJECT_INNER_FUNCTION] = { .txt = text_object_function_inner, }, [VIS_TEXTOBJECT_OUTER_LINE] = { .txt = text_object_line, }, [VIS_TEXTOBJECT_INNER_LINE] = { .txt = text_object_line_inner, }, + [VIS_TEXTOBJECT_SEARCH_FORWARD] = { .vis = search_forward, .type = SPLIT }, + [VIS_TEXTOBJECT_SEARCH_BACKWARD] = { .vis = search_backward, .type = SPLIT }, }; -- cgit v1.2.3