diff options
Diffstat (limited to 'eventKeyboard.go')
| -rw-r--r-- | eventKeyboard.go | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/eventKeyboard.go b/eventKeyboard.go new file mode 100644 index 0000000..f8bcf41 --- /dev/null +++ b/eventKeyboard.go @@ -0,0 +1,90 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is (now) governed by the GPL 3.0 + +package main + +import ( + "github.com/awesome-gocui/gocui" +) + +// 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 +} + +// 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 +} |
