From 9c7b139e5ac7c0fbec70a827aab6d0d2b9a030b7 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 6 Feb 2025 04:47:50 -0600 Subject: [PATCH] full screen BG widget is created. good enough to ship it --- eventBindings.go | 8 ++++++-- find.go | 17 +++++++++++++++++ help.go | 19 ++++++++++++++++--- stdoutShow.go | 5 +++-- structs.go | 3 ++- treeAdd.go | 5 +++++ 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/eventBindings.go b/eventBindings.go index 33602ba..600bea0 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -110,12 +110,16 @@ func theStdout(g *gocui.Gui, v *gocui.View) error { me.stdout.outputOffscreen = true log.Info("set stdout on screen here") } + // move the stdout window back onscreen me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH) me.stdout.outputOnTop = false - me.baseGui.SetViewOnBottom("msg") + setThingsOnTop() + // me.baseGui.SetViewOnBottom("msg") + // setBottomBG() } else { me.stdout.outputOnTop = true - me.baseGui.SetViewOnTop("msg") + setThingsOnTop() + // me.baseGui.SetViewOnTop("msg") } return nil } diff --git a/find.go b/find.go index b07f711..274e544 100644 --- a/find.go +++ b/find.go @@ -91,6 +91,23 @@ func (tk *guiWidget) findWindows() []*guiWidget { return found } +// find the BG widget. +// This widget is always in the background and covers the whole screen. +// gocui seems to not return mouse events unless there is something there +func (tk *guiWidget) findBG() *guiWidget { + if tk.node.WidgetType == widget.Stdout { + tk.isBG = true + return tk + } + + for _, child := range tk.children { + if found := child.findBG(); found != nil { + return found + } + } + return nil +} + // returns the "highest priority widget under the mouse func findUnderMouse() *guiWidget { w, h := me.baseGui.MousePosition() diff --git a/help.go b/help.go index ac69f37..a0ac91c 100644 --- a/help.go +++ b/help.go @@ -89,14 +89,27 @@ func showHelp() error { // depending on the state the user has chosen func setThingsOnTop() { if me.showHelp { // terrible variable name. FIXME - // log.Info("help is hidden") - return + // log.Info("help does not exist") + } else { + me.baseGui.SetViewOnTop("help") } - me.baseGui.SetViewOnTop("help") if me.stdout.outputOnTop { me.baseGui.SetViewOnTop("msg") } else { me.baseGui.SetViewOnBottom("msg") } + setBottomBG() +} + +func setBottomBG() { + // this attempts to find the "BG" widget and set it to the background on the very very bottom + rootTK := me.treeRoot.TK.(*guiWidget) + if tk := rootTK.findBG(); tk != nil { + // log.Info("found BG. setting to bottom", tk.cuiName) + tk.v.Clear() + me.baseGui.SetViewOnBottom(tk.cuiName) + w, h := me.baseGui.Size() + me.baseGui.SetView(tk.cuiName, -1, -1, w+1, h+1, 0) + } } diff --git a/stdoutShow.go b/stdoutShow.go index 6d36861..94c7a1f 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -41,7 +41,7 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View { if me.stdout.tk == nil { a := new(widget.Action) - a.ProgName = "stdout" + a.ProgName = "2stdout2" a.WidgetType = widget.Stdout a.WidgetId = -3 a.ParentId = 0 @@ -87,7 +87,8 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View { v.SelBgColor = gocui.ColorCyan v.SelFgColor = gocui.ColorBlack fmt.Fprintln(v, "figure out how to capture STDOUT to here\n"+stringFromMouseClick) - g.SetViewOnBottom("msg") + // g.SetViewOnBottom("msg") + // setBottomBG() me.stdout.tk.v = v me.stdout.tk.DrawAt(me.stdout.lastW, me.stdout.lastH) diff --git a/structs.go b/structs.go index 5539d52..8bf31dd 100644 --- a/structs.go +++ b/structs.go @@ -133,7 +133,8 @@ type guiWidget struct { frame bool // ? selectedTab *tree.Node // for a window, this is currently selected tab color *colorT // what color to use - resize bool + resize bool // the window is currently being resized + isBG bool // means this is the background widget. There is only one of these } // from the gocui devs: diff --git a/treeAdd.go b/treeAdd.go index 66010bb..fba7252 100644 --- a/treeAdd.go +++ b/treeAdd.go @@ -53,6 +53,11 @@ func addWidget(n *tree.Node) { hideHelp() showHelp() return + case widget.Stdout: + nw.labelN = "moreSTDOUT" + n.State.ProgName = "moreSTDOUT" + n.State.Label = "moreSTDOUT" + return case widget.Tab: nw.color = &colorTab return