Skip to content
Myr

Draw spinner with Unicode characters

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 82bf8c1 · Browse files · 2 files+9 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−5 removed

  • other:+9 added−5 removed

2 files+9 added−5 removed

modified:src/constants.go+1 added-1 removed
23 unmodified lines
2425 // Terminal26 initialDelay = 20 * time.Millisecond27 initialDelayTac = 100 * time.Millisecond28 spinnerDuration = 200 * time.Millisecond28 spinnerDuration = 100 * time.Millisecond29 previewCancelWait = 500 * time.Millisecond30 maxPatternLength = 30031 maxMulti = math.MaxInt3232
55 unmodified lines
modified:src/terminal.go+8 added-4 removed
59 unmodified lines
60// Terminal represents terminal input/output61type Terminal struct {62 initDelay time.Duration63 infoStyle infoStyle64 spinner []string65 prompt string66 promptLen int67 queryLen [2]int68 layout layoutType
76 unmodified lines
145func (a byTimeOrder) Less(i, j int) bool {146 return a[i].at.Before(a[j].at)147}148148var _spinner = []string{`-`, `\`, `|`, `/`, `-`, `\`, `|`, `/`}149149const (150 reqPrompt util.EventType = iota151 reqInfo152 reqHeader
225 unmodified lines
378 sep := regexp.QuoteMeta(string(os.PathSeparator))379 wordRubout = fmt.Sprintf("%s[^%s]", sep, sep)380 wordNext = fmt.Sprintf("[^%s]%s|(.$)", sep, sep)381 }382 spinner := []string{`⠋`, `⠙`, `⠹`, `⠸`, `⠼`, `⠴`, `⠦`, `⠧`, `⠇`, `⠏`}383 if !opts.Unicode {384 spinner = []string{`-`, `\`, `|`, `/`, `-`, `\`, `|`, `/`}385 }386 t := Terminal{387 initDelay: delay,388 infoStyle: opts.InfoStyle,389 spinner: spinner,390 queryLen: [2]int{0, 0},391 layout: opts.Layout,392 fullscreen: fullscreen,393 hscroll: opts.Hscroll,
353 unmodified lines
747 case infoDefault:748 t.move(1, 0, true)749 if t.reading {750 duration := int64(spinnerDuration)747 idx := (time.Now().UnixNano() % (duration * int64(len(_spinner)))) / duration748 t.window.CPrint(tui.ColSpinner, t.strong, _spinner[idx])751 idx := (time.Now().UnixNano() % (duration * int64(len(t.spinner)))) / duration752 t.window.CPrint(tui.ColSpinner, t.strong, t.spinner[idx])753 }754 t.move(1, 2, false)755 pos = 2756 case infoInline:
1430 unmodified lines