76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"runtime/debug"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"go.wit.com/log"
|
|
"go.wit.com/widget"
|
|
)
|
|
|
|
func simpleStdin() {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Warn("nocui YAHOOOO Recovered in simpleStdin()", r)
|
|
log.Println("Recovered from panic:", r)
|
|
log.Println("Stack trace:")
|
|
debug.PrintStack()
|
|
me.myTree.SendToolkitPanic()
|
|
return
|
|
}
|
|
}()
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
for scanner.Scan() {
|
|
s := scanner.Text()
|
|
s = strings.TrimSuffix(s, "\n")
|
|
switch s {
|
|
case "l":
|
|
log.Log(NOW, "list widgets")
|
|
me.treeRoot.ListWidgets()
|
|
case "b":
|
|
log.Log(NOW, "show buttons")
|
|
me.treeRoot.ShowButtons()
|
|
case "g":
|
|
me.myTree.SendToolkitLoad("gocui")
|
|
case "a":
|
|
me.myTree.SendToolkitLoad("andlabs")
|
|
case "d":
|
|
me.myTree.SendEnableDebugger()
|
|
case "":
|
|
fmt.Println("")
|
|
fmt.Println("Enter:")
|
|
fmt.Println("'l': list all widgets")
|
|
fmt.Println("'b': for buttons")
|
|
fmt.Println("'g': load gocui plugin")
|
|
fmt.Println("'a': load andlabs plugin")
|
|
fmt.Println("'d': enable debugging")
|
|
default:
|
|
i, _ := strconv.Atoi(s)
|
|
log.Log(NOW, "got input:", i)
|
|
n := me.treeRoot.FindWidgetId(i)
|
|
if n != nil {
|
|
n.DumpWidget("found node")
|
|
for i, s := range n.State.Strings {
|
|
log.Warn("n.State.Strings =", i, s)
|
|
}
|
|
switch n.WidgetType {
|
|
case widget.Root:
|
|
log.Warn("this is the root widget")
|
|
case widget.Dropdown:
|
|
log.Warn("print out dropdown values here")
|
|
case widget.Button:
|
|
me.myTree.SendUserEvent(n)
|
|
case widget.Checkbox:
|
|
me.myTree.SendUserEvent(n)
|
|
default:
|
|
log.Warn("you haven't defined an event for", n.WidgetType)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|