mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Move Loader to presentation package
It is very gui specific and shouldn't be in a low-level utils package.
This commit is contained in:
@ -165,7 +165,7 @@ func BranchStatus(
|
||||
) string {
|
||||
itemOperationStr := ItemOperationToString(itemOperation, tr)
|
||||
if itemOperationStr != "" {
|
||||
return style.FgCyan.Sprintf("%s %s", itemOperationStr, utils.Loader(now, userConfig.Gui.Spinner))
|
||||
return style.FgCyan.Sprintf("%s %s", itemOperationStr, Loader(now, userConfig.Gui.Spinner))
|
||||
}
|
||||
|
||||
result := ""
|
||||
|
14
pkg/gui/presentation/loader.go
Normal file
14
pkg/gui/presentation/loader.go
Normal file
@ -0,0 +1,14 @@
|
||||
package presentation
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
)
|
||||
|
||||
// Loader dumps a string to be displayed as a loader
|
||||
func Loader(now time.Time, config config.SpinnerConfig) string {
|
||||
milliseconds := now.UnixMilli()
|
||||
index := milliseconds / int64(config.Rate) % int64(len(config.Frames))
|
||||
return config.Frames[index]
|
||||
}
|
@ -10,7 +10,6 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
@ -49,7 +48,7 @@ func getRemoteDisplayStrings(
|
||||
descriptionStr := style.FgBlue.Sprintf("%d branches", branchCount)
|
||||
itemOperationStr := ItemOperationToString(itemOperation, tr)
|
||||
if itemOperationStr != "" {
|
||||
descriptionStr += " " + style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now(), userConfig.Gui.Spinner))
|
||||
descriptionStr += " " + style.FgCyan.Sprint(itemOperationStr+" "+Loader(time.Now(), userConfig.Gui.Spinner))
|
||||
}
|
||||
res = append(res, textStyle.Sprint(r.Name), descriptionStr)
|
||||
return res
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
@ -47,7 +46,7 @@ func getTagDisplayStrings(
|
||||
descriptionStr := descriptionColor.Sprint(t.Description())
|
||||
itemOperationStr := ItemOperationToString(itemOperation, tr)
|
||||
if itemOperationStr != "" {
|
||||
descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now(), userConfig.Gui.Spinner)) + " " + descriptionStr
|
||||
descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+Loader(time.Now(), userConfig.Gui.Spinner)) + " " + descriptionStr
|
||||
}
|
||||
res = append(res, textStyle.Sprint(t.Name), descriptionStr)
|
||||
return res
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
@ -75,7 +75,7 @@ func (self *StatusManager) GetStatusString(userConfig *config.UserConfig) (strin
|
||||
}
|
||||
topStatus := self.statuses[0]
|
||||
if topStatus.statusType == "waiting" {
|
||||
return topStatus.message + " " + utils.Loader(time.Now(), userConfig.Gui.Spinner), topStatus.color
|
||||
return topStatus.message + " " + presentation.Loader(time.Now(), userConfig.Gui.Spinner), topStatus.color
|
||||
}
|
||||
return topStatus.message, topStatus.color
|
||||
}
|
||||
|
@ -8,10 +8,8 @@ import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"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
|
||||
@ -25,13 +23,6 @@ func GetProjectRoot() string {
|
||||
return strings.Split(dir, "lazygit")[0] + "lazygit"
|
||||
}
|
||||
|
||||
// Loader dumps a string to be displayed as a loader
|
||||
func Loader(now time.Time, config config.SpinnerConfig) string {
|
||||
milliseconds := now.UnixMilli()
|
||||
index := milliseconds / int64(config.Rate) % int64(len(config.Frames))
|
||||
return config.Frames[index]
|
||||
}
|
||||
|
||||
func SortRange(x int, y int) (int, int) {
|
||||
if x < y {
|
||||
return x, y
|
||||
|
Reference in New Issue
Block a user