mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-04 03:48:07 +02:00
standardise how we handle background colours
This commit is contained in:
parent
d5db02a899
commit
267730bc00
@ -24,7 +24,7 @@ Default path for the config file:
|
||||
optionsTextColor:
|
||||
- blue
|
||||
selectedLineBgColor:
|
||||
- blue
|
||||
- bold
|
||||
commitLength:
|
||||
show: true
|
||||
mouseEvents: true
|
||||
@ -216,7 +216,18 @@ If you have issues with a light terminal theme where you can't read / see the te
|
||||
inactiveBorderColor:
|
||||
- black
|
||||
selectedLineBgColor:
|
||||
- blue
|
||||
- bold
|
||||
```
|
||||
|
||||
## Struggling to see selected line
|
||||
|
||||
If you struggle to see the selected line I recomment using the reverse attribute on selected lines like so:
|
||||
|
||||
```yaml
|
||||
gui:
|
||||
theme:
|
||||
selectedLineBgColor:
|
||||
- reverse
|
||||
```
|
||||
|
||||
## Example Coloring
|
||||
|
@ -256,7 +256,7 @@ func GetDefaultConfig() []byte {
|
||||
optionsTextColor:
|
||||
- blue
|
||||
selectedLineBgColor:
|
||||
- blue
|
||||
- bold
|
||||
commitLength:
|
||||
show: true
|
||||
git:
|
||||
|
@ -311,14 +311,15 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||
branchesView.ContainsList = true
|
||||
}
|
||||
|
||||
if v, err := g.SetViewBeneath("commitFiles", "branches", vHeights["commits"]); err != nil {
|
||||
commitFilesView, err := g.SetViewBeneath("commitFiles", "branches", vHeights["commits"])
|
||||
if err != nil {
|
||||
if err.Error() != "unknown view" {
|
||||
return err
|
||||
}
|
||||
v.Title = gui.Tr.SLocalize("CommitFiles")
|
||||
v.FgColor = textColor
|
||||
v.SetOnSelectItem(gui.onSelectItemWrapper(gui.onCommitFilesPanelSearchSelect))
|
||||
v.ContainsList = true
|
||||
commitFilesView.Title = gui.Tr.SLocalize("CommitFiles")
|
||||
commitFilesView.FgColor = textColor
|
||||
commitFilesView.SetOnSelectItem(gui.onSelectItemWrapper(gui.onCommitFilesPanelSearchSelect))
|
||||
commitFilesView.ContainsList = true
|
||||
}
|
||||
|
||||
commitsView, err := g.SetViewBeneath("commits", "branches", vHeights["commits"])
|
||||
@ -472,6 +473,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||
{view: commitsView, context: "branch-commits", selectedLine: gui.State.Panels.Commits.SelectedLine, lineCount: len(gui.State.Commits)},
|
||||
{view: commitsView, context: "reflog-commits", selectedLine: gui.State.Panels.ReflogCommits.SelectedLine, lineCount: len(gui.State.FilteredReflogCommits)},
|
||||
{view: stashView, context: "", selectedLine: gui.State.Panels.Stash.SelectedLine, lineCount: len(gui.State.StashEntries)},
|
||||
{view: commitFilesView, context: "", selectedLine: gui.State.Panels.CommitFiles.SelectedLine, lineCount: len(gui.State.CommitFiles)},
|
||||
}
|
||||
|
||||
// menu view might not exist so we check to be safe
|
||||
@ -485,6 +487,8 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||
}
|
||||
// check if the selected line is now out of view and if so refocus it
|
||||
listView.view.FocusPoint(0, listView.selectedLine)
|
||||
|
||||
listView.view.SelBgColor = theme.GocuiSelectedLineBgColor
|
||||
}
|
||||
|
||||
mainViewWidth, mainViewHeight := gui.getMainView().Size()
|
||||
|
@ -59,6 +59,7 @@ func (gui *Gui) coloredConflictFile(content string, conflicts []commands.Conflic
|
||||
colour := color.New(colourAttr)
|
||||
if hasFocus && conflictIndex < len(conflicts) && conflicts[conflictIndex] == conflict && gui.shouldHighlightLine(i, conflict, conflictTop) {
|
||||
colour.Add(color.Bold)
|
||||
colour.Add(theme.SelectedLineBgColor)
|
||||
}
|
||||
if i == conflict.End && len(remainingConflicts) > 0 {
|
||||
conflict, remainingConflicts = gui.shiftConflict(remainingConflicts)
|
||||
|
@ -28,9 +28,6 @@ func getFileDisplayStrings(f *commands.File, diffed bool) []string {
|
||||
return []string{red.Sprint(f.DisplayString)}
|
||||
}
|
||||
|
||||
output := green.Sprint(f.DisplayString[0:1])
|
||||
output += red.Sprint(f.DisplayString[1:3])
|
||||
|
||||
var restColor *color.Color
|
||||
if diffed {
|
||||
restColor = diffColor
|
||||
@ -39,6 +36,22 @@ func getFileDisplayStrings(f *commands.File, diffed bool) []string {
|
||||
} else {
|
||||
restColor = green
|
||||
}
|
||||
output += restColor.Sprint(f.Name)
|
||||
|
||||
// this is just making things look nice when the background attribute is 'reverse'
|
||||
firstChar := f.DisplayString[0:1]
|
||||
firstCharCl := green
|
||||
if firstChar == " " {
|
||||
firstCharCl = restColor
|
||||
}
|
||||
|
||||
secondChar := f.DisplayString[1:2]
|
||||
secondCharCl := red
|
||||
if secondChar == " " {
|
||||
secondCharCl = restColor
|
||||
}
|
||||
|
||||
output := firstCharCl.Sprint(firstChar)
|
||||
output += secondCharCl.Sprint(secondChar)
|
||||
output += restColor.Sprintf(" %s", f.Name)
|
||||
return []string{output}
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ var (
|
||||
// SelectedLineBgColor is the background color for the selected line
|
||||
SelectedLineBgColor color.Attribute
|
||||
|
||||
// GocuiSelectedLineBgColor is the background color for the selected line in gocui
|
||||
GocuiSelectedLineBgColor gocui.Attribute
|
||||
|
||||
OptionsFgColor color.Attribute
|
||||
|
||||
OptionsColor gocui.Attribute
|
||||
@ -36,6 +39,7 @@ func UpdateTheme(userConfig *viper.Viper) {
|
||||
ActiveBorderColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.activeBorderColor"))
|
||||
InactiveBorderColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.inactiveBorderColor"))
|
||||
SelectedLineBgColor = GetBgColor(userConfig.GetStringSlice("gui.theme.selectedLineBgColor"))
|
||||
GocuiSelectedLineBgColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.selectedLineBgColor"))
|
||||
OptionsColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.optionsTextColor"))
|
||||
OptionsFgColor = GetFgColor(userConfig.GetStringSlice("gui.theme.optionsTextColor"))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user