diff --git a/eventMouseDrag.go b/eventMouseDrag.go index ce66257..c2625e1 100644 --- a/eventMouseDrag.go +++ b/eventMouseDrag.go @@ -84,54 +84,49 @@ 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 } - // new function that is smarter - if tk := findWindowUnderMouse(); tk != nil { - tk.setAsDragging() - return - } - // first look for windows - for _, tk := range findByXY(w, h) { - if tk.node.WidgetType == widget.Window { - tk.setAsDragging() - return - } - } + log.Info(fmt.Sprintf("gui toolkit error. nothing to drag at (%d,%d)", w, h)) + return - // now look for the STDOUT window - for _, tk := range findByXY(w, h) { - if tk.node.WidgetType == widget.Flag { + // 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() return } - } - for _, tk := range findByXY(w, h) { - if tk.node.WidgetType == widget.Stdout { - tk.setAsDragging() - // tk.moveNew() - return + // first look for windows + for _, tk := range findByXY(w, h) { + if tk.node.WidgetType == widget.Window { + tk.setAsDragging() + return + } } - /* - if tk.node.WidgetType == widget.Label { - me.mouse.currentDrag = tk + + // now look for the STDOUT window + for _, tk := range findByXY(w, h) { + if tk.node.WidgetType == widget.Flag { + tk.setAsDragging() + return + } + } + for _, tk := range findByXY(w, h) { + if tk.node.WidgetType == widget.Stdout { + tk.setAsDragging() // tk.moveNew() return } - */ - found = true - } - if !found { - log.Info(fmt.Sprintf("findByXY() empty. nothing to move at (%d,%d)", w, h)) - } + found = true + } + */ } func (tk *guiWidget) setAsDragging() { diff --git a/stdoutShow.go b/stdoutShow.go index e630295..5e3b305 100644 --- a/stdoutShow.go +++ b/stdoutShow.go @@ -156,32 +156,42 @@ func (w *guiWidget) Write(p []byte) (n int, err error) { return len(p), nil } if tk.v == nil { - // optionally write the output to /tmp - s := fmt.Sprint(string(p)) - s = strings.TrimSuffix(s, "\n") - fmt.Fprintln(outf, s) v, _ := me.baseGui.View("msg") if v != nil { // fmt.Fprintln(outf, "found msg") tk.v = v } - } else { - // display the output in the gocui window - var cur []string - // chop off the last lines in the buffer - chop := len(me.stdout.outputS) - (me.stdout.h - 1) - if chop < 0 { - chop = 0 - } - if len(me.stdout.outputS) > chop { - cur = append(cur, me.stdout.outputS[chop:]...) - } else { - cur = append(cur, me.stdout.outputS...) - } - slices.Reverse(cur) - tk.v.Clear() - fmt.Fprintln(tk.v, strings.Join(cur, "\n")) + return len(p), nil } + tk.refreshStdout() + /* + // optionally write the output to /tmp + s := fmt.Sprint(string(p)) + s = strings.TrimSuffix(s, "\n") + fmt.Fprintln(outf, s) + v, _ := me.baseGui.View("msg") + if v != nil { + // fmt.Fprintln(outf, "found msg") + tk.v = v + } + } else { + // display the output in the gocui window + var cur []string + // chop off the last lines in the buffer + chop := len(me.stdout.outputS) - (me.stdout.h - 1) + if chop < 0 { + chop = 0 + } + if len(me.stdout.outputS) > chop { + cur = append(cur, me.stdout.outputS[chop:]...) + } else { + cur = append(cur, me.stdout.outputS...) + } + slices.Reverse(cur) + tk.v.Clear() + fmt.Fprintln(tk.v, strings.Join(cur, "\n")) + } + */ return len(p), nil }