summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-02 18:04:08 -0600
committerJeff Carr <[email protected]>2025-03-02 18:04:08 -0600
commitdc329ed18c27c3b7d0467b5fc131438f41ece678 (patch)
treea160c25ce688290b89f244e064ee855071558375
parent3e7287baea931b27770a6d7b33db51b889db50c5 (diff)
can refresh manually
-rw-r--r--eventBindings.go28
-rw-r--r--init.go22
-rw-r--r--structs.go1
3 files changed, 30 insertions, 21 deletions
diff --git a/eventBindings.go b/eventBindings.go
index 05d1442..508daa4 100644
--- a/eventBindings.go
+++ b/eventBindings.go
@@ -78,19 +78,21 @@ func theSuperMouse(g *gocui.Gui, v *gocui.View) error {
// use this to test code ideas // put whatever you want here and hit '2' to activate it
func theNotsure(g *gocui.Gui, v *gocui.View) error {
log.Info("got to theNotsure(). now what? dark =", me.dark)
- if me.debug {
- log.Info("debugging off")
- me.debug = false
- } else {
- log.Info("debugging on")
- me.debug = true
- }
- win := findWindowUnderMouse()
- if win != nil {
- win.dumpWidget("found() win. redrawing window:")
- win.makeWindowActive()
- }
-
+ me.refresh = true
+ /*
+ if me.debug {
+ log.Info("debugging off")
+ me.debug = false
+ } else {
+ log.Info("debugging on")
+ me.debug = true
+ }
+ win := findWindowUnderMouse()
+ if win != nil {
+ win.dumpWidget("found() win. redrawing window:")
+ win.makeWindowActive()
+ }
+ */
return nil
}
diff --git a/init.go b/init.go
index ef29827..ad1c1ee 100644
--- a/init.go
+++ b/init.go
@@ -197,12 +197,6 @@ func main() {
// this hack is to wait for the application to send something
// before trying to do anything. todo: rethink this someday
func waitOK() {
- defer func() {
- if r := recover(); r != nil {
- fmt.Fprintln(outf, "INIT PLUGIN recovered in r", r)
- return
- }
- }()
for {
if me.ok {
return
@@ -238,12 +232,24 @@ func refreshGocui() {
}()
var lastRefresh time.Time
lastRefresh = time.Now()
+ me.refresh = false
for {
time.Sleep(100 * time.Millisecond)
// log.Info("refresh checking ok")
if !me.ok {
continue
}
+
+ // redraw the windows if something has changed
+ if time.Since(lastRefresh) > 1000*time.Millisecond {
+ if me.refresh {
+ log.Info("refresh triggered")
+ me.newWindowTrigger <- me.treeRoot.TK.(*guiWidget)
+ me.refresh = false
+ }
+ }
+
+ // this code updates the clock
if time.Since(lastRefresh) > 1000*time.Millisecond {
// artificially pause clock while dragging.
// this is a reminder to make this refresh code smarter
@@ -289,9 +295,9 @@ func newWindowTrigger() {
select {
case tk := <-me.newWindowTrigger:
// log.Log(NOW, "newWindowTrigger() got new window", tk.cuiName)
- time.Sleep(200 * time.Millisecond)
+ // time.Sleep(200 * time.Millisecond)
waitOK()
- time.Sleep(200 * time.Millisecond)
+ // time.Sleep(200 * time.Millisecond)
redoWindows(me.FirstWindowW, me.FirstWindowH)
me.firstWindowOk = true
if !me.stdout.init {
diff --git a/structs.go b/structs.go
index 425698e..9537b89 100644
--- a/structs.go
+++ b/structs.go
@@ -41,6 +41,7 @@ type config struct {
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
+ refresh bool // redraw everything?
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?)