This commit is contained in:
Bradley Cicenas 2017-11-28 13:40:43 +00:00
parent fb5c825cf6
commit 28389aa38c
2 changed files with 8 additions and 7 deletions

View File

@ -177,9 +177,9 @@ func logReader(container *container.Container) (logs chan string, quit chan bool
go func() {
for {
select {
case log := <- stream:
case log := <-stream:
logs <- log.Message
case <- quit:
case <-quit:
logCollector.Stop()
close(logs)
return

View File

@ -1,13 +1,14 @@
package widgets
import (
ui "github.com/gizak/termui"
"fmt"
ui "github.com/gizak/termui"
)
type TextView struct {
ui.Block
inputStream <- chan string
inputStream <-chan string
render chan bool
Text []string // all the text
TextOut []string // text to be displayed
@ -16,7 +17,7 @@ type TextView struct {
padding Padding
}
func NewTextView(lines <- chan string) *TextView {
func NewTextView(lines <-chan string) *TextView {
i := &TextView{
Block: *ui.NewBlock(),
inputStream: lines,
@ -67,12 +68,12 @@ func (i *TextView) renderLoop() {
if size > len(i.Text) {
size = len(i.Text)
}
i.TextOut = i.Text[len(i.Text) - size:]
i.TextOut = i.Text[len(i.Text)-size:]
width := i.Width - (i.padding[0] * 2)
for n := range i.TextOut {
if len(i.TextOut[n]) > width {
i.TextOut[n] = fmt.Sprintf("%s...", i.TextOut[n][:width - 3])
i.TextOut[n] = fmt.Sprintf("%s...", i.TextOut[n][:width-3])
}
}
ui.Render(i)