gocui: proper line count on Stdout
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
a4403975e7
commit
17b59b7e7e
|
@ -16,7 +16,7 @@ func moveMsg(g *gocui.Gui) {
|
||||||
if !movingMsg && (mx != initialMouseX || my != initialMouseY) {
|
if !movingMsg && (mx != initialMouseX || my != initialMouseY) {
|
||||||
movingMsg = true
|
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")
|
g.SetViewOnBottom("msg")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,9 @@ type config struct {
|
||||||
stretchy bool // expand things like buttons to the maximum size
|
stretchy bool // expand things like buttons to the maximum size
|
||||||
padded bool // add space between things like buttons
|
padded bool // add space between things like buttons
|
||||||
margin bool // add space around the frames of windows
|
margin bool // add space around the frames of windows
|
||||||
|
|
||||||
|
// writeMutex protects locks the write process
|
||||||
|
writeMutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -167,9 +170,6 @@ type cuiWidget struct {
|
||||||
v *gocui.View
|
v *gocui.View
|
||||||
frame bool
|
frame bool
|
||||||
|
|
||||||
// writeMutex protects locks the write process
|
|
||||||
writeMutex sync.Mutex
|
|
||||||
|
|
||||||
parent *cuiWidget
|
parent *cuiWidget
|
||||||
children []*cuiWidget
|
children []*cuiWidget
|
||||||
}
|
}
|
||||||
|
@ -201,8 +201,8 @@ func (w *cuiWidget) StartH() {
|
||||||
|
|
||||||
func (w *cuiWidget) Write(p []byte) (n int, err error) {
|
func (w *cuiWidget) Write(p []byte) (n int, err error) {
|
||||||
w.tainted = true
|
w.tainted = true
|
||||||
w.writeMutex.Lock()
|
me.writeMutex.Lock()
|
||||||
defer w.writeMutex.Unlock()
|
defer me.writeMutex.Unlock()
|
||||||
if (me.logStdout.v == nil) {
|
if (me.logStdout.v == nil) {
|
||||||
fmt.Fprintln(outf, string(p))
|
fmt.Fprintln(outf, string(p))
|
||||||
v, _ := me.baseGui.View("msg")
|
v, _ := me.baseGui.View("msg")
|
||||||
|
@ -217,11 +217,12 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
|
||||||
// log(logNow, "widget.Write()", p)
|
// log(logNow, "widget.Write()", p)
|
||||||
|
|
||||||
s := fmt.Sprint(string(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")
|
tmp := strings.Split(s, "\n")
|
||||||
outputS = append(outputS, tmp...)
|
outputS = append(outputS, tmp...)
|
||||||
if (len(outputS) > outputH) {
|
if (len(outputS) > outputH) {
|
||||||
outputS = outputS[4:]
|
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"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue