From 749e6f9a50d5570d40c2c5f1ebc3eaceb32776da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 15 Feb 2017 08:25:23 +0100 Subject: 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. --- text-motions.c | 75 ---------------------------------------------------------- 1 file changed, 75 deletions(-) (limited to 'text-motions.c') 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; -- cgit v1.2.3