diff options
author | pommicket <pommicket@gmail.com> | 2023-01-01 23:32:54 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-01-01 23:32:54 -0500 |
commit | 4a8dcb2db975a3681ff63518a20ca8afc3137782 (patch) | |
tree | 0dbcb5d3edeb79cab37528045e69856d65956aa2 | |
parent | 4c1c689240f9590f25b18337f2f9897b29d9e27d (diff) |
restructure colors.c
-rw-r--r-- | colors.c | 12 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | ted.h | 5 |
3 files changed, 13 insertions, 5 deletions
@@ -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; @@ -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) @@ -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); |