summaryrefslogtreecommitdiff
path: root/eventBindings.go
diff options
context:
space:
mode:
Diffstat (limited to 'eventBindings.go')
-rw-r--r--eventBindings.go61
1 files changed, 54 insertions, 7 deletions
diff --git a/eventBindings.go b/eventBindings.go
index 183a21d..26348e5 100644
--- a/eventBindings.go
+++ b/eventBindings.go
@@ -32,13 +32,12 @@ func registerHandlers(g *gocui.Gui) {
g.SetKeybinding("", keyForced, modForced, handle_ctrl_z) // CTRL-Z :cleverly let's you background gocui (breaks cursor mouse on return)
// regular keys
- g.SetKeybinding("", 'H', gocui.ModNone, theHelp) // '?' toggles on and off the help menu
- g.SetKeybinding("", 'O', gocui.ModNone, theStdout) // 'o' toggle the STDOUT window
- g.SetKeybinding("", 'q', gocui.ModNone, doExit) // 'q' exit
+ g.SetKeybinding("", 'H', gocui.ModNone, theHelp) // '?' toggles on and off the help menu
+ g.SetKeybinding("", 'O', gocui.ModNone, theStdout) // 'o' toggle the STDOUT window
+ g.SetKeybinding("", 'q', gocui.ModNone, doExit) // 'q' exit
+ g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, tabCycleWindows) // '2' use this to test new ideas
// debugging
- g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, theNotsure) // '2' use this to test new ideas
- g.SetKeybinding("", gocui.KeyTab, gocui.ModShift, theNotsure) // '2' use this to test new ideas
g.SetKeybinding("", '2', gocui.ModNone, theNotsure) // '2' use this to test new ideas
g.SetKeybinding("", 'S', gocui.ModNone, theSuperMouse) // 'S' Super Mouse mode!
g.SetKeybinding("", 'M', gocui.ModNone, printWidgetPlacements) // 'M' list all widgets with positions
@@ -93,12 +92,60 @@ func addDropdown() *tree.Node {
return addDropdownNew(-222)
}
+func findNextWindow() *guiWidget {
+ var found bool
+ if len(me.allwin) == 0 {
+ return nil
+ }
+ for _, win := range me.allwin {
+ if win.activeWindow {
+ found = true
+ win.activeWindow = false
+ continue
+ }
+ if found {
+ win.activeWindow = true
+ return win
+ }
+ }
+ me.allwin[0].activeWindow = true
+ // at the end, loop to the beginning
+ return me.allwin[0]
+}
+
// use this to test code ideas // put whatever you want here and hit '2' to activate it
func theNotsure(g *gocui.Gui, v *gocui.View) error {
log.Info("got keypress 2. now what?")
log.Info("try to switch windows here")
- // w, h := g.MousePosition()
- // me.newWindowTrigger <- true
+ if len(me.allwin) != len(findWindows()) {
+ me.allwin = findWindows()
+ }
+ newwin := findNextWindow()
+ for i, win := range me.allwin {
+ log.Info("Window", i, "named", win.labelN, win.activeWindow)
+ }
+ if newwin == nil {
+ log.Info("findNextWindow() err. returned nil")
+ return nil
+ }
+ newwin.doWidgetClick(newwin.gocuiSize.w0, newwin.gocuiSize.h0)
+ return nil
+}
+
+func tabCycleWindows(g *gocui.Gui, v *gocui.View) error {
+ log.Info("try to switch windows here")
+ if len(me.allwin) != len(findWindows()) {
+ me.allwin = findWindows()
+ }
+ newwin := findNextWindow()
+ for i, win := range me.allwin {
+ log.Info("Window", i, "named", win.labelN, win.activeWindow)
+ }
+ if newwin == nil {
+ log.Info("findNextWindow() err. returned nil")
+ return nil
+ }
+ newwin.doWidgetClick(newwin.gocuiSize.w0, newwin.gocuiSize.h0)
return nil
}