still can't remove "msg" create in mouseMove()

This commit is contained in:
Jeff Carr 2025-02-08 14:24:43 -06:00
parent 53eb14ccbd
commit 58cb7f3d2d
4 changed files with 18 additions and 37 deletions

View File

@ -5,7 +5,6 @@ package main
import ( import (
"syscall" "syscall"
"time"
"github.com/awesome-gocui/gocui" "github.com/awesome-gocui/gocui"
"go.wit.com/log" "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 // 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 { func theNotsure(g *gocui.Gui, v *gocui.View) error {
log.Info("got keypress 2. now what? dark =", me.dark) 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 return nil
} }

View File

@ -172,14 +172,3 @@ func (tk *guiWidget) moveNew() {
// always place the help menu on top // always place the help menu on top
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn 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
}

View File

@ -97,6 +97,12 @@ func showHelp() error {
me.clock.tk.Hide() me.clock.tk.Hide()
me.clock.tk.Show() 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 return nil
} }

View File

@ -15,24 +15,15 @@ import (
"go.wit.com/widget" "go.wit.com/widget"
) )
func showMsg(g *gocui.Gui, v *gocui.View) error { func createStdout(g *gocui.Gui) bool {
var l string if me.stdout.tk == nil {
var err error makeOutputWidget(g, "this is a create before a mouse click")
msg := fmt.Sprintf("test out gocuiEvent() %d\n", me.ecount)
log.Log(NOW, "showMsg() v.name =", v.Name()) // me.logStdout.v.Write([]byte(msg))
if _, err := g.SetCurrentView(v.Name()); err != nil { me.stdout.tk.Write([]byte(msg))
return err log.Log(NOW, "logStdout test out")
} }
return true
_, 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
} }
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View { 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() me.writeMutex.Lock()
defer me.writeMutex.Unlock() defer me.writeMutex.Unlock()
tk := me.stdout.tk
lines := strings.Split(strings.TrimSpace(string(p)), "\n") lines := strings.Split(strings.TrimSpace(string(p)), "\n")
me.stdout.outputS = append(me.stdout.outputS, lines...) me.stdout.outputS = append(me.stdout.outputS, lines...)
tk := me.stdout.tk
if tk == nil {
return len(p), nil
}
if tk.v == nil { if tk.v == nil {
// optionally write the output to /tmp // optionally write the output to /tmp
s := fmt.Sprint(string(p)) s := fmt.Sprint(string(p))