From 79d709d391f045dcef34d28e1ac0875a73d06d13 Mon Sep 17 00:00:00 2001 From: krzosa Date: Sun, 21 Dec 2025 22:04:39 +0100 Subject: [PATCH] Build on new PC, fix wheel not scrolling --- build.bat | 25 ++++++++++++++++++++----- src/basic/basic_head.h | 1 + src/basic/basic_string.cpp | 2 +- src/basic/basic_string16.cpp | 4 ++-- src/text_editor/event.cpp | 4 ++-- src/text_editor/text_editor.cpp | 7 ++++--- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/build.bat b/build.bat index 5bb2a2b..aa5f8b9 100755 --- a/build.bat +++ b/build.bat @@ -1,14 +1,29 @@ @echo off +if not exist "src\external\SDL" ( + pushd src\external + git clone https://github.com/libsdl-org/SDL.git + pushd SDL + cmake -S . -B build_win32_static -DCMAKE_BUILD_TYPE=Release -DSDL_STATIC=ON + pushd build_win32_static + msbuild SDL3.sln + popd + popd + popd +) +set sdl=..\src\external\SDL +set sdllib=%sdl%\build_win32_static\Debug + mkdir build -cd build +pushd build set flags=/EHsc- /MD /Zi /FC /nologo /WX /W3 /wd4200 /wd4334 /diagnostics:column -DDEBUG_BUILD=1 -set libs=../src/external/SDL/win32-static/SDL3-static.lib ../src/external/SDL/win32-static/SDL_uclibc.lib kernel32.lib gdi32.lib user32.lib Imm32.lib ole32.lib Shell32.lib OleAut32.lib Cfgmgr32.lib Setupapi.lib Advapi32.lib version.lib winmm.lib -cl %flags% ../src/text_editor/text_editor.cpp -Fe:te.exe -I../src/external/SDL/include -I../src/external/lua/src -I../src/external/glad -I../src/ %libs% -link /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRTD +set libs=%sdllib%/SDL3-static.lib %sdllib%/SDL_uclibc.lib kernel32.lib gdi32.lib user32.lib Imm32.lib ole32.lib Shell32.lib OleAut32.lib Cfgmgr32.lib Setupapi.lib Advapi32.lib version.lib winmm.lib +cl %flags% ../src/text_editor/text_editor.cpp -Fe:te.exe -I%sdl%/include -I../src/external/glad -I../src/ %libs% -link /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRTD copy te.exe ..\data\te.exe copy te.pdb ..\data\te.pdb echo written ..\data\te.exe -cd .. -rem /fsanitize=address \ No newline at end of file + +popd +rem /fsanitize=address diff --git a/src/basic/basic_head.h b/src/basic/basic_head.h index c09e3fe..fcb3858 100644 --- a/src/basic/basic_head.h +++ b/src/basic/basic_head.h @@ -7,6 +7,7 @@ #include #include #include +#include #if defined(__APPLE__) && defined(__MACH__) diff --git a/src/basic/basic_string.cpp b/src/basic/basic_string.cpp index 9631224..75113d6 100644 --- a/src/basic/basic_string.cpp +++ b/src/basic/basic_string.cpp @@ -363,4 +363,4 @@ API Int ChopNumber(String *string) { if (col.len == 0) return -1; Int result = strtoll(col.data, NULL, 10) - 1; return result; -} \ No newline at end of file +} diff --git a/src/basic/basic_string16.cpp b/src/basic/basic_string16.cpp index 2bff562..a904582 100644 --- a/src/basic/basic_string16.cpp +++ b/src/basic/basic_string16.cpp @@ -369,7 +369,7 @@ API Int SkipNumber(String16 *string) { if (col.len == 0) return -1; Scratch scratch; String num_string = ToString(scratch, col); - Int result = strtoll(num_string.data, NULL, 10); + Int result = strtoll(num_string.data, NULL, 10); return result; } @@ -416,4 +416,4 @@ API Int ChopNumber(String16 *string) { String num_string = ToString(scratch, col); Int result = strtoll(num_string.data, NULL, 10) - 1; return result; -} \ No newline at end of file +} diff --git a/src/text_editor/event.cpp b/src/text_editor/event.cpp index d1f5b57..cf18acb 100644 --- a/src/text_editor/event.cpp +++ b/src/text_editor/event.cpp @@ -431,8 +431,8 @@ Event TranslateSDLEvent(SDL_Event *input_event) { case SDL_EVENT_MOUSE_WHEEL: { event.kind = EVENT_MOUSE_WHEEL; SDL_MouseWheelEvent &b = input_event->wheel; - event.xmouse = (int16_t)roundf(DPIScale * b.x); - event.ymouse = (int16_t)roundf(DPIScale * b.y); + event.xmouse = (int16_t)roundf(DPIScale * b.mouse_x); + event.ymouse = (int16_t)roundf(DPIScale * b.mouse_y); event.xwheel = b.x; event.ywheel = b.y; } break; diff --git a/src/text_editor/text_editor.cpp b/src/text_editor/text_editor.cpp index 231abd4..3754f83 100644 --- a/src/text_editor/text_editor.cpp +++ b/src/text_editor/text_editor.cpp @@ -178,15 +178,16 @@ void OnCommand(Event event) { if (event.xwheel || event.ywheel) { Vec2I mouse = MouseVec2I(); - For(order) { - if (!it->visible) continue; + For (order) { + if (!it->visible) { + continue; + } bool mouse_in_window = AreOverlapping(mouse, it->total_rect); if (mouse_in_window) { View *view = GetView(it->active_view); view->scroll.y -= (Int)(event.ywheel * 48); view->scroll.x += (Int)(event.xwheel * 48); - break; } } }