summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-02 12:11:05 -0500
committerpommicket <pommicket@gmail.com>2023-01-02 12:11:05 -0500
commitc42ae4ebf14388ff568ad005a94b07aba0824d31 (patch)
tree754a55b12aecc0bfe978acb1a5feec73461f535c
parent1665510ec0edf0feaf687acfdf8405b898c80089 (diff)
restructure build.c, find.c
-rw-r--r--build.c23
-rw-r--r--find.c18
-rw-r--r--main.c1
-rw-r--r--ted.h37
4 files changed, 58 insertions, 21 deletions
diff --git a/build.c b/build.c
index 5865daf..1ce198f 100644
--- a/build.c
+++ b/build.c
@@ -1,5 +1,6 @@
-// clear build errors and stop
-static void build_stop(Ted *ted) {
+#include "ted.h"
+
+void build_stop(Ted *ted) {
if (ted->building)
process_kill(&ted->build_process);
ted->building = false;
@@ -18,13 +19,11 @@ static void build_stop(Ted *ted) {
}
}
-// call before adding anything to the build queue
-static void build_queue_start(Ted *ted) {
+void build_queue_start(Ted *ted) {
build_stop(ted);
}
-// add a command to the build queue
-static void build_queue_command(Ted *ted, const char *command) {
+void build_queue_command(Ted *ted, const char *command) {
char *copy = str_dup(command);
if (copy)
arr_add(ted->build_queue, copy);
@@ -68,20 +67,18 @@ void build_setup_buffer(Ted *ted) {
build_buffer->store_undo_events = false; // don't need undo events for build output buffer
}
-// make sure you set ted->build_dir before running this!
-static void build_queue_finish(Ted *ted) {
+void build_queue_finish(Ted *ted) {
build_setup_buffer(ted);
build_run_next_command_in_queue(ted); // run the first command
}
-// make sure you set ted->build_dir before running this!
-static void build_start_with_command(Ted *ted, const char *command) {
+void build_start_with_command(Ted *ted, const char *command) {
build_queue_start(ted);
build_queue_command(ted, command);
build_queue_finish(ted);
}
-static void build_start(Ted *ted) {
+void build_start(Ted *ted) {
Settings *settings = ted_active_settings(ted);
char *command = settings->build_default_command;
char *root = ted_get_root_dir(ted);
@@ -125,7 +122,7 @@ static void build_go_to_error(Ted *ted) {
}
}
-static void build_next_error(Ted *ted) {
+void build_next_error(Ted *ted) {
if (ted->build_errors) {
ted->build_error += 1;
ted->build_error %= arr_len(ted->build_errors);
@@ -133,7 +130,7 @@ static void build_next_error(Ted *ted) {
}
}
-static void build_prev_error(Ted *ted) {
+void build_prev_error(Ted *ted) {
if (ted->build_errors) {
ted->build_error += arr_len(ted->build_errors) - 1;
ted->build_error %= arr_len(ted->build_errors);
diff --git a/find.c b/find.c
index 78ec85e..cb50f1a 100644
--- a/find.c
+++ b/find.c
@@ -1,3 +1,5 @@
+#include "ted.h"
+
#define PCRE2_STATIC
#define PCRE2_CODE_UNIT_WIDTH 32
#include <pcre2.h>
@@ -71,7 +73,7 @@ static void find_free_pattern(Ted *ted) {
arr_clear(ted->find_results);
}
-static float find_menu_height(Ted *ted) {
+float find_menu_height(Ted *ted) {
Font *font = ted->font;
float char_height = text_font_char_height(font);
const Settings *settings = ted_active_settings(ted);
@@ -266,7 +268,7 @@ static bool find_replace_match(Ted *ted, u32 match_idx) {
}
// replace the match we are currently highlighting, or do nothing if there is no highlighted match
-static void find_replace(Ted *ted) {
+void find_replace(Ted *ted) {
TextBuffer *buffer = find_search_buffer(ted);
if (!buffer) return;
u32 match_idx = find_match_idx(ted);
@@ -278,18 +280,18 @@ static void find_replace(Ted *ted) {
}
// go to next find result
-static void find_next(Ted *ted) {
+void find_next(Ted *ted) {
if (ted->replace) {
find_replace(ted);
}
find_next_in_direction(ted, +1);
}
-static void find_prev(Ted *ted) {
+void find_prev(Ted *ted) {
find_next_in_direction(ted, -1);
}
-static void find_replace_all(Ted *ted) {
+void find_replace_all(Ted *ted) {
TextBuffer *buffer = find_search_buffer(ted);
if (!buffer) return;
if (ted->replace) {
@@ -315,7 +317,7 @@ static void find_replace_all(Ted *ted) {
}
}
-static void find_menu_frame(Ted *ted, Rect menu_bounds) {
+void find_menu_frame(Ted *ted, Rect menu_bounds) {
Font *font = ted->font, *font_bold = ted->font_bold;
const float char_height = text_font_char_height(font);
@@ -454,7 +456,7 @@ static void find_menu_frame(Ted *ted, Rect menu_bounds) {
}
-static void find_open(Ted *ted, bool replace) {
+void find_open(Ted *ted, bool replace) {
if (ted->menu) return;
if (ted->active_buffer == &ted->build_buffer) return;
if (!ted->find)
@@ -466,7 +468,7 @@ static void find_open(Ted *ted, bool replace) {
find_update(ted, true);
}
-static void find_close(Ted *ted) {
+void find_close(Ted *ted) {
ted->find = false;
ted_switch_to_buffer(ted, find_search_buffer(ted));
find_free_pattern(ted);
diff --git a/main.c b/main.c
index 9c60cab..7bd1415 100644
--- a/main.c
+++ b/main.c
@@ -21,6 +21,7 @@
(make every c file a valid translation unit)
- some way of opening + closing all C files in directory for clangd workspace/symbols to work?
is this still necessary?
+ - maybe it can be done with the clangd config instead.s
- CSS highlighting
- styles ([color] sections)
- more documentation generally (development.md or something?)
diff --git a/ted.h b/ted.h
index 84b161b..382e600 100644
--- a/ted.h
+++ b/ted.h
@@ -742,6 +742,31 @@ void buffer_toggle_comment_selection(TextBuffer *buffer);
// make sure to call gl_geometry_draw after this
void buffer_highlight_lsp_range(TextBuffer *buffer, LSPRange range);
+// === build.c ===
+// clear build errors and stop
+void build_stop(Ted *ted);
+// call before adding anything to the build queue
+void build_queue_start(Ted *ted);
+// add a command to the build queue. call build_queue_start before this.
+void build_queue_command(Ted *ted, const char *command);
+// call this after calling build_queue_start, build_queue_command.
+// make sure you set ted->build_dir before running this!
+void build_queue_finish(Ted *ted);
+// set up the build output buffer.
+void build_setup_buffer(Ted *ted);
+// run a single command in the build window.
+// make sure you set ted->build_dir before running this!
+void build_start_with_command(Ted *ted, const char *command);
+// figure out which build command to run, and run it.
+void build_start(Ted *ted);
+// go to next build error
+void build_next_error(Ted *ted);
+// go to previous build error
+void build_prev_error(Ted *ted);
+// find build errors in build buffer.
+void build_check_for_errors(Ted *ted);
+void build_frame(Ted *ted, float x1, float y1, float x2, float y2);
+
// === colors.c ===
ColorSetting color_setting_from_str(const char *str);
const char *color_setting_to_str(ColorSetting s);
@@ -753,6 +778,18 @@ Command command_from_str(const char *str);
const char *command_to_str(Command c);
void command_execute(Ted *ted, Command c, i64 argument);
+// === find.c ===
+TextBuffer *find_search_buffer(Ted *ted);
+float find_menu_height(Ted *ted);
+void find_update(Ted *ted, bool force);
+void find_replace(Ted *ted);
+void find_next(Ted *ted);
+void find_prev(Ted *ted);
+void find_replace_all(Ted *ted);
+void find_menu_frame(Ted *ted, Rect menu_bounds);
+void find_open(Ted *ted, bool replace);
+void find_close(Ted *ted);
+
// === gl.c ===
GlRcSAB *gl_rc_sab_new(GLuint shader, GLuint array, GLuint buffer);
void gl_rc_sab_incref(GlRcSAB *s);