Fix focus on console buffer and console buffer not drawing

This commit is contained in:
Krzosa Karol
2024-08-02 12:16:08 +02:00
parent 55223b763a
commit 95dc31be91
4 changed files with 17 additions and 16 deletions

View File

@@ -300,7 +300,6 @@ void DrawRect(Rect2I rect, Color color) {
} }
void DrawRectOutline(Rect2I rect, Color color, Int thickness = 2) { void DrawRectOutline(Rect2I rect, Color color, Int thickness = 2) {
Rect2I a = CutLeft(&rect, thickness); Rect2I a = CutLeft(&rect, thickness);
Rect2I b = CutRight(&rect, thickness); Rect2I b = CutRight(&rect, thickness);
Rect2I c = CutTop(&rect, thickness); Rect2I c = CutTop(&rect, thickness);

View File

@@ -325,7 +325,11 @@ bool GlobalCommand(Event event) {
if (Ctrl(SDLK_GRAVE)) { if (Ctrl(SDLK_GRAVE)) {
Window *window = GetWindow(ConsoleWindowID); Window *window = GetWindow(ConsoleWindowID);
ToggleVisibility(window); if (ToggleVisibility(window)) {
SetActiveWindow(window->id);
} else {
SetActiveWindow(GetLastActiveWindow());
}
} }
if (CtrlShift(SDLK_BACKSLASH)) { if (CtrlShift(SDLK_BACKSLASH)) {

View File

@@ -6,18 +6,12 @@
- make the editor replayable, store events and then replay - make the editor replayable, store events and then replay
- be careful about globals - be careful about globals
- Windows - Windows
- Mark windows as absolute or non-automatic layout and then just loop through windows - search as part of title window?
- layouting, resize windows - 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? - 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 - 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 - 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 - 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 - Implement shell interaction in a console buffer

View File

@@ -96,8 +96,10 @@ void SetVisibility(Window *window, bool v) {
} }
} }
void ToggleVisibility(Window *window) { bool ToggleVisibility(Window *window) {
SetVisibility(window, !window->visible); bool visible = !window->visible;
SetVisibility(window, visible);
return visible;
} }
void InitWindows(View *null_view) { void InitWindows(View *null_view) {
@@ -213,8 +215,8 @@ void LayoutWindows() {
{ {
Window *window = GetWindow(ConsoleWindowID); Window *window = GetWindow(ConsoleWindowID);
if (window->visible) { if (window->visible) {
Vec2I size = GetSize(screen_rect); Vec2I size = GetSize(screen_rect);
Rect2I c = CutBottom(&screen_rect, (Int)((float)size.y * 0.5f)); window->total_rect = CutBottom(&screen_rect, (Int)((float)size.y * 0.5f));
Window *title_bar_window = GetWindow(window->title_bar_window); 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->total_rect = CutBottom(&window->total_rect, GetTitleBarSize(title_bar_window));
@@ -251,9 +253,11 @@ void LayoutWindows() {
Window *window = ⁢ Window *window = ⁢
if (!window->visible || window->absolute_position || window->is_title_bar) continue; if (!window->visible || window->absolute_position || window->is_title_bar) continue;
Window *title_bar_window = GetWindow(window->title_bar_window); Window *title_bar_window = GetWindow(window->title_bar_window);
title_bar_window->total_rect = CutBottom(&window->total_rect, GetTitleBarSize(title_bar_window)); if (title_bar_window) {
title_bar_window->document_rect = title_bar_window->total_rect; 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; window->document_rect = window->total_rect;
if (window->draw_scrollbar) window->scrollbar_rect = CutRight(&window->document_rect, (Int)ScrollBarSize); if (window->draw_scrollbar) window->scrollbar_rect = CutRight(&window->document_rect, (Int)ScrollBarSize);