trying stuff that isn't working

This commit is contained in:
Jeff Carr 2025-02-01 17:58:13 -06:00
parent 9a3f9d0991
commit 5a2097d080
3 changed files with 38 additions and 1 deletions

View File

@ -61,9 +61,33 @@ func setSuperMouse(g *gocui.Gui, v *gocui.View) error {
return nil
}
var wtf bool
// use this to test code ideas
func theNotsure(g *gocui.Gui, v *gocui.View) error {
log.Info("got keypress 2. now what?")
// closes anything under your mouse
w, h := g.MousePosition()
for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Stdout {
tk.dumpWidget("theNotsure() DrawAt STDOUT")
tk.DrawAt(10, 10)
if wtf {
log.Log(GOCUI, "set visible false")
tk.deleteView()
// tk.SetVisible(false)
wtf = false
} else {
log.Log(GOCUI, "set visible true")
tk.drawView()
// tk.SetVisible(true)
wtf = true
}
continue
}
}
/* closes anything under your mouse
w, h := g.MousePosition()
for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Stdout {
@ -73,6 +97,7 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
tk.dumpWidget("theNotsure() HIDDING")
tk.Hide()
}
*/
return nil
}

View File

@ -38,7 +38,6 @@ func mouseMove(g *gocui.Gui) {
// don't move this code out of here
for _, tk := range findByXY(w, h) {
if tk.node.WidgetType == widget.Stdout {
// moveMsg(g)
tk.moveNew(g)
return
}

View File

@ -97,6 +97,9 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
case widget.Box:
tk.placeBox(startW, startH)
return 0, 0
case widget.Stdout:
tk.setStdoutWH(startW, startH)
return tk.gocuiSize.Width(), tk.gocuiSize.Height()
case widget.Group:
// move the group to the parent's next location
tk.gocuiSetWH(startW, startH)
@ -265,3 +268,13 @@ func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + 1
}
}
func (tk *guiWidget) setStdoutWH(sizeW, sizeH int) {
w := 120
h := 40
tk.gocuiSize.w0 = sizeW
tk.gocuiSize.h0 = sizeH
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h
}