summaryrefslogtreecommitdiff
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
parent076b0e4077f3854f7c5e487e83cfd590d14e7aeb (diff)
gocui: proper line count on Stdout
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--toolkit/gocui/showStdout.go2
-rw-r--r--toolkit/gocui/structs.go15
2 files changed, 9 insertions, 8 deletions
diff --git a/toolkit/gocui/showStdout.go b/toolkit/gocui/showStdout.go
index 909abd5..32fb9f3 100644
--- a/toolkit/gocui/showStdout.go
+++ b/toolkit/gocui/showStdout.go
@@ -16,7 +16,7 @@ func moveMsg(g *gocui.Gui) {
if !movingMsg && (mx != initialMouseX || my != initialMouseY) {
movingMsg = true
}
- g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH, 0)
+ g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH + me.FramePadH, 0)
g.SetViewOnBottom("msg")
}
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"))