nicer help menu & stdout behavior
This commit is contained in:
parent
31c130045d
commit
3faacd6c43
|
@ -32,25 +32,23 @@ 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)
|
g.SetKeybinding("", keyForced, modForced, handle_ctrl_z) // CTRL-Z :cleverly let's you background gocui (breaks cursor mouse on return)
|
||||||
|
|
||||||
// regular keys
|
// regular keys
|
||||||
g.SetKeybinding("", '?', gocui.ModNone, theHelp) // '?' toggles on and off the help menu
|
g.SetKeybinding("", 'H', gocui.ModNone, theHelp) // '?' toggles on and off the help menu
|
||||||
g.SetKeybinding("", 'w', gocui.ModNone, doWindow) // 'w' close all windows
|
g.SetKeybinding("", 'O', gocui.ModNone, theStdout) // 'o' toggle the STDOUT window
|
||||||
g.SetKeybinding("", 'r', gocui.ModNone, widgetRefresh) // 'r' screen refresh
|
g.SetKeybinding("", 'q', gocui.ModNone, doExit) // 'q' exit
|
||||||
g.SetKeybinding("", 'q', gocui.ModNone, doExit) // 'q' exit
|
|
||||||
|
|
||||||
// debugging
|
// debugging
|
||||||
g.SetKeybinding("", 'f', gocui.ModNone, theFind) // 'f' shows what is under your mouse
|
g.SetKeybinding("", '2', gocui.ModNone, theNotsure) // '2' use this to test new ideas
|
||||||
g.SetKeybinding("", 'S', gocui.ModNone, setSuperMouse) // 'S' Super Mouse mode!
|
g.SetKeybinding("", 'S', gocui.ModNone, theSuperMouse) // 'S' Super Mouse mode!
|
||||||
g.SetKeybinding("", 'h', gocui.ModNone, theHide) // 'h' hide all widgets
|
|
||||||
g.SetKeybinding("", 'M', gocui.ModNone, printWidgetPlacements) // 'M' list all widgets with positions
|
g.SetKeybinding("", 'M', gocui.ModNone, printWidgetPlacements) // 'M' list all widgets with positions
|
||||||
g.SetKeybinding("", 'L', gocui.ModNone, printWidgetTree) // 'L' list all widgets in tree view
|
g.SetKeybinding("", 'L', gocui.ModNone, printWidgetTree) // 'L' list all widgets in tree view
|
||||||
|
g.SetKeybinding("", 'f', gocui.ModNone, theFind) // 'f' shows what is under your mouse
|
||||||
g.SetKeybinding("", 'd', gocui.ModNone, theLetterD) // 'd' toggles on and off debugging buttons
|
g.SetKeybinding("", 'd', gocui.ModNone, theLetterD) // 'd' toggles on and off debugging buttons
|
||||||
g.SetKeybinding("", '2', gocui.ModNone, theNotsure) // '2' for testing new ideas
|
|
||||||
g.SetKeybinding("", 'q', gocui.ModNone, quit) // 'q' only exits gocui. plugin stays alive (?)
|
g.SetKeybinding("", 'q', gocui.ModNone, quit) // 'q' only exits gocui. plugin stays alive (?)
|
||||||
}
|
}
|
||||||
|
|
||||||
// flips on 'super mouse' mode
|
// flips on 'super mouse' mode // this was awesome for debugging gocui. never remove this code.
|
||||||
// while this is turned on, it will print out every widget found under the mouse
|
// while this is turned on, it will print out every widget found under the mouse
|
||||||
func setSuperMouse(g *gocui.Gui, v *gocui.View) error {
|
func theSuperMouse(g *gocui.Gui, v *gocui.View) error {
|
||||||
if me.supermouse {
|
if me.supermouse {
|
||||||
log.Log(GOCUI, "supermouse off")
|
log.Log(GOCUI, "supermouse off")
|
||||||
me.supermouse = false
|
me.supermouse = false
|
||||||
|
@ -93,18 +91,22 @@ func addDropdown() *tree.Node {
|
||||||
return addDropdownNew(-222)
|
return addDropdownNew(-222)
|
||||||
}
|
}
|
||||||
|
|
||||||
// use this to test code ideas
|
// 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 {
|
func theNotsure(g *gocui.Gui, v *gocui.View) error {
|
||||||
log.Info("got keypress 2. now what?")
|
log.Info("got keypress 2. now what?")
|
||||||
// w, h := g.MousePosition()
|
// w, h := g.MousePosition()
|
||||||
me.newWindowTrigger <- true
|
// me.newWindowTrigger <- true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func theHide(g *gocui.Gui, v *gocui.View) error {
|
func theStdout(g *gocui.Gui, v *gocui.View) error {
|
||||||
var w *guiWidget
|
if me.outputOnTop {
|
||||||
w = me.treeRoot.TK.(*guiWidget)
|
me.outputOnTop = false
|
||||||
w.hideWidgets()
|
me.baseGui.SetViewOnBottom("msg")
|
||||||
|
} else {
|
||||||
|
me.outputOnTop = true
|
||||||
|
me.baseGui.SetViewOnTop("msg")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,16 +175,6 @@ func theHelp(g *gocui.Gui, v *gocui.View) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func widgetRefresh(g *gocui.Gui, v *gocui.View) error {
|
|
||||||
log.Log(GOCUI, "todo: refresh windows here")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func doWindow(g *gocui.Gui, v *gocui.View) error {
|
|
||||||
log.Log(GOCUI, "todo: close all windows here")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: find and give credit to the person that I found this patch in their forked repo
|
// todo: find and give credit to the person that I found this patch in their forked repo
|
||||||
// handle ctrl+z
|
// handle ctrl+z
|
||||||
func handle_ctrl_z(g *gocui.Gui, v *gocui.View) error {
|
func handle_ctrl_z(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
|
|
@ -98,7 +98,7 @@ func (tk *guiWidget) moveNew() {
|
||||||
w, h := me.baseGui.MousePosition()
|
w, h := me.baseGui.MousePosition()
|
||||||
if tk.node.WidgetType == widget.Window {
|
if tk.node.WidgetType == widget.Window {
|
||||||
tk.redrawWindow(w-tk.dragW, h-tk.dragH) // TODO: fix these hard coded things with offsets
|
tk.redrawWindow(w-tk.dragW, h-tk.dragH) // TODO: fix these hard coded things with offsets
|
||||||
helpTop() // sets the help window as the top view
|
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if tk.node.WidgetType == widget.Flag {
|
if tk.node.WidgetType == widget.Flag {
|
||||||
|
@ -141,7 +141,7 @@ func (tk *guiWidget) moveNew() {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
// always place the help menu on top
|
// always place the help menu on top
|
||||||
helpTop() // sets the help window as the top view
|
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
|
||||||
}
|
}
|
||||||
|
|
||||||
func createStdout(g *gocui.Gui) bool {
|
func createStdout(g *gocui.Gui) bool {
|
||||||
|
|
14
help.go
14
help.go
|
@ -25,7 +25,8 @@ import (
|
||||||
|
|
||||||
var helpText []string = []string{"KEYBINDINGS",
|
var helpText []string = []string{"KEYBINDINGS",
|
||||||
"",
|
"",
|
||||||
"?: toggle help",
|
"H: toggle (H)elp",
|
||||||
|
"O: toggle (O)output (os.STDOUT)",
|
||||||
"S: super mouse",
|
"S: super mouse",
|
||||||
"M: list all widgets positions",
|
"M: list all widgets positions",
|
||||||
"L: list all widgets in tree form",
|
"L: list all widgets in tree form",
|
||||||
|
@ -34,7 +35,6 @@ var helpText []string = []string{"KEYBINDINGS",
|
||||||
|
|
||||||
"q: quit()",
|
"q: quit()",
|
||||||
"p: panic()",
|
"p: panic()",
|
||||||
"o: show Stdout",
|
|
||||||
"l: log to /tmp/witgui.log",
|
"l: log to /tmp/witgui.log",
|
||||||
"Ctrl-D: Toggle Debugging",
|
"Ctrl-D: Toggle Debugging",
|
||||||
"Ctrl-V: Toggle Verbose Debugging",
|
"Ctrl-V: Toggle Verbose Debugging",
|
||||||
|
@ -93,10 +93,18 @@ func showHelp() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func helpTop() {
|
// in the very end of redrawing things, this will place the help and stdout on the top or botton
|
||||||
|
// depending on the state the user has chosen
|
||||||
|
func setThingsOnTop() {
|
||||||
if me.showHelp { // terrible variable name. FIXME
|
if me.showHelp { // terrible variable name. FIXME
|
||||||
// log.Info("help is hidden")
|
// log.Info("help is hidden")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
me.baseGui.SetViewOnTop("help")
|
me.baseGui.SetViewOnTop("help")
|
||||||
|
|
||||||
|
if me.outputOnTop {
|
||||||
|
me.baseGui.SetViewOnTop("msg")
|
||||||
|
} else {
|
||||||
|
me.baseGui.SetViewOnBottom("msg")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ type config struct {
|
||||||
startOutputW int // ?
|
startOutputW int // ?
|
||||||
startOutputH int // ?
|
startOutputH int // ?
|
||||||
helpLabel *gocui.View // ?
|
helpLabel *gocui.View // ?
|
||||||
|
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||||
|
outputOnTop bool // is the STDOUT window on top?
|
||||||
// dropdownV *guiWidget // this is a floating widget that we show whenever the user clicks on a
|
// dropdownV *guiWidget // this is a floating widget that we show whenever the user clicks on a
|
||||||
dropdownW *guiWidget // grab the dropdown choices from this widget
|
dropdownW *guiWidget // grab the dropdown choices from this widget
|
||||||
FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||||
|
@ -65,7 +67,6 @@ type config struct {
|
||||||
margin bool // add space around the frames of windows
|
margin bool // add space around the frames of windows
|
||||||
writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe)
|
writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe)
|
||||||
dtoggle bool // is a dropdown or combobox currently active?
|
dtoggle bool // is a dropdown or combobox currently active?
|
||||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
|
||||||
ecount int // counts how many mouse and keyboard events have occurred
|
ecount int // counts how many mouse and keyboard events have occurred
|
||||||
supermouse bool // prints out every widget found while you move the mouse around
|
supermouse bool // prints out every widget found while you move the mouse around
|
||||||
depth int // used for listWidgets() debugging
|
depth int // used for listWidgets() debugging
|
||||||
|
|
Loading…
Reference in New Issue