Some updates

This commit is contained in:
2025-10-22 16:38:12 -05:00
parent b00f1ce9c5
commit cf47b5a4e4
7 changed files with 221 additions and 17 deletions

View File

@@ -41,6 +41,12 @@ type Spinner struct {
var _ Widget = (*Spinner)(nil)
var (
SPINNER_DOTS = []rune{'⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'}
SPINNER_DIRS = []rune{'←', '↖', '↑', '↗', '→', '↘', '↓', '↙'}
SPINNER_FILL = []rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '▇', '▆', '▅', '▄', '▃', '▁'}
)
func NewSpinner(id string, style tcell.Style) *Spinner {
ret := &Spinner{id: id}
ret.Init(id, style)
@@ -48,7 +54,7 @@ func NewSpinner(id string, style tcell.Style) *Spinner {
}
func (w *Spinner) Init(id string, st tcell.Style) {
w.frames = []rune{'⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'}
w.frames = SPINNER_DOTS
w.tickInterval = time.Second
w.keyMap = BlankKeyMap()
}
@@ -66,10 +72,7 @@ func (w *Spinner) RemoveFromKeyMap(km KeyMap) {
}
func (w *Spinner) HandleKey(ev *tcell.EventKey) bool { return false }
func (w *Spinner) HandleTime(ev *tcell.EventTime) {
for w.lastTick.Before(ev.When()) {
w.lastTick = w.lastTick.Add(w.tickInterval)
w.currentFrame = (w.currentFrame + 1) % len(w.frames)
}
w.currentFrame = (w.currentFrame + 1) % len(w.frames)
}
func (w *Spinner) Draw(screen tcell.Screen) {