From c071730337a45ca2da9db6ba005c16e758383ba9 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 17 Feb 2026 11:48:34 +0000 Subject: [PATCH] now that some things have been optimized I can have it be single threaded But!!!! I have to fix this, the UI needs to be very good! --- tui/internal/controllers/mainc.go | 58 +++++++++++++------------------ tui/internal/views/layoutTool.go | 38 +++++++++----------- 2 files changed, 41 insertions(+), 55 deletions(-) diff --git a/tui/internal/controllers/mainc.go b/tui/internal/controllers/mainc.go index 5128e3e..db16bcd 100644 --- a/tui/internal/controllers/mainc.go +++ b/tui/internal/controllers/mainc.go @@ -46,47 +46,39 @@ func NewMainController(logger *slog.Logger) *MainController { } mc.EvBus.On(ui.RedrawEv{}, func(e any) { - go func() { - mc.App.QueueUpdateDraw(func() {}) - }() + mc.App.QueueUpdateDraw(func() {}) }) mc.EvBus.On(ui.ChangeFocusEv{}, func(e any) { - go func() { - mc.App.SetFocus(e.(ui.ChangeFocusEv).Target) - }() + mc.App.SetFocus(e.(ui.ChangeFocusEv).Target) }) mc.EvBus.On(ui.LogEv{}, func(e any) { - go func() { - mc.EvBus.Emit(ui.PrintLogEv{Log: e.(ui.LogEv).Log}) - }() + mc.EvBus.Emit(ui.PrintLogEv{Log: e.(ui.LogEv).Log}) }) mc.EvBus.On(ui.CreateWindowEv{}, func(e any) { - go func() { - win := e.(ui.CreateWindowEv).Window + win := e.(ui.CreateWindowEv).Window - uiWindow := cdashdisplay.UIWindow{ - Dims: cdashdisplay.UIDimensions{ - X0: win.X, - Y0: win.Y, - Width: win.Width, - Height: win.Height, - }, - Decor: cdashdisplay.DefaultDecorations, - Title: helper.B32(win.Title), - } + uiWindow := cdashdisplay.UIWindow{ + Dims: cdashdisplay.UIDimensions{ + X0: win.X, + Y0: win.Y, + Width: win.Width, + Height: win.Height, + }, + Decor: cdashdisplay.DefaultDecorations, + Title: helper.B32(win.Title), + } - wID, err := mc.CDash.CreateWindow(uiWindow) - if err != nil { - mc.EvBus.Emit(ui.PrintLogEv{Log: "failed to create window\n"}) - return - } + wID, err := mc.CDash.CreateWindow(uiWindow) + if err != nil { + mc.EvBus.Emit(ui.PrintLogEv{Log: "failed to create window\n"}) + return + } - mc.EvBus.Emit(ui.WindowCreatedEv{ID: wID, Win: uiWindow}) - mc.EvBus.Emit(ui.PrintLogEv{Log: "Window created!\n"}) - }() + mc.EvBus.Emit(ui.WindowCreatedEv{ID: wID, Win: uiWindow}) + mc.EvBus.Emit(ui.PrintLogEv{Log: "Window created!\n"}) }) mc.EvBus.On(ui.UpdateWindowEv{}, func(e any) { @@ -112,12 +104,10 @@ func NewMainController(logger *slog.Logger) *MainController { }) mc.EvBus.On(ui.DestroyWindowEv{}, func(e any) { - go func() { - pLogger.Info(fmt.Sprintf("Called in to destroy win: %d", e.(ui.DestroyWindowEv).ID)) - mc.CDash.DestroyWindow(e.(ui.DestroyWindowEv).ID) + pLogger.Info(fmt.Sprintf("Called in to destroy win: %d", e.(ui.DestroyWindowEv).ID)) + mc.CDash.DestroyWindow(e.(ui.DestroyWindowEv).ID) - mc.EvBus.Emit(ui.WindowDestroyedEv{ID: e.(ui.DestroyWindowEv).ID}) - }() + mc.EvBus.Emit(ui.WindowDestroyedEv{ID: e.(ui.DestroyWindowEv).ID}) }) mc.EvBus.On(ui.MoveWindowEv{}, func(e any) { diff --git a/tui/internal/views/layoutTool.go b/tui/internal/views/layoutTool.go index 9e187c1..d729ddc 100644 --- a/tui/internal/views/layoutTool.go +++ b/tui/internal/views/layoutTool.go @@ -85,34 +85,30 @@ func BindWindowEvents( // triggers directly on the UINodes I want them to be triggered on bus.On(ui.WindowCreatedEv{}, func(e any) { - go func() { - ev := e.(ui.WindowCreatedEv) + ev := e.(ui.WindowCreatedEv) - bus.Emit(ui.LogEv{Log: "Received a window created event\n"}) - if tree == nil { - bus.Emit(ui.LogEv{Log: "tree view is nil"}) - return - } + bus.Emit(ui.LogEv{Log: "Received a window created event\n"}) + if tree == nil { + bus.Emit(ui.LogEv{Log: "tree view is nil"}) + return + } - appendWindow(bus, doc, tree, ev.ID, &ev.Win) - }() + appendWindow(bus, doc, tree, ev.ID, &ev.Win) }) bus.On(ui.WindowDestroyedEv{}, func(e any) { - go func() { - root := tree.GetRoot() - if root == nil { - bus.Emit(ui.LogEv{Log: "unable to get current tree node"}) - } + root := tree.GetRoot() + if root == nil { + bus.Emit(ui.LogEv{Log: "unable to get current tree node"}) + } - node := FindNodeByID(root, e.(ui.WindowDestroyedEv).ID) - if node != nil { - root.RemoveChild(node) - } + node := FindNodeByID(root, e.(ui.WindowDestroyedEv).ID) + if node != nil { + root.RemoveChild(node) + } - // NODE: add a log here in case it fails so we know whats going on - bus.Emit(ui.ForceRedraw{}) - }() + // NODE: add a log here in case it fails so we know whats going on + bus.Emit(ui.ForceRedraw{}) }) bus.On(ui.RegisterLoadedLayout{}, func(e any) {