diff --git a/.build/.added_strings_w3.jai b/.build/.added_strings_w3.jai index 0dc2e43..f2eb681 100644 --- a/.build/.added_strings_w3.jai +++ b/.build/.added_strings_w3.jai @@ -6,7 +6,7 @@ NAME :: "mexplore"; VERSION :: "0.1"; JAI_VERSION :: "beta 0.2.016, built on 19 July 2025"; - RELEASE_DATE :: "3 August 2025, 09:51:04"; + RELEASE_DATE :: "6 August 2025, 21:33:37"; GIT_BRANCH :: "main"; - GIT_REVISION :: "e4df2e155175ce56f09148738c333da44455ce7a"; + GIT_REVISION :: "4744f67e2e182828d1a3de921c4a5b6194a2a24d"; DEBUG :: true; diff --git a/.build/mexplore-debug_0_w3.obj b/.build/mexplore-debug_0_w3.obj index 8eb9c51..7e35138 100644 Binary files a/.build/mexplore-debug_0_w3.obj and b/.build/mexplore-debug_0_w3.obj differ diff --git a/.build/mexplore-debug_1_w3.obj b/.build/mexplore-debug_1_w3.obj index ab11050..d0df3c8 100644 Binary files a/.build/mexplore-debug_1_w3.obj and b/.build/mexplore-debug_1_w3.obj differ diff --git a/.build/mexplore-debug_2_w3.obj b/.build/mexplore-debug_2_w3.obj index 87f6fc9..ac7d8f9 100644 Binary files a/.build/mexplore-debug_2_w3.obj and b/.build/mexplore-debug_2_w3.obj differ diff --git a/.build/mexplore-debug_3_w3.obj b/.build/mexplore-debug_3_w3.obj index 05585fb..16a15ef 100644 Binary files a/.build/mexplore-debug_3_w3.obj and b/.build/mexplore-debug_3_w3.obj differ diff --git a/bin/mexplore-debug.exe b/bin/mexplore-debug.exe index 22960cc..afc2649 100644 Binary files a/bin/mexplore-debug.exe and b/bin/mexplore-debug.exe differ diff --git a/bin/mexplore-debug.pdb b/bin/mexplore-debug.pdb index 8a7d42a..3a45e7c 100644 Binary files a/bin/mexplore-debug.pdb and b/bin/mexplore-debug.pdb differ diff --git a/bin/mexplore-debug.rdi b/bin/mexplore-debug.rdi index 8649241..1e3e116 100644 Binary files a/bin/mexplore-debug.rdi and b/bin/mexplore-debug.rdi differ diff --git a/src/main.jai b/src/main.jai index e4b0dc4..126caef 100644 --- a/src/main.jai +++ b/src/main.jai @@ -86,10 +86,44 @@ main :: () { running = false; case SDL_EVENT_KEY_DOWN; - log("%", event.key); if event.key.key == { case SDLK_ESCAPE; running = false; + + case SDLK_LEFT; + transition.left_arrow_down = true; + if event.key.mod == SDL_KMOD_LCTRL { + log("Moving word to the left!"); + transition.char = STB_TEXTEDIT_K_WORDLEFT; + } else { + log("Moving to the left"); + transition.char = STB_TEXTEDIT_K_LEFT; + } + + case SDLK_RIGHT; + transition.right_arrow_down = true; + if event.key.mod == SDL_KMOD_LCTRL { + log("Moving word to the right!"); + transition.char = STB_TEXTEDIT_K_WORDRIGHT; + } else { + log("Moving to the right"); + transition.char = STB_TEXTEDIT_K_RIGHT; + } + + case SDLK_BACKSPACE; + transition.backspace = true; + if event.key.mod == SDL_KMOD_LCTRL { + // log("Moving word to the right!"); + // transition.char = STB_TEXTEDIT_K_WORDRIGHT; + } else { + transition.char = STB_TEXTEDIT_K_BACKSPACE; + } + + case SDLK_LSHIFT; + transition.shift_down = true; + + case SDLK_LCTRL; + transition.control_down = true; case SDLK_RETURN; transition.char = STB_TEXTEDIT_NEWLINE; diff --git a/src/platform/input.jai b/src/platform/input.jai index 572ac57..b6f609e 100644 --- a/src/platform/input.jai +++ b/src/platform/input.jai @@ -14,6 +14,12 @@ InputTransition :: struct { shift_down : bool; shift_up : bool; + left_arrow_down : bool; + + right_arrow_down : bool; + + backspace : bool; + char : s32; } diff --git a/src/stb_textedit.jai b/src/stb_textedit.jai index 421ef26..747a976 100644 --- a/src/stb_textedit.jai +++ b/src/stb_textedit.jai @@ -290,6 +290,7 @@ STB_TEXTEDIT_DELETECHARS :: (obj: *STB_TEXTEDIT_STRING, i: s32, n: s32) { if (i >= obj.text.count) return; // Nothing to remove if (i + n > obj.text.count) n = xx obj.text.count - i; // Trim n if it goes past end memcpy(*obj.text.data[i], *obj.text.data[i + n], obj.text.count - i - n); + array_resize(*obj.text, obj.text.count - n, false); } STB_TEXTEDIT_GETCHAR :: (obj: *STB_TEXTEDIT_STRING, i: s32) -> STB_TEXTEDIT_CHARTYPE { @@ -305,14 +306,15 @@ STB_TEXTEDIT_INSERTCHARS :: (obj: *STB_TEXTEDIT_STRING, i: s32, c: *STB_TEXTEDIT len := obj.text.count; - if n + len > obj.text.allocated { + if n + len > obj.text.count { array_resize(*obj.text, n + len); } // Shift the tail of the string right by n characters if i != len - memcpy(obj.text.data + ((i + n) * size_of(STB_TEXTEDIT_CHARTYPE)), obj.text.data + (i * size_of(STB_TEXTEDIT_CHARTYPE)), (len - i) * size_of(STB_TEXTEDIT_CHARTYPE)); + //memcpy(obj.text.data + ((i + n) * size_of(STB_TEXTEDIT_CHARTYPE)), obj.text.data + (i * size_of(STB_TEXTEDIT_CHARTYPE)), (len - i) * size_of(STB_TEXTEDIT_CHARTYPE)); + memcpy(obj.text.data + ((i + n)), obj.text.data + (i), (len - i) * size_of(STB_TEXTEDIT_CHARTYPE)); //memcpy(obj.text.data + (i * size_of(STB_TEXTEDIT_CHARTYPE)), c, n * size_of(STB_TEXTEDIT_CHARTYPE)); memcpy(obj.text.data + (i), c, n * size_of(STB_TEXTEDIT_CHARTYPE)); @@ -899,7 +901,6 @@ while retry := true { } } } - break retry; // #if #exists(STB_TEXTEDIT_K_INSERT) { // case STB_TEXTEDIT_K_INSERT; @@ -1244,6 +1245,7 @@ while retry := true { state.select_end = state.cursor; state.has_preferred_x = 0; } + break retry; } } diff --git a/src/ui.jai b/src/ui.jai index c850e0d..654f320 100644 --- a/src/ui.jai +++ b/src/ui.jai @@ -1332,10 +1332,14 @@ ui_action :: (rect : *Rect) -> UIAction { for transition : input_transitions { if rect.type == { case .TEXTINPUT; - text_input := cast(*TextInput, rect); - if text_input.active && transition.char > 0 { - stb_textedit_key(text_input, *text_input.textedit_state, transition.char); - } + text_input := cast(*TextInput, rect); + if text_input.active { + if transition.char > 0 { + stb_textedit_key(text_input, *text_input.textedit_state, transition.char); + + text_input.cursor_time = 0.0; + } + } } } diff --git a/ui.rad b/ui.rad index edc21e1..b9947b0 100644 --- a/ui.rad +++ b/ui.rad @@ -1,21 +1,33 @@ // raddbg 0.9.20 project file -recent_file: path: "src/main.jai" -recent_file: path: "src/ui.jai" -recent_file: path: "../../../../jai/modules/math/module.jai" -recent_file: path: "../../../../jai/modules/basic/array.jai" -recent_file: path: "src/text.jai" recent_file: path: "src/stb_textedit.jai" +recent_file: path: "../../../../jai/modules/basic/array.jai" +recent_file: path: "../../../../jai/modules/default_allocator/module.jai" +recent_file: path: "src/ui.jai" +recent_file: path: "src/main.jai" +recent_file: path: "../../../../jai/modules/math/module.jai" +recent_file: path: "src/text.jai" recent_file: path: "modules/kb_text_shape/kb_text_shape.h" recent_file: path: "modules/SDL3/src/SDL-release-3.2.16/src/events/sdl_keyboard.c" recent_file: path: "modules/SDL3/src/SDL-release-3.2.16/src/video/windows/SDL_windowsevents.c" recent_file: path: "src/math/math.jai" recent_file: path: "../../../../jai/modules/runtime_support.jai" recent_file: path: "../../../../jai/modules/basic/module.jai" -recent_file: path: "../../../../jai/modules/default_allocator/module.jai" target: { executable: "bin/mexplore-debug.exe" working_directory: bin enabled: 1 } +breakpoint: +{ + source_location: "src/stb_textedit.jai:1140:1" + hit_count: 0 + enabled: 0 +} +breakpoint: +{ + source_location: "src/stb_textedit.jai:305:1" + hit_count: 0 + enabled: 0 +}