keep cleaning the 'msg' stdout handling code

This commit is contained in:
Jeff Carr 2025-02-08 18:21:31 -06:00
parent 2c07da350a
commit bff0943dc5
2 changed files with 60 additions and 55 deletions

View File

@ -84,16 +84,20 @@ func mouseMove(g *gocui.Gui) {
return
}
// if me.mouse.globalMouseDown {
// log.Info("msgMouseDown == true")
// plugin will segfault if you don't keep this inside a check for msgMouseDown
// don't move this code out of here
var found bool = false
// drag whatever was set to drag
if me.mouse.currentDrag != nil {
// me.mouse.currentDrag.dumpWidget(fmt.Sprintf("MM (%3d,%3d)", w, h))
me.mouse.currentDrag.moveNew()
return
}
log.Info(fmt.Sprintf("gui toolkit error. nothing to drag at (%d,%d)", w, h))
return
// if me.mouse.globalMouseDown {
// log.Info("msgMouseDown == true")
// plugin will segfault if you don't keep this inside a check for msgMouseDown
// don't move this code out of here
/*
// new function that is smarter
if tk := findWindowUnderMouse(); tk != nil {
tk.setAsDragging()
@ -120,18 +124,9 @@ func mouseMove(g *gocui.Gui) {
// tk.moveNew()
return
}
/*
if tk.node.WidgetType == widget.Label {
me.mouse.currentDrag = tk
// tk.moveNew()
return
}
*/
found = true
}
if !found {
log.Info(fmt.Sprintf("findByXY() empty. nothing to move at (%d,%d)", w, h))
}
*/
}
func (tk *guiWidget) setAsDragging() {

View File

@ -156,6 +156,15 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
return len(p), nil
}
if tk.v == nil {
v, _ := me.baseGui.View("msg")
if v != nil {
// fmt.Fprintln(outf, "found msg")
tk.v = v
}
return len(p), nil
}
tk.refreshStdout()
/*
// optionally write the output to /tmp
s := fmt.Sprint(string(p))
s = strings.TrimSuffix(s, "\n")
@ -182,6 +191,7 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
tk.v.Clear()
fmt.Fprintln(tk.v, strings.Join(cur, "\n"))
}
*/
return len(p), nil
}