diff --git a/src/platform/render_opengl.cpp b/src/platform/render_opengl.cpp index e97570f..22451de 100644 --- a/src/platform/render_opengl.cpp +++ b/src/platform/render_opengl.cpp @@ -300,7 +300,6 @@ void DrawRect(Rect2I rect, Color color) { } void DrawRectOutline(Rect2I rect, Color color, Int thickness = 2) { - Rect2I a = CutLeft(&rect, thickness); Rect2I b = CutRight(&rect, thickness); Rect2I c = CutTop(&rect, thickness); diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index 1ce158f..a2123aa 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -325,7 +325,11 @@ bool GlobalCommand(Event event) { if (Ctrl(SDLK_GRAVE)) { Window *window = GetWindow(ConsoleWindowID); - ToggleVisibility(window); + if (ToggleVisibility(window)) { + SetActiveWindow(window->id); + } else { + SetActiveWindow(GetLastActiveWindow()); + } } if (CtrlShift(SDLK_BACKSLASH)) { diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index 39d4e92..b78d42a 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -6,18 +6,12 @@ - make the editor replayable, store events and then replay - be careful about globals - - Windows - - Mark windows as absolute or non-automatic layout and then just loop through windows + - search as part of title window? - layouting, resize windows - - column based, choose number of columns and then evenly split - we can adjust sizes using mouse - maybe we can use first line number to use the window? - try to incorporate the acme square which allows you to put windows wherever and also scale the border - - not sure if wouldn't need the infobars for every window then to align things - - is this even practical if we have tab based design? - - this would allow to create new windows just like that to inform user and so on - window borders as flag - - Implement console buffer mimicking vscode with ctrl+~ etc. - Modify error popups to not focus, introduce a interaction timer which after some time will make window invisible - Implement shell interaction in a console buffer diff --git a/src/text_editor/window.cpp b/src/text_editor/window.cpp index 95920ce..2beac70 100644 --- a/src/text_editor/window.cpp +++ b/src/text_editor/window.cpp @@ -96,8 +96,10 @@ void SetVisibility(Window *window, bool v) { } } -void ToggleVisibility(Window *window) { - SetVisibility(window, !window->visible); +bool ToggleVisibility(Window *window) { + bool visible = !window->visible; + SetVisibility(window, visible); + return visible; } void InitWindows(View *null_view) { @@ -213,8 +215,8 @@ void LayoutWindows() { { Window *window = GetWindow(ConsoleWindowID); if (window->visible) { - Vec2I size = GetSize(screen_rect); - Rect2I c = CutBottom(&screen_rect, (Int)((float)size.y * 0.5f)); + Vec2I size = GetSize(screen_rect); + window->total_rect = CutBottom(&screen_rect, (Int)((float)size.y * 0.5f)); Window *title_bar_window = GetWindow(window->title_bar_window); title_bar_window->total_rect = CutBottom(&window->total_rect, GetTitleBarSize(title_bar_window)); @@ -251,9 +253,11 @@ void LayoutWindows() { Window *window = ⁢ if (!window->visible || window->absolute_position || window->is_title_bar) continue; - Window *title_bar_window = GetWindow(window->title_bar_window); - title_bar_window->total_rect = CutBottom(&window->total_rect, GetTitleBarSize(title_bar_window)); - title_bar_window->document_rect = title_bar_window->total_rect; + Window *title_bar_window = GetWindow(window->title_bar_window); + if (title_bar_window) { + title_bar_window->total_rect = CutBottom(&window->total_rect, GetTitleBarSize(title_bar_window)); + title_bar_window->document_rect = title_bar_window->total_rect; + } window->document_rect = window->total_rect; if (window->draw_scrollbar) window->scrollbar_rect = CutRight(&window->document_rect, (Int)ScrollBarSize);