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