diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/resources/resources.c | 5 | ||||
| -rw-r--r-- | src/resources/resources.h | 1 | ||||
| -rw-r--r-- | src/scenes/puzzleScene.c | 6 | ||||
| -rw-r--r-- | src/ui_elements/TextEditor.c | 8 | ||||
| -rw-r--r-- | src/ui_elements/UI.h | 1 |
5 files changed, 18 insertions, 3 deletions
diff --git a/src/resources/resources.c b/src/resources/resources.c index b8a292e..e82b6e0 100644 --- a/src/resources/resources.c +++ b/src/resources/resources.c @@ -3,12 +3,15 @@ #include <raylib.h> Font MainFont; +Font MonoFont; void LoadResources() { - MainFont = LoadFontEx("assets/coolvetica.ttf", 100, NULL, 0); + MainFont = LoadFontEx("assets/fonts/coolvetica.ttf", 100, NULL, 0); + MonoFont = LoadFontEx("assets/fonts/monofont.ttf", 100, NULL, 0); } Font *GetMainFont() { return &MainFont; } +Font *GetMonoFont() { return &MonoFont; } void DrawStripe(int start_step, int end_step, Color color) { int height = GetScreenHeight(); diff --git a/src/resources/resources.h b/src/resources/resources.h index c53da99..e6efc25 100644 --- a/src/resources/resources.h +++ b/src/resources/resources.h @@ -18,5 +18,6 @@ static const Color COLORSCHEME_WHITE = { 233, 225, 185, 255 }; void LoadResources(); Font *GetMainFont(); +Font *GetMonoFont(); #endif // RESOURCES_H diff --git a/src/scenes/puzzleScene.c b/src/scenes/puzzleScene.c index 8824a09..d49b530 100644 --- a/src/scenes/puzzleScene.c +++ b/src/scenes/puzzleScene.c @@ -67,6 +67,10 @@ bool drawPuzzleScene(void *self) { DrawPuzzleName(data->PuzzlePtr->Name); Rectangle body = GetBodyRect(); + DrawRecBordered(body, WHITE, COLORSCHEME_ORANGE, BORDER); + DrawTextArea(data->EditorInfo, body, GetMonoFont(), 20, 2, &data->editor_scroll); + return true; + Rectangle pane1, pane2; GetPanesSplit(&pane1, &pane2, body, 0.5, 0.4); DrawRecBordered(pane1, WHITE, COLORSCHEME_ORANGE, BORDER); @@ -74,7 +78,7 @@ bool drawPuzzleScene(void *self) { DrawTextInRec(pane1, data->PuzzlePtr->Description, GetMainFont(), 20, COLORSCHEME_BROWN, 3, &data->scroll); - DrawTextArea(data->EditorInfo, pane2, GetMainFont(), 20, 2, &data->editor_scroll); + DrawTextArea(data->EditorInfo, pane2, GetMonoFont(), 20, 2, &data->editor_scroll); return true; } diff --git a/src/ui_elements/TextEditor.c b/src/ui_elements/TextEditor.c index ebc8671..fa85443 100644 --- a/src/ui_elements/TextEditor.c +++ b/src/ui_elements/TextEditor.c @@ -68,11 +68,13 @@ bool AddSpaceDetermined(TextNode *base, size_t additional_space) { void AppendTextToNode(TextNode *base, char *new_text) { if (base == NULL || new_text == NULL) return; size_t len = strlen(base->text); + size_t new_len = strlen(new_text); /// >= and not > because it needs a \0 - if (len + strlen(new_text) >= base->cap) { + if (len + new_len >= base->cap) { if (!AddSpace(base)) return; } strcpy(base->text + len, new_text); + base->len += new_len; } TextArea *CreateTextArea() { @@ -367,6 +369,10 @@ void HandleKeyboard(TextArea *ta) { if (IsKeyPressedFix(KEY_RIGHT)) MoveCursorRight(ta); if (IsKeyPressedFix(KEY_DOWN)) MoveCursorDown(ta); if (IsKeyPressedFix(KEY_UP)) MoveCursorUp(ta); + if (IsKeyPressedFix(KEY_TAB)) { + for (int i = 0; i < TAB_WIDTH; i++) + InsertChar(ta, ' '); + }; if (IsKeyPressedFix(KEY_HOME)) MoveCursorHome(ta); if (IsKeyPressedFix(KEY_END)) MoveCursorEnd(ta); diff --git a/src/ui_elements/UI.h b/src/ui_elements/UI.h index 779290f..eaf17e8 100644 --- a/src/ui_elements/UI.h +++ b/src/ui_elements/UI.h @@ -5,6 +5,7 @@ #define UI_ELEMENTS_H static const float SCROLL_SENC = 10; +static const float TAB_WIDTH = 4; void DrawRecBordered(Rectangle rec, Color bg, Color border_color, int border_width); void DrawTextInRec(Rectangle rec, char *text, Font *font, int height, Color color, float padding, int *scroll); |
