summaryrefslogtreecommitdiff
path: root/toolkit/gocui/structs.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-26 22:08:43 -0500
committerJeff Carr <[email protected]>2023-04-26 22:08:43 -0500
commitefa1b7eba77254d2607dae47e3e6ea70fc619932 (patch)
treecc59516135be4d74a2cba230d286bdebac85c676 /toolkit/gocui/structs.go
parent076b0e4077f3854f7c5e487e83cfd590d14e7aeb (diff)
gocui: proper line count on Stdout
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui/structs.go')
-rw-r--r--toolkit/gocui/structs.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/toolkit/gocui/structs.go b/toolkit/gocui/structs.go
index d3d8b03..4b1749e 100644
--- a/toolkit/gocui/structs.go
+++ b/toolkit/gocui/structs.go
@@ -80,6 +80,9 @@ type config struct {
stretchy bool // expand things like buttons to the maximum size
padded bool // add space between things like buttons
margin bool // add space around the frames of windows
+
+ // writeMutex protects locks the write process
+ writeMutex sync.Mutex
}
var (
@@ -167,9 +170,6 @@ type cuiWidget struct {
v *gocui.View
frame bool
- // writeMutex protects locks the write process
- writeMutex sync.Mutex
-
parent *cuiWidget
children []*cuiWidget
}
@@ -201,8 +201,8 @@ func (w *cuiWidget) StartH() {
func (w *cuiWidget) Write(p []byte) (n int, err error) {
w.tainted = true
- w.writeMutex.Lock()
- defer w.writeMutex.Unlock()
+ me.writeMutex.Lock()
+ defer me.writeMutex.Unlock()
if (me.logStdout.v == nil) {
fmt.Fprintln(outf, string(p))
v, _ := me.baseGui.View("msg")
@@ -217,11 +217,12 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
// log(logNow, "widget.Write()", p)
s := fmt.Sprint(string(p))
- s = strings.TrimSuffix(s, "\n")
+ s = "jwc " + strconv.Itoa(len(outputS)) + " " + strings.TrimSuffix(s, "\n")
tmp := strings.Split(s, "\n")
outputS = append(outputS, tmp...)
if (len(outputS) > outputH) {
- outputS = outputS[4:]
+ l := len(outputS) - outputH
+ outputS = outputS[l:]
}
fmt.Fprintln(me.logStdout.v, strings.Join(outputS, "\n"))