This commit is contained in:
Caleb Bassi 2019-02-03 20:11:35 -08:00
parent dbf25cdd85
commit d9607af034
4 changed files with 9 additions and 8 deletions

View File

@ -9,10 +9,11 @@ import (
"sync" "sync"
"time" "time"
ui "github.com/cjbassi/gotop/src/termui"
"github.com/cjbassi/gotop/src/utils"
"github.com/gizak/termui" "github.com/gizak/termui"
psCPU "github.com/shirou/gopsutil/cpu" psCPU "github.com/shirou/gopsutil/cpu"
ui "github.com/cjbassi/gotop/src/termui"
"github.com/cjbassi/gotop/src/utils"
) )
const ( const (

View File

@ -1,8 +1,5 @@
package widgets package widgets
// Temp is too customized to inherit from a generic widget so we create a customized one here.
// Temp defines its own Buffer method directly.
import ( import (
"fmt" "fmt"
"image" "image"
@ -14,7 +11,7 @@ import (
) )
type Temp struct { type Temp struct {
*ui.Block *ui.Block // inherits from Block instead of a premade Widget
interval time.Duration interval time.Duration
Data map[string]int Data map[string]int
Threshold int Threshold int
@ -50,6 +47,7 @@ func NewTemp(renderLock *sync.RWMutex, fahrenheit bool) *Temp {
return self return self
} }
// We implement a custom Draw method instead of inheriting from a generic Widget.
func (self *Temp) Draw(buf *ui.Buffer) { func (self *Temp) Draw(buf *ui.Buffer) {
self.Block.Draw(buf) self.Block.Draw(buf)

View File

@ -6,8 +6,9 @@ import (
"log" "log"
"strings" "strings"
"github.com/cjbassi/gotop/src/utils"
psHost "github.com/shirou/gopsutil/host" psHost "github.com/shirou/gopsutil/host"
"github.com/cjbassi/gotop/src/utils"
) )
func (self *Temp) update() { func (self *Temp) update() {

View File

@ -3,8 +3,9 @@ package widgets
import ( import (
"log" "log"
"github.com/cjbassi/gotop/src/utils"
psHost "github.com/shirou/gopsutil/host" psHost "github.com/shirou/gopsutil/host"
"github.com/cjbassi/gotop/src/utils"
) )
func (self *Temp) update() { func (self *Temp) update() {