You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

55 lines
833 B

package utils
import (
"time"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
const (
RefreshInterval = 250 * time.Millisecond
)
func EmptyBoxSpace(bgColor tcell.Color) *tview.Box {
box := tview.NewBox()
box.SetBackgroundColor(bgColor)
box.SetBorder(false)
return box
}
func CheckFocus(prims ...tview.Primitive) bool {
for _, prim := range prims {
if prim.HasFocus() {
return true
}
}
return false
}
func AlignStringListWidth(list []string) ([]string, int) {
var (
m = 0
alignedList = make([]string, 0)
)
for _, item := range list {
if len(item) > m {
m = len(item)
}
}
for _, item := range list {
if len(item) < m {
need := m - len(item)
for i := 0; i < need; i++ {
item += " "
}
}
alignedList = append(alignedList, item)
}
return alignedList, m
}