diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-02-07 09:17:35 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-02-07 11:31:34 +0100 |
| commit | b01ac103aa61b5a0383ed085bf6997d8e5f70bbc (patch) | |
| tree | 3d02f19abec12a61a7a48810ee21fa7e53fc2718 | |
| parent | d97c8cc3cf9b64c680f4ae933354adc19e50dde2 (diff) | |
| download | vis-b01ac103aa61b5a0383ed085bf6997d8e5f70bbc.tar.gz vis-b01ac103aa61b5a0383ed085bf6997d8e5f70bbc.tar.xz | |
vis: reformat text object definitions
| -rw-r--r-- | vis-core.h | 6 | ||||
| -rw-r--r-- | vis-text-objects.c | 132 | ||||
| -rw-r--r-- | vis.c | 2 |
3 files changed, 107 insertions, 33 deletions
@@ -80,9 +80,9 @@ typedef struct { Filerange (*vis)(Vis*, Text*, size_t pos); Filerange (*user)(Vis*, Win*, void *data, size_t pos); enum { - INNER = 1 << 0, /* whether the object should include */ - OUTER = 1 << 1, /* the delimiting symbols or not */ - SPLIT = 1 << 2, /* whether multiple applications will yield a split range */ + TEXTOBJECT_DELIMITED_INNER = 1 << 0, /* single byte delimited, inner variant */ + TEXTOBJECT_DELIMITED_OUTER = 1 << 1, /* single byte delimited, outer variant */ + TEXTOBJECT_NON_CONTIGUOUS = 1 << 2, /* multiple applications yield a split range */ } type; void *data; } TextObject; diff --git a/vis-text-objects.c b/vis-text-objects.c index b3ed463..e4b053b 100644 --- a/vis-text-objects.c +++ b/vis-text-objects.c @@ -97,34 +97,108 @@ static Filerange object_backtick(Text *txt, size_t pos) { } const TextObject vis_textobjects[] = { - [VIS_TEXTOBJECT_INNER_WORD] = { .txt = text_object_word }, - [VIS_TEXTOBJECT_OUTER_WORD] = { .txt = text_object_word_outer }, - [VIS_TEXTOBJECT_INNER_LONGWORD] = { .txt = text_object_longword }, - [VIS_TEXTOBJECT_OUTER_LONGWORD] = { .txt = text_object_longword_outer }, - [VIS_TEXTOBJECT_SENTENCE] = { .txt = text_object_sentence }, - [VIS_TEXTOBJECT_PARAGRAPH] = { .txt = text_object_paragraph }, - [VIS_TEXTOBJECT_OUTER_SQUARE_BRACKET] = { .txt = text_object_square_bracket, .type = OUTER }, - [VIS_TEXTOBJECT_INNER_SQUARE_BRACKET] = { .txt = text_object_square_bracket, .type = INNER }, - [VIS_TEXTOBJECT_OUTER_CURLY_BRACKET] = { .txt = text_object_curly_bracket, .type = OUTER }, - [VIS_TEXTOBJECT_INNER_CURLY_BRACKET] = { .txt = text_object_curly_bracket, .type = INNER }, - [VIS_TEXTOBJECT_OUTER_ANGLE_BRACKET] = { .txt = text_object_angle_bracket, .type = OUTER }, - [VIS_TEXTOBJECT_INNER_ANGLE_BRACKET] = { .txt = text_object_angle_bracket, .type = INNER }, - [VIS_TEXTOBJECT_OUTER_PARANTHESE] = { .txt = text_object_paranthese, .type = OUTER }, - [VIS_TEXTOBJECT_INNER_PARANTHESE] = { .txt = text_object_paranthese, .type = INNER }, - [VIS_TEXTOBJECT_OUTER_QUOTE] = { .txt = object_quote, .type = OUTER }, - [VIS_TEXTOBJECT_INNER_QUOTE] = { .txt = object_quote, .type = INNER }, - [VIS_TEXTOBJECT_OUTER_SINGLE_QUOTE] = { .txt = object_single_quote, .type = OUTER }, - [VIS_TEXTOBJECT_INNER_SINGLE_QUOTE] = { .txt = object_single_quote, .type = INNER }, - [VIS_TEXTOBJECT_OUTER_BACKTICK] = { .txt = object_backtick, .type = OUTER }, - [VIS_TEXTOBJECT_INNER_BACKTICK] = { .txt = object_backtick, .type = INNER }, - [VIS_TEXTOBJECT_OUTER_ENTIRE] = { .txt = text_object_entire, }, - [VIS_TEXTOBJECT_INNER_ENTIRE] = { .txt = text_object_entire_inner, }, - [VIS_TEXTOBJECT_OUTER_FUNCTION] = { .txt = text_object_function, }, - [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_INDENTATION] = { .txt = text_object_indentation, }, - [VIS_TEXTOBJECT_SEARCH_FORWARD] = { .vis = search_forward, .type = SPLIT }, - [VIS_TEXTOBJECT_SEARCH_BACKWARD] = { .vis = search_backward, .type = SPLIT }, + [VIS_TEXTOBJECT_INNER_WORD] = { + .txt = text_object_word, + }, + [VIS_TEXTOBJECT_OUTER_WORD] = { + .txt = text_object_word_outer, + }, + [VIS_TEXTOBJECT_INNER_LONGWORD] = { + .txt = text_object_longword, + }, + [VIS_TEXTOBJECT_OUTER_LONGWORD] = { + .txt = text_object_longword_outer, + }, + [VIS_TEXTOBJECT_SENTENCE] = { + .txt = text_object_sentence, + }, + [VIS_TEXTOBJECT_PARAGRAPH] = { + .txt = text_object_paragraph, + }, + [VIS_TEXTOBJECT_OUTER_SQUARE_BRACKET] = { + .txt = text_object_square_bracket, + .type = TEXTOBJECT_DELIMITED_OUTER, + }, + [VIS_TEXTOBJECT_INNER_SQUARE_BRACKET] = { + .txt = text_object_square_bracket, + .type = TEXTOBJECT_DELIMITED_INNER, + }, + [VIS_TEXTOBJECT_OUTER_CURLY_BRACKET] = { + .txt = text_object_curly_bracket, + .type = TEXTOBJECT_DELIMITED_OUTER, + }, + [VIS_TEXTOBJECT_INNER_CURLY_BRACKET] = { + .txt = text_object_curly_bracket, + .type = TEXTOBJECT_DELIMITED_INNER, + }, + [VIS_TEXTOBJECT_OUTER_ANGLE_BRACKET] = { + .txt = text_object_angle_bracket, + .type = TEXTOBJECT_DELIMITED_OUTER, + }, + [VIS_TEXTOBJECT_INNER_ANGLE_BRACKET] = { + .txt = text_object_angle_bracket, + .type = TEXTOBJECT_DELIMITED_INNER, + }, + [VIS_TEXTOBJECT_OUTER_PARANTHESE] = { + .txt = text_object_paranthese, + .type = TEXTOBJECT_DELIMITED_OUTER, + }, + [VIS_TEXTOBJECT_INNER_PARANTHESE] = { + .txt = text_object_paranthese, + .type = TEXTOBJECT_DELIMITED_INNER, + }, + [VIS_TEXTOBJECT_OUTER_QUOTE] = { + .txt = object_quote, + .type = TEXTOBJECT_DELIMITED_OUTER, + }, + [VIS_TEXTOBJECT_INNER_QUOTE] = { + .txt = object_quote, + .type = TEXTOBJECT_DELIMITED_INNER, + }, + [VIS_TEXTOBJECT_OUTER_SINGLE_QUOTE] = { + .txt = object_single_quote, + .type = TEXTOBJECT_DELIMITED_OUTER, + }, + [VIS_TEXTOBJECT_INNER_SINGLE_QUOTE] = { + .txt = object_single_quote, + .type = TEXTOBJECT_DELIMITED_INNER, + }, + [VIS_TEXTOBJECT_OUTER_BACKTICK] = { + .txt = object_backtick, + .type = TEXTOBJECT_DELIMITED_OUTER, + }, + [VIS_TEXTOBJECT_INNER_BACKTICK] = { + .txt = object_backtick, + .type = TEXTOBJECT_DELIMITED_INNER, + }, + [VIS_TEXTOBJECT_OUTER_ENTIRE] = { + .txt = text_object_entire, + }, + [VIS_TEXTOBJECT_INNER_ENTIRE] = { + .txt = text_object_entire_inner, + }, + [VIS_TEXTOBJECT_OUTER_FUNCTION] = { + .txt = text_object_function, + }, + [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_INDENTATION] = { + .txt = text_object_indentation, + }, + [VIS_TEXTOBJECT_SEARCH_FORWARD] = { + .vis = search_forward, + .type = TEXTOBJECT_NON_CONTIGUOUS, + }, + [VIS_TEXTOBJECT_SEARCH_BACKWARD] = { + .vis = search_backward, + .type = TEXTOBJECT_NON_CONTIGUOUS, + }, }; @@ -771,7 +771,7 @@ void vis_do(Vis *vis) { r = a->textobj->user(vis, win, a->textobj->data, pos); if (!text_range_valid(&r)) break; - if (a->textobj->type & OUTER) { + if (a->textobj->type & TEXTOBJECT_DELIMITED_OUTER) { r.start--; r.end++; } |
