From 55ef21312888cbfb9d449eee8f7958b74f85ac7c Mon Sep 17 00:00:00 2001 From: Physick <96335032+DegustatorPonos@users.noreply.github.com> Date: Fri, 10 Jul 2026 00:02:55 +0500 Subject: more work on an editor --- src/ui_elements/TextEditor.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/ui_elements/TextEditor.c') 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); -- cgit v1.3