mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 04:45:47 +02:00
Add SpinnerConfig
This new config section allows to customize frames and rate of thespinner
This commit is contained in:
parent
53f0c4aeff
commit
f3dba743f0
15 changed files with 101 additions and 31 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
)
|
||||
|
||||
// GetProjectRoot returns the path to the root of the project. Only to be used
|
||||
|
@ -24,15 +25,11 @@ func GetProjectRoot() string {
|
|||
return strings.Split(dir, "lazygit")[0] + "lazygit"
|
||||
}
|
||||
|
||||
// The duration between two frames of the loader animation in milliseconds
|
||||
const LoaderAnimationInterval = 50
|
||||
|
||||
// Loader dumps a string to be displayed as a loader
|
||||
func Loader(now time.Time) string {
|
||||
characters := "|/-\\"
|
||||
func Loader(now time.Time, config config.SpinnerConfig) string {
|
||||
milliseconds := now.UnixMilli()
|
||||
index := milliseconds / LoaderAnimationInterval % int64(len(characters))
|
||||
return characters[index : index+1]
|
||||
index := milliseconds / int64(config.Rate) % int64(len(config.Frames))
|
||||
return config.Frames[index]
|
||||
}
|
||||
|
||||
// Min returns the minimum of two integers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue