mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-17 00:18:05 +02:00
color fixups
This commit is contained in:
@ -118,15 +118,16 @@ func coloredString(textStyle style.TextStyle, str string, selected bool, include
|
|||||||
textStyle = textStyle.MergeStyle(theme.SelectedRangeBgColor)
|
textStyle = textStyle.MergeStyle(theme.SelectedRangeBgColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(str) < 2 {
|
firstCharStyle := textStyle
|
||||||
return textStyle.Sprint(str)
|
if included {
|
||||||
|
firstCharStyle = firstCharStyle.MergeStyle(style.BgGreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
res := textStyle.Sprint(str[:1])
|
if len(str) < 2 {
|
||||||
if included {
|
return firstCharStyle.Sprint(str)
|
||||||
return res + textStyle.MergeStyle(style.BgGreen).Sprint(str[1:])
|
|
||||||
}
|
}
|
||||||
return res + textStyle.Sprint(str[1:])
|
|
||||||
|
return firstCharStyle.Sprint(str[:1]) + textStyle.Sprint(str[1:])
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePatch(patch string) ([]int, []int, []*PatchLine) {
|
func parsePatch(patch string) ([]int, []int, []*PatchLine) {
|
||||||
|
@ -554,7 +554,7 @@ func (gui *Gui) findBranchNameSuggestions(input string) []*types.Suggestion {
|
|||||||
for i, branchName := range matchingBranchNames {
|
for i, branchName := range matchingBranchNames {
|
||||||
suggestions[i] = &types.Suggestion{
|
suggestions[i] = &types.Suggestion{
|
||||||
Value: branchName,
|
Value: branchName,
|
||||||
Label: presentation.GetBranchColor(branchName).Sprint(branchName),
|
Label: presentation.GetBranchTextStyle(branchName).Sprint(branchName),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
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 {
|
if i == conflict.end && len(remainingConflicts) > 0 {
|
||||||
conflict, remainingConflicts = shiftConflict(remainingConflicts)
|
conflict, remainingConflicts = shiftConflict(remainingConflicts)
|
||||||
|
@ -27,11 +27,11 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
|
|||||||
displayName = b.DisplayName
|
displayName = b.DisplayName
|
||||||
}
|
}
|
||||||
|
|
||||||
nameColorAttr := GetBranchColor(b.Name)
|
nameTextStyle := GetBranchTextStyle(b.Name)
|
||||||
if diffed {
|
if diffed {
|
||||||
nameColorAttr = theme.DiffTerminalColor
|
nameTextStyle = theme.DiffTerminalColor
|
||||||
}
|
}
|
||||||
coloredName := nameColorAttr.Sprint(displayName)
|
coloredName := nameTextStyle.Sprint(displayName)
|
||||||
if b.IsTrackingRemote() {
|
if b.IsTrackingRemote() {
|
||||||
coloredName = fmt.Sprintf("%s %s", coloredName, ColoredBranchStatus(b))
|
coloredName = fmt.Sprintf("%s %s", coloredName, ColoredBranchStatus(b))
|
||||||
}
|
}
|
||||||
@ -48,8 +48,8 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBranchColor branch color
|
// GetBranchTextStyle branch color
|
||||||
func GetBranchColor(name string) style.TextStyle {
|
func GetBranchTextStyle(name string) style.TextStyle {
|
||||||
branchType := strings.Split(name, "/")[0]
|
branchType := strings.Split(name, "/")[0]
|
||||||
|
|
||||||
switch branchType {
|
switch branchType {
|
||||||
|
@ -59,7 +59,7 @@ func getFullDescriptionDisplayStringsForCommit(c *models.Commit, cherryPickedCom
|
|||||||
if c.Action != "" {
|
if c.Action != "" {
|
||||||
secondColumnString = actionColorMap(c.Action).Sprint(c.Action)
|
secondColumnString = actionColorMap(c.Action).Sprint(c.Action)
|
||||||
} else if c.ExtraInfo != "" {
|
} else if c.ExtraInfo != "" {
|
||||||
tagString = theme.DiffTerminalColor.SetBold().Sprint(c.ExtraInfo) + " "
|
tagString = style.FgMagenta.SetBold().Sprint(c.ExtraInfo) + " "
|
||||||
}
|
}
|
||||||
|
|
||||||
truncatedAuthor := utils.TruncateWithEllipsis(c.Author, 17)
|
truncatedAuthor := utils.TruncateWithEllipsis(c.Author, 17)
|
||||||
|
@ -18,10 +18,10 @@ func GetRemoteBranchListDisplayStrings(branches []*models.RemoteBranch, diffName
|
|||||||
|
|
||||||
// getRemoteBranchDisplayStrings returns the display string of branch
|
// getRemoteBranchDisplayStrings returns the display string of branch
|
||||||
func getRemoteBranchDisplayStrings(b *models.RemoteBranch, diffed bool) []string {
|
func getRemoteBranchDisplayStrings(b *models.RemoteBranch, diffed bool) []string {
|
||||||
nameColorAttr := GetBranchColor(b.Name)
|
textStyle := GetBranchTextStyle(b.Name)
|
||||||
if diffed {
|
if diffed {
|
||||||
nameColorAttr = theme.DiffTerminalColor
|
textStyle = theme.DiffTerminalColor
|
||||||
}
|
}
|
||||||
|
|
||||||
return []string{nameColorAttr.Sprint(b.Name)}
|
return []string{textStyle.Sprint(b.Name)}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ func GetRemoteListDisplayStrings(remotes []*models.Remote, diffName string) [][]
|
|||||||
func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
|
func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
|
||||||
branchCount := len(r.Branches)
|
branchCount := len(r.Branches)
|
||||||
|
|
||||||
nameColorAttr := theme.DefaultTextColor
|
textStyle := theme.DefaultTextColor
|
||||||
if diffed {
|
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)}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ func GetStashEntryListDisplayStrings(stashEntries []*models.StashEntry, diffName
|
|||||||
|
|
||||||
// getStashEntryDisplayStrings returns the display string of branch
|
// getStashEntryDisplayStrings returns the display string of branch
|
||||||
func getStashEntryDisplayStrings(s *models.StashEntry, diffed bool) []string {
|
func getStashEntryDisplayStrings(s *models.StashEntry, diffed bool) []string {
|
||||||
attr := theme.DefaultTextColor
|
textStyle := theme.DefaultTextColor
|
||||||
if diffed {
|
if diffed {
|
||||||
attr = theme.DiffTerminalColor
|
textStyle = theme.DiffTerminalColor
|
||||||
}
|
}
|
||||||
return []string{attr.Sprint(s.Name)}
|
return []string{textStyle.Sprint(s.Name)}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ func GetTagListDisplayStrings(tags []*models.Tag, diffName string) [][]string {
|
|||||||
|
|
||||||
// getTagDisplayStrings returns the display string of branch
|
// getTagDisplayStrings returns the display string of branch
|
||||||
func getTagDisplayStrings(t *models.Tag, diffed bool) []string {
|
func getTagDisplayStrings(t *models.Tag, diffed bool) []string {
|
||||||
attr := theme.DefaultTextColor
|
textStyle := theme.DefaultTextColor
|
||||||
if diffed {
|
if diffed {
|
||||||
attr = theme.DiffTerminalColor
|
textStyle = theme.DiffTerminalColor
|
||||||
}
|
}
|
||||||
return []string{attr.Sprint(t.Name)}
|
return []string{textStyle.Sprint(t.Name)}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ func (gui *Gui) refreshStatus() {
|
|||||||
status += style.FgYellow.Sprintf("(%s) ", gui.GitCommand.WorkingTreeState())
|
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()
|
repoName := utils.GetCurrentRepoName()
|
||||||
status += fmt.Sprintf("%s → %s ", repoName, name)
|
status += fmt.Sprintf("%s → %s ", repoName, name)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user