summaryrefslogtreecommitdiff
path: root/structs.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-06 16:19:36 -0600
committerJeff Carr <[email protected]>2025-02-06 16:19:36 -0600
commite134ecb6a4285d576c45c3f86274703f32ab30b0 (patch)
tree4c07d83ac6a4f195c708c50ca1b4b492931d662e /structs.go
parent5bae8b7e41fc17a5020f4c8e58695ae59063cda4 (diff)
make stdout upside down
Diffstat (limited to 'structs.go')
-rw-r--r--structs.go46
1 files changed, 2 insertions, 44 deletions
diff --git a/structs.go b/structs.go
index f444e65..b4d1aef 100644
--- a/structs.go
+++ b/structs.go
@@ -12,7 +12,6 @@ import (
"fmt"
"reflect"
"strconv"
- "strings"
"sync"
"github.com/awesome-gocui/gocui"
@@ -88,6 +87,8 @@ type stdout struct {
mouseOffsetH int // the current 'h' offset
init bool // moves the window offscreen on startup
resize bool // user is resizing the window
+ outputS []string // the buffer of all the output
+
}
// settings for the dropdown window
@@ -166,49 +167,6 @@ type guiWidget struct {
isBG bool // means this is the background widget. There is only one of these
}
-// from the gocui devs:
-// Write appends a byte slice into the view's internal buffer. Because
-// View implements the io.Writer interface, it can be passed as parameter
-// of functions like fmt.Fprintf, fmt.Fprintln, io.Copy, etc. Clear must
-// be called to clear the view's buffer.
-
-func (w *guiWidget) Write(p []byte) (n int, err error) {
- w.tainted = true
- me.writeMutex.Lock()
- defer me.writeMutex.Unlock()
-
- // _, outputH := w.Size()
- outputH := 33 // special output length for "msg" window until I figure things out
-
- tk := me.stdout.tk
- if tk.v == nil {
- // optionally write the output to /tmp
- s := fmt.Sprint(string(p))
- s = strings.TrimSuffix(s, "\n")
- fmt.Fprintln(outf, s)
- v, _ := me.baseGui.View("msg")
- if v != nil {
- // fmt.Fprintln(outf, "found msg")
- tk.v = v
- }
- } else {
- // display the output in the gocui window
- tk.v.Clear()
-
- 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(tk.v, strings.Join(outputS, "\n"))
- }
-
- return len(p), nil
-}
-
// THIS IS GO COMPILER MAGIC
// this sets the `default` in the structs above on init()
// this is cool code. thank the GO devs for this code and Alex Flint for explaining it to me