diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-02-15 08:25:23 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-02-15 08:27:59 +0100 |
| commit | 749e6f9a50d5570d40c2c5f1ebc3eaceb32776da (patch) | |
| tree | a6d6d0dafc4fdb4a8f5bea2e6a9c2ea72263a51d /text-motions.c | |
| parent | d266238916882b4082b3ddbb71941aea5e7d20ef (diff) | |
| download | vis-749e6f9a50d5570d40c2c5f1ebc3eaceb32776da.tar.gz vis-749e6f9a50d5570d40c2c5f1ebc3eaceb32776da.tar.xz | |
vis: remove motion and text objects related to C functions
These do not really belong into the editor core. If desired they
could be implemented in Lua instead.
Diffstat (limited to 'text-motions.c')
| -rw-r--r-- | text-motions.c | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/text-motions.c b/text-motions.c index f5701ae..094395f 100644 --- a/text-motions.c +++ b/text-motions.c @@ -511,81 +511,6 @@ size_t text_line_empty_prev(Text *txt, size_t pos) { return it.pos; } -size_t text_function_start_next(Text *txt, size_t pos) { - size_t a = text_function_end_next(txt, pos); - size_t b = a; - char c; - if (a != pos) { - Iterator it = text_iterator_get(txt, a); - while (text_iterator_byte_next(&it, &c) && (c == '\r' || c == '\n')); - a = it.pos; - } - if (b != pos) { - size_t match = text_bracket_match(txt, b); - b = match != b ? text_line_next(txt, text_line_empty_prev(txt, match)) : pos; - } - if (a <= pos && b <= pos) - return pos; - else if (a <= pos) - return b; - else if (b <= pos) - return a; - else - return MIN(a, b); -} - -size_t text_function_start_prev(Text *txt, size_t pos) { - char c; - size_t apos = text_byte_get(txt, pos, &c) && c == '}' && pos > 0 ? pos - 1 : pos; - size_t a = text_function_end_next(txt, apos); - size_t b = text_function_end_prev(txt, pos); - if (a != apos) { - size_t match = text_bracket_match(txt, a); - a = match != a ? text_line_next(txt, text_line_empty_prev(txt, match)) : pos; - } - if (b != pos) { - size_t match = text_bracket_match(txt, b); - b = match != b ? text_line_next(txt, text_line_empty_prev(txt, match)) : pos; - } - if (a >= pos && b >= pos) - return pos; - else if (a >= pos) - return b; - else if (b >= pos) - return a; - else - return MAX(a, b); -} - -static size_t text_function_end_direction(Text *txt, size_t pos, int direction) { - size_t start = pos, match; - if (direction < 0 && pos > 0) - pos--; - for (;;) { - char c[3]; - if (direction > 0) - match = text_find_next(txt, pos, "\n}"); - else - match = text_find_prev(txt, pos, "\n}"); - if (text_bytes_get(txt, match, sizeof c, c) != 3 || c[0] != '\n' || c[1] != '}') - break; - if (c[2] == '\r' || c[2] == '\n') - return match+1; - if (match == pos) - match += direction; - pos = match; - } - return start; -} - -size_t text_function_end_next(Text *txt, size_t pos) { - return text_function_end_direction(txt, pos, +1); -} - -size_t text_function_end_prev(Text *txt, size_t pos) { - return text_function_end_direction(txt, pos, -1); -} - size_t text_block_start(Text *txt, size_t pos) { Filerange r = text_object_curly_bracket(txt, pos-1); return text_range_valid(&r) ? r.start-1 : pos; |
