summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-08 12:05:25 -0600
committerJeff Carr <[email protected]>2025-02-08 12:05:25 -0600
commit665d2289e2ce910326cacb2e6b8c35c5e241c279 (patch)
tree01681b2e03c7a68cb122b3fae70e065d99142e1a
parented024aac7025cdf41d2ea6f0c5a83f1694982da1 (diff)
tiggers gocui on startup
-rw-r--r--find.go34
-rw-r--r--init.go47
-rw-r--r--treeAdd.go12
3 files changed, 63 insertions, 30 deletions
diff --git a/find.go b/find.go
index 795f7ee..189d84b 100644
--- a/find.go
+++ b/find.go
@@ -45,25 +45,25 @@ func (r rectType) inRect(w int, h int) bool {
func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
var widgets []*guiWidget
- if !tk.Visible() {
- // ignore widgets that are not visible
- } else {
+ // if !tk.Visible() {
+ // ignore widgets that are not visible
+ // } else {
- // check the location to see if this is under (W,H)
- // if it is, return this widget
- // if (tk.gocuiSize.w0 <= w) && (w <= tk.gocuiSize.w1) &&
- // (tk.gocuiSize.h0 <= h) && (h <= tk.gocuiSize.h1) {
- if tk.gocuiSize.inRect(w, h) {
- widgets = append(widgets, tk)
- } else {
- // if (tk.full.w0 <= w) && (w <= tk.full.w1) &&
- // (tk.full.h0 <= h) && (h <= tk.full.h1) {
- if tk.full.inRect(w, h) {
- widgets = append(widgets, tk)
- }
- // log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
- }
+ // check the location to see if this is under (W,H)
+ // if it is, return this widget
+ // if (tk.gocuiSize.w0 <= w) && (w <= tk.gocuiSize.w1) &&
+ // (tk.gocuiSize.h0 <= h) && (h <= tk.gocuiSize.h1) {
+ // if tk.gocuiSize.inRect(w, h) {
+ // widgets = append(widgets, tk)
+ // } else {
+ // if (tk.full.w0 <= w) && (w <= tk.full.w1) &&
+ // (tk.full.h0 <= h) && (h <= tk.full.h1) {
+ if tk.full.inRect(w, h) {
+ widgets = append(widgets, tk)
}
+ // log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
+ // }
+ // }
// tk.verifyRect()
// search through the children widgets in the binary tree
diff --git a/init.go b/init.go
index 3964ce0..d387d02 100644
--- a/init.go
+++ b/init.go
@@ -56,6 +56,7 @@ func init() {
me.myTree = tree.New()
me.myTree.PluginName = "gocui"
+ go refreshGocui()
if val, err := me.myTree.ConfigFind("dark"); err == nil {
if val == "true" {
@@ -207,6 +208,47 @@ func gocuiMain() {
}
}
+// this hack is to wait for the application to send something
+// before trying to do anything. todo: rethink this someday
+func waitOK() {
+ for {
+ if me.ok {
+ return
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
+}
+
+var lastRefresh time.Time
+
+func testRefresh(*gocui.Gui) error {
+ log.Info("in testRefresh")
+ return nil
+}
+
+func refreshGocui() {
+ lastRefresh = time.Now()
+ for {
+ time.Sleep(10 * time.Millisecond)
+ // log.Info("refresh checking ok")
+ if !me.ok {
+ continue
+ }
+ if time.Since(lastRefresh) > 1*time.Second {
+ if me.mouse.mouseUp {
+ log.Info("refresh now on mouseUp")
+ me.baseGui.Update(testRefresh)
+ } else {
+ log.Info("refresh skip on mouseDown")
+ // me.baseGui.Update()
+ }
+ lastRefresh = time.Now()
+ }
+ }
+}
+
+// set the widget start width & height
+
func newWindowTrigger() {
log.Log(NOW, "newWindowTriggerl() START")
for {
@@ -222,7 +264,10 @@ func newWindowTrigger() {
relocateStdoutOffscreen()
}
tk.makeWindowActive()
- tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
+ // place the new window relative to the mouse
+ tk.redrawWindow(me.mouse.downW+8, me.mouse.downH-2)
+ // tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
+
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
// log.Log(NOW, "newWindowTrigger() after sleep")
}
diff --git a/treeAdd.go b/treeAdd.go
index 9b975ad..35f3514 100644
--- a/treeAdd.go
+++ b/treeAdd.go
@@ -4,8 +4,6 @@
package main
import (
- "time"
-
log "go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
@@ -30,16 +28,6 @@ func setFake(n *tree.Node) {
}
}
-func waitOK() {
- for {
- if me.ok {
- return
- }
- time.Sleep(10 * time.Millisecond)
- }
-}
-
-// set the widget start width & height
// func (n *node) addWidget(n *tree.Node) {
func addWidget(n *tree.Node) {
if !me.ok {