summaryrefslogtreecommitdiff
path: root/structs.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-28 02:20:31 -0600
committerJeff Carr <[email protected]>2024-01-28 02:20:31 -0600
commit4fbbd2cee13546dbe570509e2c2e0755225a1489 (patch)
tree8e5c8238e0b28b2a03b682789095b5f61b72b3c5 /structs.go
parenta9913b70edec4cf4e5bf51dadebfb64c87085fd6 (diff)
large refactor to use the tree package
Things build and now need to be fixed treeRoot has no children lists all widgets works shows help module loads Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'structs.go')
-rw-r--r--structs.go59
1 files changed, 45 insertions, 14 deletions
diff --git a/structs.go b/structs.go
index e899f78..0599a0c 100644
--- a/structs.go
+++ b/structs.go
@@ -10,13 +10,16 @@ package main
import (
"fmt"
- "github.com/awesome-gocui/gocui"
"reflect"
"strconv"
"strings"
"sync"
+ "github.com/awesome-gocui/gocui"
+
"go.wit.com/log"
+ "go.wit.com/toolkits/tree"
+ "go.wit.com/widget"
)
// It's probably a terrible idea to call this 'me'
@@ -27,19 +30,22 @@ var showHelp bool = true
var redoWidgets bool = true
// This is the window that is currently active
-var currentWindow *node
+var currentWindow *tree.Node
type config struct {
baseGui *gocui.Gui // the main gocui handle
- rootNode *node // the base of the binary tree. it should have id == 0
+ // rootNode *node // the base of the binary tree. it should have id == 0
+
+ treeRoot *tree.Node // the base of the binary tree. it should have id == 0
+ myTree *tree.TreeInfo
- ctrlDown *node // shown if you click the mouse when the ctrl key is pressed
- currentWindow *node // this is the current tab or window to show
- logStdout *node // where to show STDOUT
+ ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
+ currentWindow *tree.Node // this is the current tab or window to show
+ logStdout *tree.Node // where to show STDOUT
helpLabel *gocui.View
- ddview *node // the gocui view to select dropdrown lists
- ddClicked bool // the dropdown menu view was clicked
- ddNode *node // the dropdown menu is for this widget
+ ddview *tree.Node // the gocui view to select dropdrown lists
+ ddClicked bool // the dropdown menu view was clicked
+ ddNode *tree.Node // the dropdown menu is for this widget
/*
// this is the channel we send user events like
@@ -118,9 +124,32 @@ type guiWidget struct {
v *gocui.View // this is nil if the widget is not displayed
cuiName string // what gocui uses to reference the widget
+ WidgetType widget.WidgetType
+
+ // tw *toolkit.Widget
+ parent *guiWidget
+ children []*guiWidget
+
+ node *tree.Node
+
+ hasTabs bool // does the window have tabs?
+ currentTab bool // the visible tab
+
+ value string
+ checked bool
+
// the actual text to display in the console
label string
+ vals []string // dropdown menu items
+
+ AtW int
+ AtH int
+
+ direction widget.Orientation
+
+ progname string
+
// the logical size of the widget
// For example, 40x12 would be the center of a normal terminal
// size rectType
@@ -140,7 +169,7 @@ type guiWidget struct {
frame bool
// for a window, this is currently selected tab
- selectedTab *node
+ selectedTab *tree.Node
// what color to use
color *colorT
@@ -156,7 +185,9 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
w.tainted = true
me.writeMutex.Lock()
defer me.writeMutex.Unlock()
- if me.logStdout.tk.v == nil {
+ var tk *guiWidget
+ tk = me.logStdout.TK.(*guiWidget)
+ if tk.v == nil {
// optionally write the output to /tmp
s := fmt.Sprint(string(p))
s = strings.TrimSuffix(s, "\n")
@@ -164,11 +195,11 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
v, _ := me.baseGui.View("msg")
if v != nil {
// fmt.Fprintln(outf, "found msg")
- me.logStdout.tk.v = v
+ tk.v = v
}
} else {
// display the output in the gocui window
- me.logStdout.tk.v.Clear()
+ tk.v.Clear()
s := fmt.Sprint(string(p))
s = strings.TrimSuffix(s, "\n")
@@ -178,7 +209,7 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
l := len(outputS) - outputH
outputS = outputS[l:]
}
- fmt.Fprintln(me.logStdout.tk.v, strings.Join(outputS, "\n"))
+ fmt.Fprintln(tk.v, strings.Join(outputS, "\n"))
}
return len(p), nil