summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-01 21:47:31 -0600
committerJeff Carr <[email protected]>2024-02-01 21:47:31 -0600
commitdddef229dcab1cd2c5ab7101dc5a4781478c0a62 (patch)
tree1c3944f04f323214f17ab716196a7edd65834308
parent13b0daed7cb950c1244a8e6e42523813178d4c7d (diff)
dropdown & combobox's pop upv0.19.1
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--add.go5
-rw-r--r--click.go2
-rw-r--r--dropdown.go13
-rw-r--r--gocui.go29
-rw-r--r--main.go42
5 files changed, 53 insertions, 38 deletions
diff --git a/add.go b/add.go
index 9a59dc9..ed43ffa 100644
--- a/add.go
+++ b/add.go
@@ -49,6 +49,11 @@ func addWidget(n *tree.Node) {
nw.color = &colorWindow
wRoot := me.treeRoot.TK.(*guiWidget)
wRoot.redoWindows(0, 0)
+ // TODO: record the first window here?
+ // do initial setup of helper widgets here:
+ if me.ddview == nil {
+ me.ddview = makeDropdownView("addWidget() ddview")
+ }
return
case widget.Tab:
nw.color = &colorTab
diff --git a/click.go b/click.go
index e41d3b0..9b1f858 100644
--- a/click.go
+++ b/click.go
@@ -198,9 +198,11 @@ func (w *guiWidget) doWidgetClick() {
log.Log(NOW, "ddItem:", w.String(), i, s)
ddItems += s + "\n"
}
+ /*
if me.ddview == nil {
me.ddview = makeDropdownView(ddItems)
}
+ */
showDropdownItems(ddItems)
me.ddNode = w.node
/*
diff --git a/dropdown.go b/dropdown.go
index 79bf302..a12a929 100644
--- a/dropdown.go
+++ b/dropdown.go
@@ -155,12 +155,13 @@ func showDDview() error {
return nil
}
- /*
- // if there is a drop down view active, treat it like a dialog box and close it
- if (hideDDview() == nil) {
- return nil
- }
- */
+/*
+// if there is a drop down view active, treat it like a dialog box and close it
+
+ if (hideDDview() == nil) {
+ return nil
+ }
+*/
func (w *guiWidget) dropdownClicked(mouseW, mouseH int) {
log.Log(NOW, "dropdownClicked() (w,h) =", mouseW, mouseH)
w.SetVisible(false)
diff --git a/gocui.go b/gocui.go
index dec6d20..05672ec 100644
--- a/gocui.go
+++ b/gocui.go
@@ -12,35 +12,6 @@ import (
"go.wit.com/log"
)
-// This initializes the gocui package
-// it runs SetManagerFunc which passes every input
-// event (keyboard, mouse, etc) to the function "gocuiEvent()"
-func gocuiMain() {
- g, err := gocui.NewGui(gocui.OutputNormal, true)
- if err != nil {
- panic(err)
- }
- defer g.Close()
-
- me.baseGui = g
-
- g.Cursor = true
- g.Mouse = true
-
- // this sets the function that is run on every event. For example:
- // When you click the mouse, move the mouse, or press a key on the keyboard
- // This is equivalent to xev or similar to cat /dev/input on linux
- g.SetManagerFunc(gocuiEvent)
-
- if err := defaultKeybindings(g); err != nil {
- panic(err)
- }
-
- if err := g.MainLoop(); err != nil && !errors.Is(err, gocui.ErrQuit) {
- panic(err)
- }
-}
-
// Thanks to the gocui developers -- your package kicks ass
// This function is called on every event. It is a callback function from the gocui package
// which has an excellent implementation. While gocui handles things like text highlighting
diff --git a/main.go b/main.go
index 1e8f9a8..4d4dde4 100644
--- a/main.go
+++ b/main.go
@@ -5,9 +5,11 @@
package main
import (
+ "errors"
"os"
"runtime/debug"
+ "github.com/awesome-gocui/gocui"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
)
@@ -75,14 +77,19 @@ func mainGogui() {
log.Warn("YAHOOOO Recovered in guiMain application:", r)
log.Warn("Recovered from panic:", r)
me.baseGui.Close()
- log.Sleep(3)
+
+ // allow gocui to close if possible, then print stack
+ log.Sleep(1)
os.Stdout = origStdout
os.Stderr = origStderr
-
me.myTree.SendToolkitPanic()
log.Warn("Stack trace:")
debug.PrintStack()
- panic("BUMMER")
+
+ // attempt to switch to the nocui toolkit
+ log.Sleep(1)
+ me.myTree.SendToolkitLoad("nocui")
+ // panic("BUMMER")
return
}
}()
@@ -106,3 +113,32 @@ func mainGogui() {
os.Stderr = ferr
gocuiMain()
}
+
+// This initializes the gocui package
+// it runs SetManagerFunc which passes every input
+// event (keyboard, mouse, etc) to the function "gocuiEvent()"
+func gocuiMain() {
+ g, err := gocui.NewGui(gocui.OutputNormal, true)
+ if err != nil {
+ panic(err)
+ }
+ defer g.Close()
+
+ me.baseGui = g
+
+ g.Cursor = true
+ g.Mouse = true
+
+ // this sets the function that is run on every event. For example:
+ // When you click the mouse, move the mouse, or press a key on the keyboard
+ // This is equivalent to xev or similar to cat /dev/input on linux
+ g.SetManagerFunc(gocuiEvent)
+
+ if err := defaultKeybindings(g); err != nil {
+ panic(err)
+ }
+
+ if err := g.MainLoop(); err != nil && !errors.Is(err, gocui.ErrQuit) {
+ panic(err)
+ }
+}