From 02ee27233b43eba648e5a9060fe269df963b9844 Mon Sep 17 00:00:00 2001 From: pommicket Date: Mon, 2 Jan 2023 12:16:35 -0500 Subject: restructure tags.c, menu.c --- menu.c | 20 ++++++++++---------- tags.c | 7 +++---- ted.h | 28 ++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/menu.c b/menu.c index bdcaa23..d6d954f 100644 --- a/menu.c +++ b/menu.c @@ -1,3 +1,5 @@ +#include "ted.h" + static void menu_close_with_next(Ted *ted, Menu next) { ted_switch_to_buffer(ted, ted->prev_active_buffer); TextBuffer *buffer = ted->active_buffer; @@ -96,7 +98,7 @@ void menu_open(Ted *ted, Menu menu) { } } -static void menu_escape(Ted *ted) { +void menu_escape(Ted *ted) { if (*ted->warn_overwrite) { // just close "are you sure you want to overwrite?" *ted->warn_overwrite = 0; @@ -106,13 +108,12 @@ static void menu_escape(Ted *ted) { } } -static float menu_get_width(Ted *ted) { +float menu_get_width(Ted *ted) { const Settings *settings = ted_active_settings(ted); return minf(settings->max_menu_width, ted->window_width - 2.0f * settings->padding); } -// returns the rectangle of the screen coordinates of the menu -static Rect menu_rect(Ted *ted) { +Rect menu_rect(Ted *ted) { Settings *settings = ted_active_settings(ted); float window_width = ted->window_width, window_height = ted->window_height; float padding = settings->padding; @@ -123,7 +124,7 @@ static Rect menu_rect(Ted *ted) { ); } -static void menu_update(Ted *ted) { +void menu_update(Ted *ted) { Menu menu = ted->menu; const Settings *settings = ted_active_settings(ted); const u32 *colors = settings->colors; @@ -314,7 +315,7 @@ static void menu_update(Ted *ted) { } } -static void menu_render(Ted *ted) { +void menu_render(Ted *ted) { Menu menu = ted->menu; assert(menu); const Settings *settings = ted_active_settings(ted); @@ -450,8 +451,7 @@ static void menu_render(Ted *ted) { } } -// move to next/previous command -static void menu_shell_move(Ted *ted, int direction) { +void menu_shell_move(Ted *ted, int direction) { TextBuffer *line_buffer = &ted->line_buffer; if (line_buffer->modified) { // don't do it if the command has been edited @@ -475,9 +475,9 @@ static void menu_shell_move(Ted *ted, int direction) { } } -static void menu_shell_up(Ted *ted) { +void menu_shell_up(Ted *ted) { menu_shell_move(ted, -1); } -static void menu_shell_down(Ted *ted) { +void menu_shell_down(Ted *ted) { menu_shell_move(ted, +1); } diff --git a/tags.c b/tags.c index df1fa60..efbf5e2 100644 --- a/tags.c +++ b/tags.c @@ -1,3 +1,5 @@ +#include "ted.h" + static const char *tags_filename(Ted *ted, bool error_if_does_not_exist) { change_directory(ted->cwd); const char *filename = "tags"; @@ -93,7 +95,7 @@ static void tags_generate_at_dir(Ted *ted, bool run_in_build_window, const char } // generate/re-generate tags. -static void tags_generate(Ted *ted, bool run_in_build_window) { +void tags_generate(Ted *ted, bool run_in_build_window) { const char *filename = tags_filename(ted, false); if (!filename) { strcpy(ted->tags_dir, ted->cwd); @@ -131,9 +133,6 @@ static int tag_try(FILE *fp, const char *tag) { return -1; } -// finds all tags beginning with the given prefix, returning them into *out, writing at most out_size entries. -// you may pass NULL for out, in which case just the number of matching tags is returned (still maxing out at out_size) -// each element in out should be freed when you're done with them size_t tags_beginning_with(Ted *ted, const char *prefix, char **out, size_t out_size) { assert(out_size); const char *tags_name = tags_filename(ted, true); diff --git a/ted.h b/ted.h index 382e600..c25a53e 100644 --- a/ted.h +++ b/ted.h @@ -810,6 +810,21 @@ void gl_geometry_rect_border(Rect r, float border_thickness, u32 color); void gl_geometry_draw(void); GLuint gl_load_texture_from_image(const char *path); +// === menu.c === +void menu_close(Ted *ted); +void menu_open(Ted *ted, Menu menu); +void menu_escape(Ted *ted); +float menu_get_width(Ted *ted); +Rect menu_rect(Ted *ted); +void menu_update(Ted *ted); +void menu_render(Ted *ted); +// move to next/previous command +void menu_shell_move(Ted *ted, int direction); +// move to previous command +void menu_shell_up(Ted *ted); +// move to next command +void menu_shell_down(Ted *ted); + // === node.c === void node_switch_to_tab(Ted *ted, Node *node, u16 new_tab_index); void node_tab_next(Ted *ted, Node *node, i64 n); @@ -841,6 +856,17 @@ char32_t syntax_matching_bracket(Language lang, char32_t c); bool syntax_is_opening_bracket(Language lang, char32_t c); void syntax_highlight(SyntaxState *state, Language lang, const char32_t *line, u32 line_len, SyntaxCharType *char_types); +// === tags.c === +void tags_generate(Ted *ted, bool run_in_build_window); +// find all tags beginning with the given prefix, returning them into `*out`, writing at most out_size entries. +// you may pass NULL for `out`, in which case just the number of matching tags is returned +// (still maxing out at `out_size`). +// each element in `out` should be freed when you're done with them. +size_t tags_beginning_with(Ted *ted, const char *prefix, char **out, size_t out_size); +bool tag_goto(Ted *ted, const char *tag); +// get all tags in the tags file as SymbolInfos. +SymbolInfo *tags_get_symbols(Ted *ted); + // === ted.c === void ted_seterr_to_buferr(Ted *ted, TextBuffer *buffer); bool ted_haserr(Ted *ted); @@ -890,7 +916,6 @@ void popup_render(Ted *ted, u32 options, const char *title, const char *body); v2 checkbox_frame(Ted *ted, bool *value, const char *label, v2 pos); -TextBuffer *find_search_buffer(Ted *ted); // first, we read all config files, then we parse them. // this is because we want less specific settings (e.g. settings applied // to all languages instead of one particular language) to be applied first, @@ -911,7 +936,6 @@ void config_free(Ted *ted); char *settings_get_root_dir(Settings *settings, const char *path); void menu_open(Ted *ted, Menu menu); void menu_close(Ted *ted); -void find_update(Ted *ted, bool force); void autocomplete_close(Ted *ted); void signature_help_retrigger(Ted *ted); // go to the definition of `name`. -- cgit v1.2.3