diff options
Diffstat (limited to 'structs.go')
| -rw-r--r-- | structs.go | 46 |
1 files changed, 2 insertions, 44 deletions
@@ -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 |
