summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-01 23:32:54 -0500
committerpommicket <pommicket@gmail.com>2023-01-01 23:32:54 -0500
commit4a8dcb2db975a3681ff63518a20ca8afc3137782 (patch)
tree0dbcb5d3edeb79cab37528045e69856d65956aa2
parent4c1c689240f9590f25b18337f2f9897b29d9e27d (diff)
restructure colors.c
-rw-r--r--colors.c12
-rw-r--r--main.c1
-rw-r--r--ted.h5
3 files changed, 13 insertions, 5 deletions
diff --git a/colors.c b/colors.c
index a6c72c6..bc46d52 100644
--- a/colors.c
+++ b/colors.c
@@ -1,6 +1,8 @@
+#include "ted.h"
+
typedef struct {
ColorSetting setting;
- char const *name;
+ const char *name;
} ColorName;
static ColorName const color_names[] = {
@@ -55,7 +57,7 @@ static ColorName const color_names[] = {
static_assert_if_possible(arr_count(color_names) == COLOR_COUNT)
-static ColorSetting color_setting_from_str(char const *str) {
+ColorSetting color_setting_from_str(const char *str) {
// @OPTIMIZE: sort color_names, binary search
for (int i = 0; i < COLOR_COUNT; ++i) {
ColorName const *n = &color_names[i];
@@ -65,7 +67,7 @@ static ColorSetting color_setting_from_str(char const *str) {
return COLOR_UNKNOWN;
}
-static char const *color_setting_to_str(ColorSetting s) {
+const char *color_setting_to_str(ColorSetting s) {
for (int i = 0; i < COLOR_COUNT; ++i) {
ColorName const *n = &color_names[i];
if (n->setting == s)
@@ -75,7 +77,7 @@ static char const *color_setting_to_str(ColorSetting s) {
}
// converts #rrggbb/#rrggbbaa to a color. returns false if it's not in the right format.
-static Status color_from_str(char const *str, u32 *color) {
+Status color_from_str(const char *str, u32 *color) {
uint r = 0, g = 0, b = 0, a = 0xff;
bool success = false;
switch (strlen(str)) {
@@ -108,7 +110,7 @@ static Status color_from_str(char const *str, u32 *color) {
}
-static ColorSetting color_for_symbol_kind(SymbolKind kind) {
+ColorSetting color_for_symbol_kind(SymbolKind kind) {
switch (kind) {
case SYMBOL_CONSTANT:
return COLOR_CONSTANT;
diff --git a/main.c b/main.c
index bbe7aea..87c22fe 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,6 @@
/*
@TODO:
+- change @OPTIM(IZE) to @TODO
- rename v[234] to vec[234]
- handle multiple symbols with same name in go-to-definition menu
- better non-error window/showMessage(Request)
diff --git a/ted.h b/ted.h
index 662c588..f649bff 100644
--- a/ted.h
+++ b/ted.h
@@ -592,6 +592,11 @@ typedef struct Ted {
char error_shown[512]; // error display in box on screen
} Ted;
+// === colors.c ===
+ColorSetting color_setting_from_str(char const *str);
+const char *color_setting_to_str(ColorSetting s);
+Status color_from_str(const char *str, u32 *color);
+ColorSetting color_for_symbol_kind(SymbolKind kind);
// === gl.c ===
GlRcSAB *gl_rc_sab_new(GLuint shader, GLuint array, GLuint buffer);
void gl_rc_sab_incref(GlRcSAB *s);