diff --git a/src/termui/table.go b/src/termui/table.go index bb62eec..1455726 100644 --- a/src/termui/table.go +++ b/src/termui/table.go @@ -3,6 +3,7 @@ package termui import ( "image" "strings" + "sync" . "github.com/gizak/termui" ) @@ -11,6 +12,8 @@ import ( type Table struct { *Block + sync.Mutex + Header []string Rows [][]string @@ -49,6 +52,8 @@ func (self *Table) ColResize() { // Buffer implements the Bufferer interface. func (self *Table) Draw(buf *Buffer) { + self.Lock() + self.Block.Draw(buf) self.ColResizer() @@ -124,6 +129,7 @@ func (self *Table) Draw(buf *Buffer) { ) } } + self.Unlock() } ///////////////////////////////////////////////////////////////////////////////// diff --git a/src/widgets/proc.go b/src/widgets/proc.go index d4ba739..f3dc441 100644 --- a/src/widgets/proc.go +++ b/src/widgets/proc.go @@ -66,7 +66,9 @@ func NewProc() *Proc { go func() { ticker := time.NewTicker(self.interval) for range ticker.C { + self.Lock() self.update() + self.Unlock() } }()