summaryrefslogtreecommitdiff
path: root/toolkit/gocui/structs.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-27 00:10:23 -0500
committerJeff Carr <[email protected]>2023-04-27 00:10:23 -0500
commitf5468d9c1cdaf1b0a2e44fcc78621bfae23e44fa (patch)
treef4da96c8302f70a8c683fae58ed568653f51cf2f /toolkit/gocui/structs.go
parentefa1b7eba77254d2607dae47e3e6ea70fc619932 (diff)
gocui: better output handlingv0.8.4
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui/structs.go')
-rw-r--r--toolkit/gocui/structs.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/toolkit/gocui/structs.go b/toolkit/gocui/structs.go
index 4b1749e..09d1f33 100644
--- a/toolkit/gocui/structs.go
+++ b/toolkit/gocui/structs.go
@@ -204,27 +204,27 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
me.writeMutex.Lock()
defer me.writeMutex.Unlock()
if (me.logStdout.v == nil) {
+ // optionally write the output to /tmp
fmt.Fprintln(outf, string(p))
v, _ := me.baseGui.View("msg")
if (v != nil) {
fmt.Fprintln(outf, "found msg")
me.logStdout.v = v
}
- return
- }
- me.logStdout.v.Clear()
- // fmt.Fprintln(w.v, p + "jcarr")
- // log(logNow, "widget.Write()", p)
+ } else {
+ // display the output in the gocui window
+ me.logStdout.v.Clear()
- s := fmt.Sprint(string(p))
- s = "jwc " + strconv.Itoa(len(outputS)) + " " + strings.TrimSuffix(s, "\n")
- tmp := strings.Split(s, "\n")
- outputS = append(outputS, tmp...)
- if (len(outputS) > outputH) {
- l := len(outputS) - outputH
- outputS = outputS[l:]
+ s := fmt.Sprint(string(p))
+ s = strings.TrimSuffix(s, "\n")
+ tmp := strings.Split(s, "\n")
+ outputS = append(outputS, tmp...)
+ if (len(outputS) > outputH) {
+ l := len(outputS) - outputH
+ outputS = outputS[l:]
+ }
+ fmt.Fprintln(me.logStdout.v, strings.Join(outputS, "\n"))
}
- fmt.Fprintln(me.logStdout.v, strings.Join(outputS, "\n"))
return len(p), nil
}