mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
gofmt
This commit is contained in:
parent
fb5c825cf6
commit
28389aa38c
4
menus.go
4
menus.go
@ -177,9 +177,9 @@ func logReader(container *container.Container) (logs chan string, quit chan bool
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case log := <- stream:
|
case log := <-stream:
|
||||||
logs <- log.Message
|
logs <- log.Message
|
||||||
case <- quit:
|
case <-quit:
|
||||||
logCollector.Stop()
|
logCollector.Stop()
|
||||||
close(logs)
|
close(logs)
|
||||||
return
|
return
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package widgets
|
package widgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ui "github.com/gizak/termui"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TextView struct {
|
type TextView struct {
|
||||||
ui.Block
|
ui.Block
|
||||||
inputStream <- chan string
|
inputStream <-chan string
|
||||||
render chan bool
|
render chan bool
|
||||||
Text []string // all the text
|
Text []string // all the text
|
||||||
TextOut []string // text to be displayed
|
TextOut []string // text to be displayed
|
||||||
@ -16,7 +17,7 @@ type TextView struct {
|
|||||||
padding Padding
|
padding Padding
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTextView(lines <- chan string) *TextView {
|
func NewTextView(lines <-chan string) *TextView {
|
||||||
i := &TextView{
|
i := &TextView{
|
||||||
Block: *ui.NewBlock(),
|
Block: *ui.NewBlock(),
|
||||||
inputStream: lines,
|
inputStream: lines,
|
||||||
@ -67,12 +68,12 @@ func (i *TextView) renderLoop() {
|
|||||||
if size > len(i.Text) {
|
if size > len(i.Text) {
|
||||||
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)
|
width := i.Width - (i.padding[0] * 2)
|
||||||
for n := range i.TextOut {
|
for n := range i.TextOut {
|
||||||
if len(i.TextOut[n]) > width {
|
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)
|
ui.Render(i)
|
||||||
|
Loading…
Reference in New Issue
Block a user