summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-05-13 21:10:00 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-05-13 21:24:25 +1000
commit267730bc0059eacd0327eebbaa3b9efd04ee8464 (patch)
tree33be8d44df0ad19ff38c5a8a266b761be7737cbd
parentd5db02a899540661162ca3b816cd559ff577fff2 (diff)
standardise how we handle background coloursv0.20.3
-rw-r--r--docs/Config.md15
-rw-r--r--pkg/config/app_config.go2
-rw-r--r--pkg/gui/layout.go14
-rw-r--r--pkg/gui/merge_panel.go1
-rw-r--r--pkg/gui/presentation/files.go21
-rw-r--r--pkg/theme/theme.go4
6 files changed, 45 insertions, 12 deletions
diff --git a/docs/Config.md b/docs/Config.md
index 6f5969ee5..3685126cd 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -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
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go
index a36512ee1..7d1648b6f 100644
--- a/pkg/config/app_config.go
+++ b/pkg/config/app_config.go
@@ -256,7 +256,7 @@ func GetDefaultConfig() []byte {
optionsTextColor:
- blue
selectedLineBgColor:
- - blue
+ - bold
commitLength:
show: true
git:
diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go
index a10d661e9..f5385e934 100644
--- a/pkg/gui/layout.go
+++ b/pkg/gui/layout.go
@@ -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()
diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go
index 4d9a258fc..d30f152ac 100644
--- a/pkg/gui/merge_panel.go
+++ b/pkg/gui/merge_panel.go
@@ -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)
diff --git a/pkg/gui/presentation/files.go b/pkg/gui/presentation/files.go
index 3e70617fa..a16abdce6 100644
--- a/pkg/gui/presentation/files.go
+++ b/pkg/gui/presentation/files.go
@@ -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}
}
diff --git a/pkg/theme/theme.go b/pkg/theme/theme.go
index ccb6bef08..259edfe04 100644
--- a/pkg/theme/theme.go
+++ b/pkg/theme/theme.go
@@ -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"))