summaryrefslogtreecommitdiff
path: root/nocui/stdin.go
diff options
context:
space:
mode:
Diffstat (limited to 'nocui/stdin.go')
-rw-r--r--nocui/stdin.go79
1 files changed, 36 insertions, 43 deletions
diff --git a/nocui/stdin.go b/nocui/stdin.go
index f7469c6..f003ee4 100644
--- a/nocui/stdin.go
+++ b/nocui/stdin.go
@@ -4,6 +4,7 @@ import (
"os"
"fmt"
"bufio"
+ "runtime/debug"
"strings"
"strconv"
@@ -12,6 +13,15 @@ import (
)
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.DoToolkitPanic()
+ }
+ }()
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
s := scanner.Text()
@@ -19,63 +29,46 @@ func simpleStdin() {
switch s {
case "l":
log.Log(NOW, "list widgets")
- me.rootNode.listWidgets()
+ me.treeRoot.ListWidgets()
case "b":
log.Log(NOW, "show buttons")
- me.rootNode.showButtons()
+ me.treeRoot.ShowButtons()
+ case "g":
+ me.myTree.DoToolkitLoad("gocui")
+ case "a":
+ me.myTree.DoToolkitLoad("andlabs")
case "d":
- var a widget.Action
- a.ActionType = widget.EnableDebug
- callback <- a
+ me.myTree.DoEnableDebugger()
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.rootNode.findWidgetId(i)
+ n := me.treeRoot.FindWidgetId(i)
if (n != nil) {
- n.dumpWidget("found node")
- n.doUserEvent()
+ 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.DoUserEvent(n)
+ case widget.Checkbox:
+ me.myTree.DoUserEvent(n)
+ default:
+ log.Warn("you haven't defined an event for", n.WidgetType)
+ }
}
}
}
}
-
-func (n *node) showButtons() {
- if n.WidgetType == widget.Button {
- n.dumpWidget("Button:")
- }
-
- for _, child := range n.children {
- child.showButtons()
- }
-}
-
-func (n *node) dumpWidget(pad string) {
- log.Log(NOW, "node:", pad, n.WidgetId, ",", n.WidgetType, ",", n.progname)
-}
-
-var depth int = 0
-
-func (n *node) listWidgets() {
- if (n == nil) {
- return
- }
-
- var pad string
- for i := 0; i < depth; i++ {
- pad = pad + " "
- }
- n.dumpWidget(pad)
-
- for _, child := range n.children {
- depth += 1
- child.listWidgets()
- depth -= 1
- }
- return
-}