full screen BG widget is created. good enough to ship it

This commit is contained in:
Jeff Carr 2025-02-06 04:47:50 -06:00
parent d3b25092f8
commit 9c7b139e5a
6 changed files with 49 additions and 8 deletions

View File

@ -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
}

17
find.go
View File

@ -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()

19
help.go
View File

@ -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)
}
}

View File

@ -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)

View File

@ -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:

View File

@ -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