diff --git a/src/text_editor/generated_config.cpp b/src/text_editor/generated_config.cpp index 9333f7f..4371d52 100644 --- a/src/text_editor/generated_config.cpp +++ b/src/text_editor/generated_config.cpp @@ -1,4 +1,73 @@ 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.ClangFormatOnSave = false diff --git a/src/text_editor/text_editor.cpp b/src/text_editor/text_editor.cpp index 715fdfe..2bb65f1 100644 --- a/src/text_editor/text_editor.cpp +++ b/src/text_editor/text_editor.cpp @@ -160,26 +160,32 @@ Event TranslateSDLEvent(SDL_Event *input_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) { Scratch scratch; Array order = GetWindowZOrder(scratch); Vec2I mouse = MouseVec2I(); - static SDL_Cursor *SDL_MouseCursor; - if (SDL_MouseCursor) { - SDL_DestroyCursor(SDL_MouseCursor); - SDL_MouseCursor = NULL; - } - if (ResizerSelected) { WindowSplit *split = ResizerSelected; if (split->kind == WindowSplitKind_Vertical) { - SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_EW_RESIZE); - SDL_SetCursor(SDL_MouseCursor); + SetMouseCursor(SDL_SYSTEM_CURSOR_EW_RESIZE); } else { Assert(split->kind == WindowSplitKind_Horizontal); - SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NS_RESIZE); - SDL_SetCursor(SDL_MouseCursor); + SetMouseCursor(SDL_SYSTEM_CURSOR_NS_RESIZE); } return; } @@ -190,12 +196,10 @@ void SetMouseCursor(Event event) { bool mouse_in_scrollbar = AreOverlapping(mouse, it->scrollbar_rect); if (!IsDocumentSelectionValid() && (mouse_in_scrollbar || IsScrollbarSelectionValid())) { - SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); - SDL_SetCursor(SDL_MouseCursor); + SetMouseCursor(SDL_SYSTEM_CURSOR_DEFAULT); return; } else if (mouse_in_total || IsDocumentSelectionValid()) { - SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_TEXT); - SDL_SetCursor(SDL_MouseCursor); + SetMouseCursor(SDL_SYSTEM_CURSOR_TEXT); return; } } @@ -203,18 +207,15 @@ void SetMouseCursor(Event event) { if (ResizerHover) { WindowSplit *split = ResizerHover; if (split->kind == WindowSplitKind_Vertical) { - SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_EW_RESIZE); - SDL_SetCursor(SDL_MouseCursor); + SetMouseCursor(SDL_SYSTEM_CURSOR_EW_RESIZE); } else { Assert(split->kind == WindowSplitKind_Horizontal); - SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NS_RESIZE); - SDL_SetCursor(SDL_MouseCursor); + SetMouseCursor(SDL_SYSTEM_CURSOR_NS_RESIZE); } return; } - SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); - SDL_SetCursor(SDL_MouseCursor); + SetMouseCursor(SDL_SYSTEM_CURSOR_DEFAULT); } void Update(Event event) { diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index 5ce6708..99aaee0 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -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 - - 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? +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 -- DESIGN Prev search change hotkey to Ctrl+Shift instead of Alt+N -- DESIGN Moving vertically between splits, which keys??? -- 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 - - 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 SaveAll dirty files which are saved on disk already but dirty +DESIGN Prev search change hotkey to Ctrl+Shift instead of Alt+N +DESIGN Moving vertically between splits, which keys??? +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 + 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 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 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 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 Ctrl + L or Exec shouldn't involve the last new line! -- FEATURE Search whole words, case sensitive etc. -- 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 +FEATURE Search whole words, case sensitive etc. +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 - Add metaprogram? - PLATFORM Fix windows build