diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-12-05 12:41:31 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-12-16 11:28:44 -0700 |
| commit | bafcf13695f80dac6d9be87b65ad6156ddc3d621 (patch) | |
| tree | 95c9c70928fe7b90cbf1fa66013e41d3a90c3fce | |
| parent | 1d1d19ed30309b39fc5e43c830cabb4cdd004d07 (diff) | |
| download | vis-bafcf13695f80dac6d9be87b65ad6156ddc3d621.tar.gz vis-bafcf13695f80dac6d9be87b65ad6156ddc3d621.tar.xz | |
delete functions which were exposed as unused
| -rw-r--r-- | map.c | 19 | ||||
| -rw-r--r-- | map.h | 15 | ||||
| -rw-r--r-- | test/core/map-test.c | 3 | ||||
| -rw-r--r-- | text-common.c | 8 | ||||
| -rw-r--r-- | text-motions.c | 47 | ||||
| -rw-r--r-- | text-motions.h | 8 | ||||
| -rw-r--r-- | text.h | 1 | ||||
| -rw-r--r-- | view.c | 4 | ||||
| -rw-r--r-- | view.h | 1 | ||||
| -rw-r--r-- | vis-modes.c | 16 | ||||
| -rw-r--r-- | vis.c | 16 | ||||
| -rw-r--r-- | vis.h | 24 |
12 files changed, 3 insertions, 159 deletions
@@ -68,11 +68,6 @@ void *map_closest(const Map *map, const char *prefix) return result; } -bool map_contains(const Map *map, const char *prefix) -{ - return !map_empty(map_prefix(map, prefix)); -} - bool map_put(Map *map, const char *k, const void *value) { size_t len = strlen(k); @@ -331,17 +326,3 @@ void map_free(Map *map) map_clear(map); free(map); } - -static bool free_elem(const char *key, void *value, void *data) -{ - free(value); - return true; -} - -void map_free_full(Map *map) -{ - if (!map) - return; - map_iterate(map, free_elem, NULL); - map_free(map); -} @@ -35,13 +35,6 @@ VIS_INTERNAL void *map_first(const Map *map, const char **key); */ VIS_INTERNAL void *map_closest(const Map *map, const char *prefix); /** - * Check whether the map contains the given prefix, or - * whether it can be extended to match a key of a map element. - * @param map The map to check. - * @param prefix The prefix to search for. - */ -VIS_INTERNAL bool map_contains(const Map *map, const char *prefix); -/** * Store a key value pair in the map. * @param map The map to store the key-value pair in. * @param key The key to store. @@ -97,13 +90,5 @@ VIS_INTERNAL void map_clear(Map *map); * @param map The map to free. */ VIS_INTERNAL void map_free(Map *map); -/** - * Call `free(3)` for every map element, then free the map itself. - * @param map The map to free its elements and itself. - * @rst - * .. warning:: Assumes map elements to be pointers. - * @endrst - */ -VIS_INTERNAL void map_free_full(Map *map); #endif diff --git a/test/core/map-test.c b/test/core/map-test.c index beb6ba2..06364e4 100644 --- a/test/core/map-test.c +++ b/test/core/map-test.c @@ -50,7 +50,6 @@ int main(int argc, char *argv[]) { ok(map_empty(map_prefix(map, "404")), "Empty prefix map"); ok(!map_get(map, "404"), "Get non-existing key"); - ok(!map_contains(map, "404"), "Contains non-existing key"); ok(!map_closest(map, "404"), "Closest non-existing key"); ok(!map_put(map, "a", NULL) && map_empty(map) && !map_get(map, "a"), "Put NULL value"); @@ -58,7 +57,7 @@ int main(int argc, char *argv[]) { ok(map_first(map, &key) == &values[0] && strcmp(key, "a") == 0, "First on map with 1 value"); key = NULL; ok(map_first(map_prefix(map, "a"), &key) == &values[0] && strcmp(key, "a") == 0, "First on prefix map"); - ok(map_contains(map, "a"), "Contains existing key"); + ok(!map_empty(map_prefix(map, "a")), "Contains existing key"); ok(map_closest(map, "a") == &values[0], "Closest match existing key"); ok(!map_put(map, "a", &values[1]) && get(map, "a", &values[0]), "Put duplicate"); ok(map_put(map, "cafebabe", &values[2]) && get(map, "cafebabe", &values[2]), "Put 2"); diff --git a/text-common.c b/text-common.c index 6225dad..87dc13f 100644 --- a/text-common.c +++ b/text-common.c @@ -26,14 +26,6 @@ bool text_appendf(Text *txt, const char *format, ...) { return ret; } -bool text_printf(Text *txt, size_t pos, const char *format, ...) { - va_list ap; - va_start(ap, format); - bool ret = text_vprintf(txt, pos, format, ap); - va_end(ap); - return ret; -} - bool text_byte_get(const Text *txt, size_t pos, char *byte) { return text_bytes_get(txt, pos, 1, byte); } diff --git a/text-motions.c b/text-motions.c index 13aad19..a17adde 100644 --- a/text-motions.c +++ b/text-motions.c @@ -20,14 +20,6 @@ int is_word_boundary(int c) { ('A' <= c && c <= 'Z') || c == '_'); } -size_t text_begin(Text *txt, size_t pos) { - return 0; -} - -size_t text_end(Text *txt, size_t pos) { - return text_size(txt); -} - size_t text_char_next(Text *txt, size_t pos) { Iterator it = text_iterator_get(txt, pos); text_iterator_char_next(&it, NULL); @@ -298,18 +290,6 @@ size_t text_range_line_first(Text *txt, Filerange *r) { return r->start; } -size_t text_range_line_last(Text *txt, Filerange *r) { - if (!text_range_valid(r)) - return EPOS; - size_t pos = text_line_begin(txt, r->end); - if (pos == r->end) { - /* range ends at a begin of a line, skip last line ending */ - pos = text_line_prev(txt, pos); - pos = text_line_begin(txt, pos); - } - return r->start <= pos ? pos : r->start; -} - size_t text_range_line_next(Text *txt, Filerange *r, size_t pos) { if (!text_range_contains(r, pos)) return EPOS; @@ -317,13 +297,6 @@ size_t text_range_line_next(Text *txt, Filerange *r, size_t pos) { return newpos != pos && newpos < r->end ? newpos : EPOS; } -size_t text_range_line_prev(Text *txt, Filerange *r, size_t pos) { - if (!text_range_contains(r, pos)) - return EPOS; - size_t newpos = text_line_begin(txt, text_line_prev(txt, pos)); - return newpos != pos && r->start <= newpos ? newpos : EPOS; -} - size_t text_customword_start_next(Text *txt, size_t pos, int (*isboundary)(int)) { char c; Iterator it = text_iterator_get(txt, pos); @@ -464,26 +437,6 @@ size_t text_paragraph_prev(Text *txt, size_t pos) { return text_line_blank_prev(txt, it.pos); } -size_t text_line_empty_next(Text *txt, size_t pos) { - char c; - Iterator it = text_iterator_get(txt, pos); - while (text_iterator_byte_find_next(&it, '\n')) { - if (text_iterator_byte_next(&it, &c) && c == '\n') - return it.pos; - } - return it.pos; -} - -size_t text_line_empty_prev(Text *txt, size_t pos) { - char c; - Iterator it = text_iterator_get(txt, pos); - while (text_iterator_byte_find_prev(&it, '\n')) { - if (text_iterator_byte_prev(&it, &c) && c == '\n') - return it.pos + 1; - } - return it.pos; -} - size_t text_line_blank_next(Text *txt, size_t pos) { char c; Iterator it = text_iterator_get(txt, pos); diff --git a/text-motions.h b/text-motions.h index 4bfc6c2..95e554d 100644 --- a/text-motions.h +++ b/text-motions.h @@ -9,9 +9,6 @@ #include "text.h" #include "text-regex.h" -VIS_INTERNAL size_t text_begin(Text*, size_t pos); -VIS_INTERNAL size_t text_end(Text*, size_t pos); - /* char refers to a grapheme (might skip over multiple Unicode codepoints) */ VIS_INTERNAL size_t text_char_next(Text*, size_t pos); VIS_INTERNAL size_t text_char_prev(Text*, size_t pos); @@ -52,9 +49,6 @@ VIS_INTERNAL size_t text_line_width_set(Text*, size_t pos, int width); /* move to the next/previous grapheme on the same line */ VIS_INTERNAL size_t text_line_char_next(Text*, size_t pos); VIS_INTERNAL size_t text_line_char_prev(Text*, size_t pos); -/* move to the next/previous empty line */ -VIS_INTERNAL size_t text_line_empty_next(Text*, size_t pos); -VIS_INTERNAL size_t text_line_empty_prev(Text*, size_t pos); /* move to start of next/previous blank line */ VIS_INTERNAL size_t text_line_blank_next(Text*, size_t pos); VIS_INTERNAL size_t text_line_blank_prev(Text*, size_t pos); @@ -63,9 +57,7 @@ VIS_INTERNAL size_t text_line_up(Text*, size_t pos); VIS_INTERNAL size_t text_line_down(Text*, size_t pos); /* functions to iterate over all line beginnings in a given range */ VIS_INTERNAL size_t text_range_line_first(Text*, Filerange*); -VIS_INTERNAL size_t text_range_line_last(Text*, Filerange*); VIS_INTERNAL size_t text_range_line_next(Text*, Filerange*, size_t pos); -VIS_INTERNAL size_t text_range_line_prev(Text*, Filerange*, size_t pos); /* * A longword consists of a sequence of non-blank characters, separated with * white space. TODO?: An empty line is also considered to be a word. @@ -158,7 +158,6 @@ VIS_INTERNAL bool text_insert(Text *txt, size_t pos, const char *data, size_t le */ VIS_INTERNAL bool text_delete(Text *txt, size_t pos, size_t len); VIS_INTERNAL bool text_delete_range(Text *txt, const Filerange*); -VIS_INTERNAL bool text_printf(Text *txt, size_t pos, const char *format, ...) __attribute__((format(printf, 3, 4))); VIS_INTERNAL bool text_appendf(Text *txt, const char *format, ...) __attribute__((format(printf, 2, 3))); /** * @} @@ -872,10 +872,6 @@ size_t view_cursor_get(View *view) { return view_cursors_pos(view->selection); } -void view_scroll_to(View *view, size_t pos) { - view_cursors_scroll_to(view->selection, pos); -} - void win_options_set(Win *win, enum UiOption options) { const int mapping[] = { [SYNTAX_SYMBOL_SPACE] = UI_OPTION_SYMBOL_SPACE, @@ -114,7 +114,6 @@ VIS_INTERNAL size_t view_scroll_halfpage_down(View*); VIS_INTERNAL void view_redraw_top(View*); VIS_INTERNAL void view_redraw_center(View*); VIS_INTERNAL void view_redraw_bottom(View*); -VIS_INTERNAL void view_scroll_to(View*, size_t pos); /** * @} * @defgroup view_size View Sizing diff --git a/vis-modes.c b/vis-modes.c index a6ab87b..5b8a71d 100644 --- a/vis-modes.c +++ b/vis-modes.c @@ -102,10 +102,6 @@ enum VisMode vis_mode_from(Vis *vis, const char *name) { return VIS_MODE_INVALID; } -enum VisMode vis_mode_get(Vis *vis) { - return vis->mode->id; -} - static bool mode_unmap(Mode *mode, const char *key) { return mode && mode->bindings && map_delete(mode->bindings, key); } @@ -243,14 +239,6 @@ static void vis_mode_insert_idle(Vis *vis) { vis_file_snapshot(vis, win->file); } -static void vis_mode_insert_input(Vis *vis, const char *str, size_t len) { - vis_insert_key(vis, str, len); -} - -static void vis_mode_replace_input(Vis *vis, const char *str, size_t len) { - vis_replace_key(vis, str, len); -} - Mode vis_modes[] = { [VIS_MODE_OPERATOR_PENDING] = { .id = VIS_MODE_OPERATOR_PENDING, @@ -289,7 +277,7 @@ Mode vis_modes[] = { .status = "INSERT", .help = "", .enter = vis_mode_insert_replace_enter, - .input = vis_mode_insert_input, + .input = vis_insert_key, .idle = vis_mode_insert_idle, .idle_timeout = 3, }, @@ -300,7 +288,7 @@ Mode vis_modes[] = { .status = "REPLACE", .help = "", .enter = vis_mode_insert_replace_enter, - .input = vis_mode_replace_input, + .input = vis_replace_key, .idle = vis_mode_insert_idle, .idle_timeout = 3, }, @@ -700,14 +700,6 @@ void vis_replace_key(Vis *vis, const char *data, size_t len) { } } -void vis_delete(Vis *vis, size_t pos, size_t len) { - Win *win = vis->win; - if (!win) - return; - text_delete(win->file->text, pos, len); - vis_window_invalidate(win); -} - bool vis_action_register(Vis *vis, const KeyAction *action) { return map_put(vis->actions, action->name, action); } @@ -720,14 +712,6 @@ void vis_keymap_disable(Vis *vis) { vis->keymap_disabled = true; } -void vis_interrupt(Vis *vis) { - vis->interrupted = true; -} - -bool vis_interrupt_requested(Vis *vis) { - return vis->interrupted; -} - void vis_do(Vis *vis) { Win *win = vis->win; if (!win) @@ -147,23 +147,6 @@ VIS_EXPORT void vis_die(Vis *vis, const char *msg, ...) __attribute__((noreturn, * @endrst */ VIS_EXPORT bool vis_signal_handler(Vis *vis, int signum, const siginfo_t *siginfo, const void *context); -/** - * Interrupt long running operation. - * @param vis The editor instance. - * @rst - * .. warning:: There is no guarantee that a long running operation is actually - * interrupted. It is analogous to cooperative multitasking where - * the operation has to voluntarily yield control. - * .. note:: It is invoked from `vis_signal_handler` when receiving ``SIGINT``. - * @endrst - */ -VIS_EXPORT void vis_interrupt(Vis*); -/** - * Check whether interruption was requested. - * @param vis The editor instance. - */ -VIS_EXPORT bool vis_interrupt_requested(Vis*); -/** @} */ /* --- @@ -329,13 +312,6 @@ VIS_EXPORT void vis_message_show(Vis *vis, const char *msg); */ VIS_EXPORT void vis_insert(Vis *vis, size_t pos, const char *data, size_t len); /** - * Delete data from the file. - * @param vis The editor instance. - * @param pos The starting position of the deletion. - * @param len The length of the data to delete. - */ -VIS_EXPORT void vis_delete(Vis *vis, size_t pos, size_t len); -/** * Replace data in the file. * @param vis The editor instance. * @param pos The position to replace at. |
