diff options
-rw-r--r-- | base.h | 30 | ||||
-rw-r--r-- | colors.c | 56 | ||||
-rw-r--r-- | colors.h | 60 | ||||
-rw-r--r-- | command.c | 92 | ||||
-rw-r--r-- | command.h | 92 | ||||
-rw-r--r-- | lsp.h | 5 | ||||
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | menu.c | 8 | ||||
-rw-r--r-- | syntax.c | 27 | ||||
-rw-r--r-- | ted.h | 14 | ||||
-rw-r--r-- | text.h | 40 | ||||
-rw-r--r-- | util.c | 1 |
12 files changed, 227 insertions, 204 deletions
@@ -200,32 +200,4 @@ typedef enum { LANG_COUNT } Language; -typedef struct { - Language lang; - char const *name; -} LanguageName; - -static LanguageName const language_names[] = { - {LANG_NONE, "None"}, - {LANG_C, "C"}, - {LANG_CPP, "C++"}, - {LANG_RUST, "Rust"}, - {LANG_PYTHON, "Python"}, - {LANG_TEX, "Tex"}, - {LANG_MARKDOWN, "Markdown"}, - {LANG_HTML, "HTML"}, - {LANG_CONFIG, "Config"}, - {LANG_JAVASCRIPT, "JavaScript"}, - {LANG_JAVA, "Java"}, - {LANG_GO, "Go"}, - {LANG_TED_CFG, "TedCfg"}, - {LANG_TYPESCRIPT, "TypeScript"}, - {LANG_JSON, "JSON"}, - {LANG_XML, "XML"}, - {LANG_GLSL, "GLSL"}, -}; - -static_assert_if_possible(arr_count(language_names) == LANG_COUNT) - - -#endif +#endif // BASE_H_ @@ -1,3 +1,59 @@ +typedef struct { + ColorSetting setting; + char const *name; +} ColorName; + +static ColorName const color_names[] = { + {COLOR_UNKNOWN, "unknown"}, + {COLOR_TEXT, "text"}, + {COLOR_TEXT_SECONDARY, "text-secondary"}, + {COLOR_BG, "bg"}, + {COLOR_HL, "hl"}, + {COLOR_CURSOR, "cursor"}, + {COLOR_CURSOR_ERROR, "cursor-error"}, + {COLOR_CURSOR_LINE_BG, "cursor-line-bg"}, + {COLOR_VIEW_ONLY_CURSOR, "view-only-cursor"}, + {COLOR_VIEW_ONLY_SELECTION_BG, "view-only-selection-bg"}, + {COLOR_MATCHING_BRACKET_HL, "matching-bracket-hl"}, + {COLOR_BORDER, "border"}, + {COLOR_TEXT_FOLDER, "text-folder"}, + {COLOR_TEXT_OTHER, "text-other"}, + {COLOR_SELECTION_BG, "selection-bg"}, + {COLOR_MENU_BACKDROP, "menu-backdrop"}, + {COLOR_MENU_BG, "menu-bg"}, + {COLOR_MENU_HL, "menu-hl"}, + {COLOR_ERROR_TEXT, "error-text"}, + {COLOR_ERROR_BG, "error-bg"}, + {COLOR_ERROR_BORDER, "error-border"}, + {COLOR_ACTIVE_TAB_HL, "active-tab-hl"}, + {COLOR_SELECTED_TAB_HL, "selected-tab-hl"}, + {COLOR_FIND_HL, "find-hl"}, + {COLOR_KEYWORD, "keyword"}, + {COLOR_BUILTIN, "builtin"}, + {COLOR_COMMENT, "comment"}, + {COLOR_PREPROCESSOR, "preprocessor"}, + {COLOR_STRING, "string"}, + {COLOR_CHARACTER, "character"}, + {COLOR_CONSTANT, "constant"}, + {COLOR_AUTOCOMPLETE_BG, "autocomplete-bg"}, + {COLOR_AUTOCOMPLETE_HL, "autocomplete-hl"}, + {COLOR_AUTOCOMPLETE_BORDER, "autocomplete-border"}, + {COLOR_AUTOCOMPLETE_VARIABLE, "autocomplete-variable"}, + {COLOR_AUTOCOMPLETE_FUNCTION, "autocomplete-function"}, + {COLOR_AUTOCOMPLETE_TYPE, "autocomplete-type"}, + {COLOR_HOVER_BORDER, "hover-border"}, + {COLOR_HOVER_BG, "hover-bg"}, + {COLOR_HOVER_TEXT, "hover-text"}, + {COLOR_HOVER_HL, "hover-hl"}, + {COLOR_YES, "yes"}, + {COLOR_NO, "no"}, + {COLOR_CANCEL, "cancel"}, + {COLOR_LINE_NUMBERS, "line-numbers"}, + {COLOR_CURSOR_LINE_NUMBER, "cursor-line-number"}, + {COLOR_LINE_NUMBERS_SEPARATOR, "line-numbers-separator"}, +}; + +static_assert_if_possible(arr_count(color_names) == COLOR_COUNT) static ColorSetting color_setting_from_str(char const *str) { // @OPTIMIZE: sort color_names, binary search @@ -1,3 +1,6 @@ +#ifndef COLORS_H_ +#define COLORS_H_ + typedef enum { COLOR_UNKNOWN, @@ -57,59 +60,4 @@ typedef enum { COLOR_COUNT } ColorSetting; -typedef struct { - ColorSetting setting; - char const *name; -} ColorName; - -static ColorName const color_names[] = { - {COLOR_UNKNOWN, "unknown"}, - {COLOR_TEXT, "text"}, - {COLOR_TEXT_SECONDARY, "text-secondary"}, - {COLOR_BG, "bg"}, - {COLOR_HL, "hl"}, - {COLOR_CURSOR, "cursor"}, - {COLOR_CURSOR_ERROR, "cursor-error"}, - {COLOR_CURSOR_LINE_BG, "cursor-line-bg"}, - {COLOR_VIEW_ONLY_CURSOR, "view-only-cursor"}, - {COLOR_VIEW_ONLY_SELECTION_BG, "view-only-selection-bg"}, - {COLOR_MATCHING_BRACKET_HL, "matching-bracket-hl"}, - {COLOR_BORDER, "border"}, - {COLOR_TEXT_FOLDER, "text-folder"}, - {COLOR_TEXT_OTHER, "text-other"}, - {COLOR_SELECTION_BG, "selection-bg"}, - {COLOR_MENU_BACKDROP, "menu-backdrop"}, - {COLOR_MENU_BG, "menu-bg"}, - {COLOR_MENU_HL, "menu-hl"}, - {COLOR_ERROR_TEXT, "error-text"}, - {COLOR_ERROR_BG, "error-bg"}, - {COLOR_ERROR_BORDER, "error-border"}, - {COLOR_ACTIVE_TAB_HL, "active-tab-hl"}, - {COLOR_SELECTED_TAB_HL, "selected-tab-hl"}, - {COLOR_FIND_HL, "find-hl"}, - {COLOR_KEYWORD, "keyword"}, - {COLOR_BUILTIN, "builtin"}, - {COLOR_COMMENT, "comment"}, - {COLOR_PREPROCESSOR, "preprocessor"}, - {COLOR_STRING, "string"}, - {COLOR_CHARACTER, "character"}, - {COLOR_CONSTANT, "constant"}, - {COLOR_AUTOCOMPLETE_BG, "autocomplete-bg"}, - {COLOR_AUTOCOMPLETE_HL, "autocomplete-hl"}, - {COLOR_AUTOCOMPLETE_BORDER, "autocomplete-border"}, - {COLOR_AUTOCOMPLETE_VARIABLE, "autocomplete-variable"}, - {COLOR_AUTOCOMPLETE_FUNCTION, "autocomplete-function"}, - {COLOR_AUTOCOMPLETE_TYPE, "autocomplete-type"}, - {COLOR_HOVER_BORDER, "hover-border"}, - {COLOR_HOVER_BG, "hover-bg"}, - {COLOR_HOVER_TEXT, "hover-text"}, - {COLOR_HOVER_HL, "hover-hl"}, - {COLOR_YES, "yes"}, - {COLOR_NO, "no"}, - {COLOR_CANCEL, "cancel"}, - {COLOR_LINE_NUMBERS, "line-numbers"}, - {COLOR_CURSOR_LINE_NUMBER, "cursor-line-number"}, - {COLOR_LINE_NUMBERS_SEPARATOR, "line-numbers-separator"}, -}; - -static_assert_if_possible(arr_count(color_names) == COLOR_COUNT) +#endif // COLORS_H_ @@ -1,3 +1,92 @@ +typedef struct { + char const *name; + Command cmd; +} CommandName; +static CommandName const command_names[] = { + {"unknown", CMD_UNKNOWN}, + {"noop", CMD_NOOP}, + {"left", CMD_LEFT}, + {"right", CMD_RIGHT}, + {"up", CMD_UP}, + {"down", CMD_DOWN}, + {"select-left", CMD_SELECT_LEFT}, + {"select-right", CMD_SELECT_RIGHT}, + {"select-up", CMD_SELECT_UP}, + {"select-down", CMD_SELECT_DOWN}, + {"left-word", CMD_LEFT_WORD}, + {"right-word", CMD_RIGHT_WORD}, + {"select-left-word", CMD_SELECT_LEFT_WORD}, + {"select-right-word", CMD_SELECT_RIGHT_WORD}, + {"start-of-line", CMD_START_OF_LINE}, + {"end-of-line", CMD_END_OF_LINE}, + {"select-start-of-line", CMD_SELECT_START_OF_LINE}, + {"select-end-of-line", CMD_SELECT_END_OF_LINE}, + {"start-of-file", CMD_START_OF_FILE}, + {"end-of-file", CMD_END_OF_FILE}, + {"select-start-of-file", CMD_SELECT_START_OF_FILE}, + {"select-end-of-file", CMD_SELECT_END_OF_FILE}, + {"select-page-up", CMD_SELECT_PAGE_UP}, + {"select-page-down", CMD_SELECT_PAGE_DOWN}, + {"select-all", CMD_SELECT_ALL}, + {"page-up", CMD_PAGE_UP}, + {"page-down", CMD_PAGE_DOWN}, + {"tab", CMD_TAB}, + {"backtab", CMD_BACKTAB}, + {"insert-text", CMD_INSERT_TEXT}, + {"newline", CMD_NEWLINE}, + {"newline-back", CMD_NEWLINE_BACK}, + {"comment-selection", CMD_COMMENT_SELECTION}, + {"backspace", CMD_BACKSPACE}, + {"delete", CMD_DELETE}, + {"backspace-word", CMD_BACKSPACE_WORD}, + {"delete-word", CMD_DELETE_WORD}, + {"open", CMD_OPEN}, + {"new", CMD_NEW}, + {"save", CMD_SAVE}, + {"save-as", CMD_SAVE_AS}, + {"save-all", CMD_SAVE_ALL}, + {"reload-all", CMD_RELOAD_ALL}, + {"quit", CMD_QUIT}, + {"set-language", CMD_SET_LANGUAGE}, + {"command-selector", CMD_COMMAND_SELECTOR}, + {"open-config", CMD_OPEN_CONFIG}, + {"undo", CMD_UNDO}, + {"redo", CMD_REDO}, + {"copy", CMD_COPY}, + {"cut", CMD_CUT}, + {"paste", CMD_PASTE}, + {"autocomplete", CMD_AUTOCOMPLETE}, + {"autocomplete-back", CMD_AUTOCOMPLETE_BACK}, + {"find-usages", CMD_FIND_USAGES}, + {"goto-definition", CMD_GOTO_DEFINITION}, + {"goto-definition-at-cursor", CMD_GOTO_DEFINITION_AT_CURSOR}, + {"find", CMD_FIND}, + {"find-replace", CMD_FIND_REPLACE}, + {"tab-close", CMD_TAB_CLOSE}, + {"tab-switch", CMD_TAB_SWITCH}, + {"tab-next", CMD_TAB_NEXT}, + {"tab-prev", CMD_TAB_PREV}, + {"tab-move-left", CMD_TAB_MOVE_LEFT}, + {"tab-move-right", CMD_TAB_MOVE_RIGHT}, + {"increase-text-size", CMD_TEXT_SIZE_INCREASE}, + {"decrease-text-size", CMD_TEXT_SIZE_DECREASE}, + {"view-only", CMD_VIEW_ONLY}, + {"build", CMD_BUILD}, + {"build-prev-error", CMD_BUILD_PREV_ERROR}, + {"build-next-error", CMD_BUILD_NEXT_ERROR}, + {"shell", CMD_SHELL}, + {"generate-tags", CMD_GENERATE_TAGS}, + {"goto-line", CMD_GOTO_LINE}, + {"split-horizontal", CMD_SPLIT_HORIZONTAL}, + {"split-vertical", CMD_SPLIT_VERTICAL}, + {"split-join", CMD_SPLIT_JOIN}, + {"split-switch", CMD_SPLIT_SWITCH}, + {"split-swap", CMD_SPLIT_SWAP}, + {"escape", CMD_ESCAPE}, +}; + +static_assert_if_possible(arr_count(command_names) == CMD_COUNT) + Command command_from_str(char const *str) { // @OPTIMIZE: sort command_names, do a binary search for (int i = 0; i < CMD_COUNT; ++i) { @@ -7,8 +96,7 @@ Command command_from_str(char const *str) { return CMD_UNKNOWN; } -// Returns string representation of command -char const *command_to_str(Command c) { +const char *command_to_str(Command c) { // NOTE: this probably won't need to be optimized. for (int i = 0; i < CMD_COUNT; ++i) { if (command_names[i].cmd == c) @@ -1,3 +1,6 @@ +#ifndef COMMAND_H_ +#define COMMAND_H_ + // i | ARG_STRING = ted->strings[i] #define ARG_STRING 0x4000000000000000 @@ -104,92 +107,5 @@ ENUM_U16 { CMD_COUNT } ENUM_U16_END(Command); -typedef struct { - char const *name; - Command cmd; -} CommandName; -static CommandName const command_names[] = { - {"unknown", CMD_UNKNOWN}, - {"noop", CMD_NOOP}, - {"left", CMD_LEFT}, - {"right", CMD_RIGHT}, - {"up", CMD_UP}, - {"down", CMD_DOWN}, - {"select-left", CMD_SELECT_LEFT}, - {"select-right", CMD_SELECT_RIGHT}, - {"select-up", CMD_SELECT_UP}, - {"select-down", CMD_SELECT_DOWN}, - {"left-word", CMD_LEFT_WORD}, - {"right-word", CMD_RIGHT_WORD}, - {"select-left-word", CMD_SELECT_LEFT_WORD}, - {"select-right-word", CMD_SELECT_RIGHT_WORD}, - {"start-of-line", CMD_START_OF_LINE}, - {"end-of-line", CMD_END_OF_LINE}, - {"select-start-of-line", CMD_SELECT_START_OF_LINE}, - {"select-end-of-line", CMD_SELECT_END_OF_LINE}, - {"start-of-file", CMD_START_OF_FILE}, - {"end-of-file", CMD_END_OF_FILE}, - {"select-start-of-file", CMD_SELECT_START_OF_FILE}, - {"select-end-of-file", CMD_SELECT_END_OF_FILE}, - {"select-page-up", CMD_SELECT_PAGE_UP}, - {"select-page-down", CMD_SELECT_PAGE_DOWN}, - {"select-all", CMD_SELECT_ALL}, - {"page-up", CMD_PAGE_UP}, - {"page-down", CMD_PAGE_DOWN}, - {"tab", CMD_TAB}, - {"backtab", CMD_BACKTAB}, - {"insert-text", CMD_INSERT_TEXT}, - {"newline", CMD_NEWLINE}, - {"newline-back", CMD_NEWLINE_BACK}, - {"comment-selection", CMD_COMMENT_SELECTION}, - {"backspace", CMD_BACKSPACE}, - {"delete", CMD_DELETE}, - {"backspace-word", CMD_BACKSPACE_WORD}, - {"delete-word", CMD_DELETE_WORD}, - {"open", CMD_OPEN}, - {"new", CMD_NEW}, - {"save", CMD_SAVE}, - {"save-as", CMD_SAVE_AS}, - {"save-all", CMD_SAVE_ALL}, - {"reload-all", CMD_RELOAD_ALL}, - {"quit", CMD_QUIT}, - {"set-language", CMD_SET_LANGUAGE}, - {"command-selector", CMD_COMMAND_SELECTOR}, - {"open-config", CMD_OPEN_CONFIG}, - {"undo", CMD_UNDO}, - {"redo", CMD_REDO}, - {"copy", CMD_COPY}, - {"cut", CMD_CUT}, - {"paste", CMD_PASTE}, - {"autocomplete", CMD_AUTOCOMPLETE}, - {"autocomplete-back", CMD_AUTOCOMPLETE_BACK}, - {"find-usages", CMD_FIND_USAGES}, - {"goto-definition", CMD_GOTO_DEFINITION}, - {"goto-definition-at-cursor", CMD_GOTO_DEFINITION_AT_CURSOR}, - {"find", CMD_FIND}, - {"find-replace", CMD_FIND_REPLACE}, - {"tab-close", CMD_TAB_CLOSE}, - {"tab-switch", CMD_TAB_SWITCH}, - {"tab-next", CMD_TAB_NEXT}, - {"tab-prev", CMD_TAB_PREV}, - {"tab-move-left", CMD_TAB_MOVE_LEFT}, - {"tab-move-right", CMD_TAB_MOVE_RIGHT}, - {"increase-text-size", CMD_TEXT_SIZE_INCREASE}, - {"decrease-text-size", CMD_TEXT_SIZE_DECREASE}, - {"view-only", CMD_VIEW_ONLY}, - {"build", CMD_BUILD}, - {"build-prev-error", CMD_BUILD_PREV_ERROR}, - {"build-next-error", CMD_BUILD_NEXT_ERROR}, - {"shell", CMD_SHELL}, - {"generate-tags", CMD_GENERATE_TAGS}, - {"goto-line", CMD_GOTO_LINE}, - {"split-horizontal", CMD_SPLIT_HORIZONTAL}, - {"split-vertical", CMD_SPLIT_VERTICAL}, - {"split-join", CMD_SPLIT_JOIN}, - {"split-switch", CMD_SPLIT_SWITCH}, - {"split-swap", CMD_SPLIT_SWAP}, - {"escape", CMD_ESCAPE}, -}; - -static_assert_if_possible(arr_count(command_names) == CMD_COUNT) +#endif @@ -1,3 +1,6 @@ +#ifndef LSP_H_ +#define LSP_H_ + typedef u32 LSPDocumentID; typedef u32 LSPID; typedef u32 LSPRequestID; @@ -566,3 +569,5 @@ bool lsp_document_position_eq(LSPDocumentPosition a, LSPDocumentPosition b); LSPDocumentPosition lsp_location_start_position(LSPLocation location); LSPDocumentPosition lsp_location_end_position(LSPLocation location); void lsp_free(LSP *lsp); + +#endif // LSP_H_ @@ -46,6 +46,7 @@ FUTURE FEATURES: */ #include "base.h" +#include "unicode.h" no_warn_start #if _WIN32 #include <SDL.h> @@ -81,7 +82,6 @@ no_warn_start no_warn_end #endif -#include "unicode.h" #include "ds.c" #include "util.c" @@ -120,11 +120,7 @@ static void die(char const *fmt, ...) { #include "io.c" -#include "text.h" -#include "command.h" -#include "colors.h" #include "time.c" -#include "lsp.h" #include "ted.h" #include "gl.c" #include "text.c" @@ -265,13 +265,13 @@ static void menu_update(Ted *ted) { } break; case MENU_COMMAND_SELECTOR: { Selector *selector = &ted->command_selector; - SelectorEntry *entries = selector->entries = calloc(arr_count(command_names), sizeof *selector->entries); + SelectorEntry *entries = selector->entries = calloc(CMD_COUNT, sizeof *selector->entries); char *search_term = str32_to_utf8_cstr(buffer_get_line(line_buffer, 0)); if (entries) { SelectorEntry *entry = entries; - for (size_t i = 0; i < arr_count(command_names); ++i) { - char const *name = command_names[i].name; - if (command_names[i].cmd != CMD_UNKNOWN && stristr(name, search_term)) { + for (Command c = 0; c < CMD_COUNT; ++c) { + char const *name = command_to_str(c); + if (c != CMD_UNKNOWN && *name && stristr(name, search_term)) { entry->name = name; entry->color = colors[COLOR_TEXT]; ++entry; @@ -3,6 +3,33 @@ // all characters that can appear in a number #define SYNTAX_DIGITS "0123456789.xXoObBlLuUiIabcdefABCDEF_" +typedef struct { + Language lang; + char const *name; +} LanguageName; + +static const LanguageName language_names[] = { + {LANG_NONE, "None"}, + {LANG_C, "C"}, + {LANG_CPP, "C++"}, + {LANG_RUST, "Rust"}, + {LANG_PYTHON, "Python"}, + {LANG_TEX, "Tex"}, + {LANG_MARKDOWN, "Markdown"}, + {LANG_HTML, "HTML"}, + {LANG_CONFIG, "Config"}, + {LANG_JAVASCRIPT, "JavaScript"}, + {LANG_JAVA, "Java"}, + {LANG_GO, "Go"}, + {LANG_TED_CFG, "TedCfg"}, + {LANG_TYPESCRIPT, "TypeScript"}, + {LANG_JSON, "JSON"}, + {LANG_XML, "XML"}, + {LANG_GLSL, "GLSL"}, +}; + +static_assert_if_possible(arr_count(language_names) == LANG_COUNT) + // returns the language this string is referring to, or LANG_NONE if it's invalid. Language language_from_str(char const *str) { @@ -1,3 +1,12 @@ +#ifndef TED_H_ +#define TED_H_ + +#include "lsp.h" +#include "base.h" +#include "text.h" +#include "colors.h" +#include "command.h" + #define TED_VERSION "2.0" #define TED_VERSION_FULL "ted v. " TED_VERSION #define TED_PATH_MAX 256 @@ -578,6 +587,9 @@ typedef struct Ted { } Ted; char *buffer_contents_utf8_alloc(TextBuffer *buffer); Command command_from_str(char const *str); +const char *command_to_str(Command command); +// Returns string representation of command +const char *command_to_str(Command c); void command_execute(Ted *ted, Command c, i64 argument); void ted_switch_to_buffer(Ted *ted, TextBuffer *buffer); // the settings of the active buffer, or the default settings if there is no active buffer @@ -620,3 +632,5 @@ void definitions_selector_open(Ted *ted); void definitions_selector_update(Ted *ted); void definitions_selector_render(Ted *ted, Rect bounds); void definitions_selector_close(Ted *ted); + +#endif @@ -5,9 +5,9 @@ // Example usage: // Font *font = text_font_load("font.ttf", 18); // if (font) { -// text_utf8(font, "Hello", 5, 5, 0xFF0000FF); -// text_utf8(font, "Goodbye", 5, 100, 0x00FF00FF); -// text_render(font); +// text_utf8(font, "Hello", 5, 5, 0xFF0000FF); +// text_utf8(font, "Goodbye", 5, 100, 0x00FF00FF); +// text_render(font); // } @@ -41,37 +41,37 @@ typedef enum { ANCHOR_BOTTOM_RIGHT, } Anchor; -extern bool text_has_err(void); +bool text_has_err(void); // Get the current error. Errors will NOT be overwritten with newer errors. -extern char const *text_get_err(void); +char const *text_get_err(void); // Clear the current error. -extern void text_clear_err(void); +void text_clear_err(void); // Load a TTF font found in ttf_filename with the given font size (character pixel height) -extern Font *text_font_load(char const *ttf_filename, float font_size); +Font *text_font_load(char const *ttf_filename, float font_size); // Height of a character of this font in pixels. -extern float text_font_char_height(Font *font); +float text_font_char_height(Font *font); // Width of the character 'a' of this font in pixels. // This is meant to be only used for monospace fonts. -extern float text_font_char_width(Font *font); +float text_font_char_width(Font *font); // Force text to advance by text_font_char_width(font) pixels per character (actually, per code point). -extern void text_font_set_force_monospace(Font *font, bool force); +void text_font_set_force_monospace(Font *font, bool force); // Get the dimensions of some text. -extern void text_get_size(Font *font, char const *text, float *width, float *height); -extern v2 text_get_size_v2(Font *font, char const *text); -extern void text_get_size32(Font *font, char32_t const *text, u64 len, float *width, float *height); -extern void text_utf8(Font *font, char const *text, double x, double y, u32 color); -extern void text_utf8_anchored(Font *font, char const *text, double x, double y, u32 color, Anchor anchor); -extern void text_char_with_state(Font *font, TextRenderState *state, char32_t c); -extern void text_utf8_with_state(Font *font, TextRenderState *state, char const *str); +void text_get_size(Font *font, char const *text, float *width, float *height); +v2 text_get_size_v2(Font *font, char const *text); +void text_get_size32(Font *font, char32_t const *text, u64 len, float *width, float *height); +void text_utf8(Font *font, char const *text, double x, double y, u32 color); +void text_utf8_anchored(Font *font, char const *text, double x, double y, u32 color, Anchor anchor); +void text_char_with_state(Font *font, TextRenderState *state, char32_t c); +void text_utf8_with_state(Font *font, TextRenderState *state, char const *str); // Free memory used by font. -extern void text_font_free(Font *font); -extern void text_render(Font *font); +void text_font_free(Font *font); +void text_render(Font *font); // The "default" text rendering state - everything you need to just render text normally. // This lets you do stuff like: // TextRenderState state = text_render_state_default; // (set a few options) // text_render_with_state(font, &state, ...) -extern TextRenderState const text_render_state_default; +const TextRenderState text_render_state_default; #endif @@ -7,6 +7,7 @@ #error "Unrecognized operating system." #endif +#include "base.h" // Is this character a "word" character? static bool is_word(char32_t c) { |