summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-13 21:04:37 -0600
committerJeff Carr <[email protected]>2025-02-13 21:04:37 -0600
commit1f33979af9d295ab7957dca55db9be5ba19c6324 (patch)
treeae1692fac768a90c878895cedaf06f4833dfc3c8
parent1e79d31a027e3ff7bf68bee2a139df8981db1885 (diff)
add Disable() and Enable()
-rw-r--r--init.go16
-rw-r--r--structs.go1
-rw-r--r--table.go11
-rw-r--r--treeInit.go4
4 files changed, 32 insertions, 0 deletions
diff --git a/init.go b/init.go
index 3a63c0a..4546b72 100644
--- a/init.go
+++ b/init.go
@@ -208,6 +208,17 @@ func waitOK() {
}
}
+// this hack is to wait for the application to send something
+// before trying to do anything. todo: rethink this someday
+func waitFirstWindow() {
+ for {
+ if me.firstWindowOk {
+ return
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
+}
+
// empty function. this triggers gocui to refresh the screen
func testRefresh(*gocui.Gui) error {
// log.Info("in testRefresh")
@@ -279,10 +290,15 @@ func newWindowTrigger() {
waitOK()
time.Sleep(200 * time.Millisecond)
redoWindows(3, 3)
+ me.firstWindowOk = true
if !me.stdout.init {
me.stdout.init = true
relocateStdoutOffscreen()
}
+ if me.textbox.tk == nil {
+ initTextbox()
+ me.textbox.tk.prepTextbox()
+ }
tk.makeWindowActive()
}
}
diff --git a/structs.go b/structs.go
index af5fb41..9df35aa 100644
--- a/structs.go
+++ b/structs.go
@@ -38,6 +38,7 @@ type config struct {
myTree *tree.TreeInfo // ?
currentWindow *guiWidget // this is the current tab or window to show
ok bool // if the user doesn't hit a key or move the mouse, gocui doesn't really start
+ firstWindowOk bool // allows the init to wait for the first window from the application
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
helpLabel *gocui.View // ?
showHelp bool // toggle boolean for the help menu (deprecate?)
diff --git a/table.go b/table.go
index 9e971de..429b4ca 100644
--- a/table.go
+++ b/table.go
@@ -6,8 +6,19 @@ package main
import (
"go.wit.com/lib/protobuf/guipb"
"go.wit.com/log"
+ "go.wit.com/toolkits/tree"
)
func showTable(t *guipb.Table) {
log.Info("should show table here")
}
+
+func enableWidget(n *tree.Node) {
+ tk := n.TK.(*guiWidget)
+ tk.Enable()
+}
+
+func disableWidget(n *tree.Node) {
+ tk := n.TK.(*guiWidget)
+ tk.Disable()
+}
diff --git a/treeInit.go b/treeInit.go
index c51a9fe..78ff4fb 100644
--- a/treeInit.go
+++ b/treeInit.go
@@ -60,6 +60,10 @@ func initTree() *tree.TreeInfo {
t.SetLabel = setLabel
t.SetText = setText
t.AddText = addText
+
+ t.Enable = enableWidget
+ t.Disable = disableWidget
+
t.SetChecked = setChecked
t.ToolkitClose = toolkitClose
t.ShowTable = showTable