summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eventBindingsStdout.go5
-rw-r--r--init.go4
-rw-r--r--stdoutShow.go12
3 files changed, 17 insertions, 4 deletions
diff --git a/eventBindingsStdout.go b/eventBindingsStdout.go
index 4feca78..1eed205 100644
--- a/eventBindingsStdout.go
+++ b/eventBindingsStdout.go
@@ -31,18 +31,15 @@ func theStdout(g *gocui.Gui, v *gocui.View) error {
me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH)
me.stdout.outputOnTop = false
setThingsOnTop()
- // me.baseGui.SetViewOnBottom("msg")
- // setBottomBG()
} else {
me.stdout.outputOnTop = true
setThingsOnTop()
- // me.baseGui.SetViewOnTop("msg")
}
return nil
}
func stdoutPgup(g *gocui.Gui, v *gocui.View) error {
- me.stdout.pager -= 40
+ me.stdout.pager -= me.stdout.Height() - 2
if me.stdout.pager < 0 {
me.stdout.pager = 0
}
diff --git a/init.go b/init.go
index 8b2a7be..4810658 100644
--- a/init.go
+++ b/init.go
@@ -247,9 +247,13 @@ func refreshGocui() {
continue
}
if time.Since(lastRefresh) > 1000*time.Millisecond {
+ // artificially pause clock while dragging.
+ // this is a reminder to make this refresh code smarter
+ // after the switch to protocol buffers
if me.mouse.mouseUp {
// log.Info("refresh now on mouseUp")
// todo: add logic here to see if the application has changed anything
+ // me.baseGui.UpdateAsync(testRefresh) // probably don't need this
me.baseGui.Update(testRefresh)
if me.clock.tk != nil && !me.showHelp {
// also double check the gocui view exists
diff --git a/stdoutShow.go b/stdoutShow.go
index 5e3b305..2c9cd58 100644
--- a/stdoutShow.go
+++ b/stdoutShow.go
@@ -133,6 +133,13 @@ func (tk *guiWidget) relocateStdout(w int, h int) {
// of functions like fmt.Fprintf, fmt.Fprintln, io.Copy, etc. Clear must
// be called to clear the view's buffer.
+func (w stdout) Height() int {
+ if w.tk == nil {
+ return 40
+ }
+ return w.tk.gocuiSize.Height() - 2
+}
+
func (w stdout) Write(p []byte) (n int, err error) {
me.writeMutex.Lock()
defer me.writeMutex.Unlock()
@@ -200,6 +207,11 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
func (tk *guiWidget) refreshStdout() {
if len(me.stdout.outputS) < me.stdout.h+me.stdout.pager {
// log.Info(fmt.Sprintf("buffer too small=%d len(%d)", me.stdout.pager, len(me.stdout.outputS)))
+ var cur []string
+ cur = append(cur, me.stdout.outputS...)
+ slices.Reverse(cur)
+ tk.v.Clear()
+ fmt.Fprintln(tk.v, strings.Join(cur, "\n"))
return
}