2025-01-31 08:57:32 -06:00
|
|
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
|
|
// Use of this source code is (now) governed by the GPL 3.0
|
2025-01-31 08:50:00 -06:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2025-01-31 13:00:26 -06:00
|
|
|
"fmt"
|
|
|
|
|
2025-01-31 08:50:00 -06:00
|
|
|
"github.com/awesome-gocui/gocui"
|
2025-01-31 13:00:26 -06:00
|
|
|
log "go.wit.com/log"
|
2025-01-31 08:50:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// tells 'gocui' what to call based on what key was pressed
|
|
|
|
func registerHandlers(g *gocui.Gui) {
|
|
|
|
g.SetKeybinding("", '?', gocui.ModNone, theHelp) // 'h' toggles on and off the help menu
|
|
|
|
g.SetKeybinding("", 'r', gocui.ModNone, widgetRefresh) // screen refresh
|
|
|
|
g.SetKeybinding("", 'w', gocui.ModNone, doWindow) // close all windows
|
|
|
|
g.SetKeybinding("", 'q', gocui.ModNone, doExit) // exit
|
|
|
|
g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, doExit) // exit
|
|
|
|
g.SetKeybinding("", gocui.KeyCtrlV, gocui.ModNone, doPanic) // forced panic
|
|
|
|
|
|
|
|
// debugging
|
|
|
|
g.SetKeybinding("", 'd', gocui.ModNone, theLetterD) // 'd' toggles on and off debugging buttons
|
|
|
|
g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone, openDebuggger) // open the debugger
|
|
|
|
g.SetKeybinding("", 'L', gocui.ModNone, dumpWidgets) // list all widgets
|
|
|
|
g.SetKeybinding("", 'M', gocui.ModNone, dumpWidgetPlacement) // list all widgets with positions
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func doExit(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func doPanic(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func dumpWidgets(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func dumpWidgetPlacement(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func openDebuggger(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2025-01-31 13:00:26 -06:00
|
|
|
func theFind(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
w, h := g.MousePosition()
|
|
|
|
for _, tk := range findByXY(w, h) {
|
|
|
|
log.Log(GOCUI, fmt.Sprintf("findByXY() 'f' key %-8s wId=%4d at (%3d,%3d) %s", tk.WidgetType, tk.node.WidgetId, w, h, tk.node.String()))
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2025-01-31 08:50:00 -06:00
|
|
|
// is run whenever anyone hits 'd' (in an open space)
|
|
|
|
func theLetterD(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
// widgets that don't have physical existance in
|
|
|
|
// a display toolkit are hidden. In the case
|
|
|
|
// of gocui, they are set as not 'visible' and put offscreen
|
|
|
|
// or have the size set to zero
|
|
|
|
// (hopefully anyway) lots of things with the toolkit
|
|
|
|
// still don't work
|
|
|
|
|
|
|
|
fakeStartWidth = me.FakeW
|
|
|
|
fakeStartHeight = me.TabH + me.FramePadH
|
|
|
|
if showDebug {
|
|
|
|
showFake()
|
|
|
|
showDebug = false
|
|
|
|
} else {
|
|
|
|
hideFake()
|
|
|
|
showDebug = true
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func theHelp(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
if showHelp {
|
|
|
|
helplayout()
|
|
|
|
showHelp = false
|
|
|
|
if me.dropdownV == nil {
|
|
|
|
me.dropdownV = makeDropdownView("addWidget() ddview")
|
|
|
|
}
|
|
|
|
me.dropdownV.Show()
|
|
|
|
} else {
|
|
|
|
me.baseGui.DeleteView("help")
|
|
|
|
showHelp = true
|
|
|
|
me.dropdownV.Hide()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func widgetRefresh(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func doWindow(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
return nil
|
|
|
|
}
|