1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-27 22:01:46 +02:00

color fixups

This commit is contained in:
Jesse Duffield 2021-08-01 16:02:49 +10:00
parent 123d624141
commit d626bcac00
10 changed files with 28 additions and 27 deletions

View File

@ -118,15 +118,16 @@ func coloredString(textStyle style.TextStyle, str string, selected bool, include
textStyle = textStyle.MergeStyle(theme.SelectedRangeBgColor)
}
if len(str) < 2 {
return textStyle.Sprint(str)
firstCharStyle := textStyle
if included {
firstCharStyle = firstCharStyle.MergeStyle(style.BgGreen)
}
res := textStyle.Sprint(str[:1])
if included {
return res + textStyle.MergeStyle(style.BgGreen).Sprint(str[1:])
if len(str) < 2 {
return firstCharStyle.Sprint(str)
}
return res + textStyle.Sprint(str[1:])
return firstCharStyle.Sprint(str[:1]) + textStyle.Sprint(str[1:])
}
func parsePatch(patch string) ([]int, []int, []*PatchLine) {

View File

@ -554,7 +554,7 @@ func (gui *Gui) findBranchNameSuggestions(input string) []*types.Suggestion {
for i, branchName := range matchingBranchNames {
suggestions[i] = &types.Suggestion{
Value: branchName,
Label: presentation.GetBranchColor(branchName).Sprint(branchName),
Label: presentation.GetBranchTextStyle(branchName).Sprint(branchName),
}
}

View File

@ -21,7 +21,7 @@ func ColoredConflictFile(content string, state *State, hasFocus bool) string {
}
if hasFocus && state.conflictIndex < len(state.conflicts) && *state.conflicts[state.conflictIndex] == *conflict && shouldHighlightLine(i, conflict, state.conflictTop) {
textStyle = theme.SelectedRangeBgColor.SetBold()
textStyle = textStyle.MergeStyle(theme.SelectedRangeBgColor).SetBold()
}
if i == conflict.end && len(remainingConflicts) > 0 {
conflict, remainingConflicts = shiftConflict(remainingConflicts)

View File

@ -27,11 +27,11 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
displayName = b.DisplayName
}
nameColorAttr := GetBranchColor(b.Name)
nameTextStyle := GetBranchTextStyle(b.Name)
if diffed {
nameColorAttr = theme.DiffTerminalColor
nameTextStyle = theme.DiffTerminalColor
}
coloredName := nameColorAttr.Sprint(displayName)
coloredName := nameTextStyle.Sprint(displayName)
if b.IsTrackingRemote() {
coloredName = fmt.Sprintf("%s %s", coloredName, ColoredBranchStatus(b))
}
@ -48,8 +48,8 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
return res
}
// GetBranchColor branch color
func GetBranchColor(name string) style.TextStyle {
// GetBranchTextStyle branch color
func GetBranchTextStyle(name string) style.TextStyle {
branchType := strings.Split(name, "/")[0]
switch branchType {

View File

@ -59,7 +59,7 @@ func getFullDescriptionDisplayStringsForCommit(c *models.Commit, cherryPickedCom
if c.Action != "" {
secondColumnString = actionColorMap(c.Action).Sprint(c.Action)
} else if c.ExtraInfo != "" {
tagString = theme.DiffTerminalColor.SetBold().Sprint(c.ExtraInfo) + " "
tagString = style.FgMagenta.SetBold().Sprint(c.ExtraInfo) + " "
}
truncatedAuthor := utils.TruncateWithEllipsis(c.Author, 17)

View File

@ -18,10 +18,10 @@ func GetRemoteBranchListDisplayStrings(branches []*models.RemoteBranch, diffName
// getRemoteBranchDisplayStrings returns the display string of branch
func getRemoteBranchDisplayStrings(b *models.RemoteBranch, diffed bool) []string {
nameColorAttr := GetBranchColor(b.Name)
textStyle := GetBranchTextStyle(b.Name)
if diffed {
nameColorAttr = theme.DiffTerminalColor
textStyle = theme.DiffTerminalColor
}
return []string{nameColorAttr.Sprint(b.Name)}
return []string{textStyle.Sprint(b.Name)}
}

View File

@ -21,10 +21,10 @@ func GetRemoteListDisplayStrings(remotes []*models.Remote, diffName string) [][]
func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
branchCount := len(r.Branches)
nameColorAttr := theme.DefaultTextColor
textStyle := theme.DefaultTextColor
if diffed {
nameColorAttr = theme.DiffTerminalColor
textStyle = theme.DiffTerminalColor
}
return []string{nameColorAttr.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount)}
return []string{textStyle.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount)}
}

View File

@ -18,9 +18,9 @@ func GetStashEntryListDisplayStrings(stashEntries []*models.StashEntry, diffName
// getStashEntryDisplayStrings returns the display string of branch
func getStashEntryDisplayStrings(s *models.StashEntry, diffed bool) []string {
attr := theme.DefaultTextColor
textStyle := theme.DefaultTextColor
if diffed {
attr = theme.DiffTerminalColor
textStyle = theme.DiffTerminalColor
}
return []string{attr.Sprint(s.Name)}
return []string{textStyle.Sprint(s.Name)}
}

View File

@ -18,9 +18,9 @@ func GetTagListDisplayStrings(tags []*models.Tag, diffName string) [][]string {
// getTagDisplayStrings returns the display string of branch
func getTagDisplayStrings(t *models.Tag, diffed bool) []string {
attr := theme.DefaultTextColor
textStyle := theme.DefaultTextColor
if diffed {
attr = theme.DiffTerminalColor
textStyle = theme.DiffTerminalColor
}
return []string{attr.Sprint(t.Name)}
return []string{textStyle.Sprint(t.Name)}
}

View File

@ -31,7 +31,7 @@ func (gui *Gui) refreshStatus() {
status += style.FgYellow.Sprintf("(%s) ", gui.GitCommand.WorkingTreeState())
}
name := presentation.GetBranchColor(currentBranch.Name).Sprint(currentBranch.Name)
name := presentation.GetBranchTextStyle(currentBranch.Name).Sprint(currentBranch.Name)
repoName := utils.GetCurrentRepoName()
status += fmt.Sprintf("%s → %s ", repoName, name)