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 /colors.c | |
parent | 4c1c689240f9590f25b18337f2f9897b29d9e27d (diff) |
restructure colors.c
Diffstat (limited to 'colors.c')
-rw-r--r-- | colors.c | 12 |
1 files changed, 7 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; |