Fix cursor stutter

This commit is contained in:
2025-08-19 09:18:40 +02:00
parent 0dc020c429
commit ad3e58d455
3 changed files with 104 additions and 36 deletions

View File

@@ -1,4 +1,73 @@
String BaseLuaConfig = R"==( String BaseLuaConfig = R"==(
local GruvboxDark0Hard = 0x1d2021ff
local GruvboxDark0 = 0x282828ff
local GruvboxDark0Soft = 0x32302fff
local GruvboxDark1 = 0x3c3836ff
local GruvboxDark2 = 0x504945ff
local GruvboxDark3 = 0x665c54ff
local GruvboxDark4 = 0x7c6f64ff
local GruvboxGray245 = 0x928374ff
local GruvboxGray244 = 0x928374ff
local GruvboxLight0Hard = 0xf9f5d7ff
local GruvboxLight0 = 0xfbf1c7ff
local GruvboxLight0Soft = 0xf2e5bcff
local GruvboxLight1 = 0xebdbb2ff
local GruvboxLight2 = 0xd5c4a1ff
local GruvboxLight3 = 0xbdae93ff
local GruvboxLight4 = 0xa89984ff
local GruvboxBrightRed = 0xfb4934ff
local GruvboxBrightGreen = 0xb8bb26ff
local GruvboxBrightYellow = 0xfabd2fff
local GruvboxBrightBlue = 0x83a598ff
local GruvboxBrightPurple = 0xd3869bff
local GruvboxBrightAqua = 0x8ec07cff
local GruvboxBrightOrange = 0xfe8019ff
local GruvboxNeutralRed = 0xcc241dff
local GruvboxNeutralGreen = 0x98971aff
local GruvboxNeutralYellow = 0xd79921ff
local GruvboxNeutralBlue = 0x458588ff
local GruvboxNeutralPurple = 0xb16286ff
local GruvboxNeutralAqua = 0x689d6aff
local GruvboxNeutralOrange = 0xd65d0eff
local GruvboxFadedRed = 0x9d0006ff
local GruvboxFadedGreen = 0x79740eff
local GruvboxFadedYellow = 0xb57614ff
local GruvboxFadedBlue = 0x076678ff
local GruvboxFadedPurple = 0x8f3f71ff
local GruvboxFadedAqua = 0x427b58ff
local GruvboxFadedOrange = 0xaf3a03ff
Color = {}
Color.Text = GruvboxDark0Hard
Color.LoadTextHighlight = 0x0000000F
Color.Background = GruvboxLight0Hard
Color.InactiveWindow = 0x0000000F
Color.TextLineNumbers = GruvboxDark4
Color.LineHighlight = GruvboxLight0Soft
Color.MainCaret = GruvboxDark0Hard
Color.SubCaret = GruvboxGray245
Color.Selection = GruvboxLight1
Color.WhitespaceDuringSelection = GruvboxLight4
Color.MouseUnderline = GruvboxDark0Hard
Color.CaretUnderline = GruvboxGray245
Color.FuzzySearchLineHighlight = GruvboxDark0
Color.ScrollbarBackground = GruvboxLight2
Color.ScrollbarScroller = GruvboxLight1
Color.ScrollbarScrollerSelected = GruvboxLight0Hard
Color.TitleBarText = GruvboxDark2
Color.TitleBarBackground = GruvboxLight1
Color.TitleBarActiveBackground = 0xfefefefe
Color.TitleBarSelection = GruvboxLight3
Color.ResizerBackground = GruvboxLight0Hard
Color.ResizerOutline = GruvboxLight3
Style = {}
Style.WaitForEvents = 1
Style.DrawLineNumbers = 1
Style.DrawScrollbar = 1
Style.IndentSize = 4
Style.FontSize = 15
Style.FontFilter = 0
Style.Font = GetExeDir().."/CascadiaMono.ttf"
Style.VCVarsall = "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"
Style.TrimWhitespaceOnSave = true Style.TrimWhitespaceOnSave = true
Style.ClangFormatOnSave = false Style.ClangFormatOnSave = false

View File

@@ -160,26 +160,32 @@ Event TranslateSDLEvent(SDL_Event *input_event) {
return event; return event;
} }
void SetMouseCursor(SDL_SystemCursor id) {
static SDL_Cursor *SDL_MouseCursor;
static SDL_SystemCursor last_id;
if (SDL_MouseCursor == NULL || last_id != id) {
if (SDL_MouseCursor != NULL) {
SDL_DestroyCursor(SDL_MouseCursor);
}
SDL_MouseCursor = SDL_CreateSystemCursor(id);
SDL_SetCursor(SDL_MouseCursor);
last_id = id;
}
}
void SetMouseCursor(Event event) { void SetMouseCursor(Event event) {
Scratch scratch; Scratch scratch;
Array<Window *> order = GetWindowZOrder(scratch); Array<Window *> order = GetWindowZOrder(scratch);
Vec2I mouse = MouseVec2I(); Vec2I mouse = MouseVec2I();
static SDL_Cursor *SDL_MouseCursor;
if (SDL_MouseCursor) {
SDL_DestroyCursor(SDL_MouseCursor);
SDL_MouseCursor = NULL;
}
if (ResizerSelected) { if (ResizerSelected) {
WindowSplit *split = ResizerSelected; WindowSplit *split = ResizerSelected;
if (split->kind == WindowSplitKind_Vertical) { if (split->kind == WindowSplitKind_Vertical) {
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_EW_RESIZE); SetMouseCursor(SDL_SYSTEM_CURSOR_EW_RESIZE);
SDL_SetCursor(SDL_MouseCursor);
} else { } else {
Assert(split->kind == WindowSplitKind_Horizontal); Assert(split->kind == WindowSplitKind_Horizontal);
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NS_RESIZE); SetMouseCursor(SDL_SYSTEM_CURSOR_NS_RESIZE);
SDL_SetCursor(SDL_MouseCursor);
} }
return; return;
} }
@@ -190,12 +196,10 @@ void SetMouseCursor(Event event) {
bool mouse_in_scrollbar = AreOverlapping(mouse, it->scrollbar_rect); bool mouse_in_scrollbar = AreOverlapping(mouse, it->scrollbar_rect);
if (!IsDocumentSelectionValid() && (mouse_in_scrollbar || IsScrollbarSelectionValid())) { if (!IsDocumentSelectionValid() && (mouse_in_scrollbar || IsScrollbarSelectionValid())) {
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); SetMouseCursor(SDL_SYSTEM_CURSOR_DEFAULT);
SDL_SetCursor(SDL_MouseCursor);
return; return;
} else if (mouse_in_total || IsDocumentSelectionValid()) { } else if (mouse_in_total || IsDocumentSelectionValid()) {
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_TEXT); SetMouseCursor(SDL_SYSTEM_CURSOR_TEXT);
SDL_SetCursor(SDL_MouseCursor);
return; return;
} }
} }
@@ -203,18 +207,15 @@ void SetMouseCursor(Event event) {
if (ResizerHover) { if (ResizerHover) {
WindowSplit *split = ResizerHover; WindowSplit *split = ResizerHover;
if (split->kind == WindowSplitKind_Vertical) { if (split->kind == WindowSplitKind_Vertical) {
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_EW_RESIZE); SetMouseCursor(SDL_SYSTEM_CURSOR_EW_RESIZE);
SDL_SetCursor(SDL_MouseCursor);
} else { } else {
Assert(split->kind == WindowSplitKind_Horizontal); Assert(split->kind == WindowSplitKind_Horizontal);
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NS_RESIZE); SetMouseCursor(SDL_SYSTEM_CURSOR_NS_RESIZE);
SDL_SetCursor(SDL_MouseCursor);
} }
return; return;
} }
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); SetMouseCursor(SDL_SYSTEM_CURSOR_DEFAULT);
SDL_SetCursor(SDL_MouseCursor);
} }
void Update(Event event) { void Update(Event event) {

View File

@@ -1,23 +1,21 @@
-- DESIGN We want a better workflow, one init.lua that would be applied automatically and then baked into the executable also DESIGN Config file versions, when loading should be checked, at the top of the file, what to do when old version?
- How to decrease build complexity? Should the variables be used maybe better to do the lookup?
- DESIGN Config file versions, when loading should be checked, at the top of the file, what to do when old version?
BUILD Collapse the separate unit (unix, win32) into single build BUILD Collapse the separate unit (unix, win32) into single build
- DESIGN Prev search change hotkey to Ctrl+Shift instead of Alt+N DESIGN Prev search change hotkey to Ctrl+Shift instead of Alt+N
- DESIGN Moving vertically between splits, which keys??? DESIGN Moving vertically between splits, which keys???
- DESIGN Console, console write should be preprended with new line not appended DESIGN Console, console write should be preprended with new line not appended
- DESIGN The cursor hopping history needs a bit of fixing, probably needs to be more complicated with collapsing commands etc. not sure DESIGN The cursor hopping history needs a bit of fixing, probably needs to be more complicated with collapsing commands etc. not sure
- OR maybe make it only for buffer history, and shouldnt care about cursor history that much OR maybe make it only for buffer history, and shouldnt care about cursor history that much
- FEATURE KillConsole, or maybe some window targetting but how?? FEATURE KillConsole, or maybe some window targetting but how??
- FEATURE SaveAll dirty files which are saved on disk already but dirty FEATURE SaveAll dirty files which are saved on disk already but dirty
- ISSUE Cursor changes every frame and it causes stutter on screen NOT GOOD! ISSUE Cursor changes every frame and it causes stutter on screen NOT GOOD!
- ISSUE I hit a case where GC tried deleting a buffer which was not attached to the buffer list, it had zeroed next, prev. It happened after iterating through directories using the ctrl + period ISSUE I hit a case where GC tried deleting a buffer which was not attached to the buffer list, it had zeroed next, prev. It happened after iterating through directories using the ctrl + period
- ISSUE Ctrl + L or Exec shouldn't involve the last new line! ISSUE Ctrl + L or Exec shouldn't involve the last new line!
- FEATURE Search whole words, case sensitive etc. FEATURE Search whole words, case sensitive etc.
- FEATURE Select all searched occurences FEATURE Select all searched occurences
- DESIGN Indicate maybe on the console border that a process is running in the console! also maybe exit code when exits DESIGN Indicate maybe on the console border that a process is running in the console! also maybe exit code when exits
- Add metaprogram? - Add metaprogram?
- PLATFORM Fix windows build - PLATFORM Fix windows build