From 58cb7f3d2d8cd102081ba545081f20bf0d6fd211 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 8 Feb 2025 14:24:43 -0600 Subject: [PATCH] still can't remove "msg" create in mouseMove() --- eventBindings.go | 8 -------- eventMouseDrag.go | 11 ----------- help.go | 6 ++++++ stdoutShow.go | 30 ++++++++++++------------------ 4 files changed, 18 insertions(+), 37 deletions(-) diff --git a/eventBindings.go b/eventBindings.go index 29e669c..1c0e6cc 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -5,7 +5,6 @@ package main import ( "syscall" - "time" "github.com/awesome-gocui/gocui" "go.wit.com/log" @@ -72,13 +71,6 @@ 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 keypress 2. now what? dark =", me.dark) - if me.clock.tk == nil { - makeClock() - } else { - me.clock.tk.v.Clear() - me.clock.tk.labelN = time.Now().Format("15:04:05") - me.clock.tk.v.WriteString(me.clock.tk.labelN) - } return nil } diff --git a/eventMouseDrag.go b/eventMouseDrag.go index e976d22..40f608d 100644 --- a/eventMouseDrag.go +++ b/eventMouseDrag.go @@ -172,14 +172,3 @@ func (tk *guiWidget) moveNew() { // always place the help menu on top setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn } - -func createStdout(g *gocui.Gui) bool { - makeOutputWidget(g, "this is a create before a mouse click") - if me.stdout.tk != nil { - msg := fmt.Sprintf("test out gocuiEvent() %d\n", me.ecount) - // me.logStdout.v.Write([]byte(msg)) - me.stdout.tk.Write([]byte(msg)) - log.Log(NOW, "logStdout test out") - } - return true -} diff --git a/help.go b/help.go index 8ae7d7b..067d841 100644 --- a/help.go +++ b/help.go @@ -97,6 +97,12 @@ func showHelp() error { me.clock.tk.Hide() me.clock.tk.Show() } + if me.stdout.tk == nil { + makeOutputWidget(me.baseGui, "made this in showHelp()") + msg := fmt.Sprintf("test to stdout from in showHelp() %d\n", me.ecount) + me.stdout.Write([]byte(msg)) + log.Log(NOW, "log.log(NOW) test") + } return nil } diff --git a/stdoutShow.go b/stdoutShow.go index 5f980bd..e630295 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -15,24 +15,15 @@ import ( "go.wit.com/widget" ) -func showMsg(g *gocui.Gui, v *gocui.View) error { - var l string - var err error - - log.Log(NOW, "showMsg() v.name =", v.Name()) - if _, err := g.SetCurrentView(v.Name()); err != nil { - return err +func createStdout(g *gocui.Gui) bool { + if me.stdout.tk == nil { + makeOutputWidget(g, "this is a create before a mouse click") + msg := fmt.Sprintf("test out gocuiEvent() %d\n", me.ecount) + // me.logStdout.v.Write([]byte(msg)) + me.stdout.tk.Write([]byte(msg)) + log.Log(NOW, "logStdout test out") } - - _, cy := v.Cursor() - if l, err = v.Line(cy); err != nil { - l = "" - } - - outv := makeOutputWidget(g, l) - outv.Write([]byte("test out2")) - log.Info("test out2") - return nil + return true } func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View { @@ -157,10 +148,13 @@ func (w *guiWidget) Write(p []byte) (n int, err error) { me.writeMutex.Lock() defer me.writeMutex.Unlock() - tk := me.stdout.tk lines := strings.Split(strings.TrimSpace(string(p)), "\n") me.stdout.outputS = append(me.stdout.outputS, lines...) + tk := me.stdout.tk + if tk == nil { + return len(p), nil + } if tk.v == nil { // optionally write the output to /tmp s := fmt.Sprint(string(p))