1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-01 13:17:53 +02:00

Color view frame differently when searching/filtering

Given that we now persist search/filter states even after a side context loses focus, we need to make it really
clear to the user that the context is currently being searched/filtered
This commit is contained in:
Jesse Duffield 2023-06-03 14:11:03 +10:00
parent 3ca1292fb4
commit 9df634f13f
5 changed files with 46 additions and 24 deletions

View File

@ -36,6 +36,9 @@ gui:
- bold - bold
inactiveBorderColor: inactiveBorderColor:
- white - white
searchingActiveBorderColor:
- cyan
- bold
optionsTextColor: optionsTextColor:
- blue - blue
selectedLineBgColor: selectedLineBgColor:

View File

@ -60,15 +60,16 @@ type GuiConfig struct {
} }
type ThemeConfig struct { type ThemeConfig struct {
ActiveBorderColor []string `yaml:"activeBorderColor"` ActiveBorderColor []string `yaml:"activeBorderColor"`
InactiveBorderColor []string `yaml:"inactiveBorderColor"` InactiveBorderColor []string `yaml:"inactiveBorderColor"`
OptionsTextColor []string `yaml:"optionsTextColor"` SearchingActiveBorderColor []string `yaml:"searchingActiveBorderColor"`
SelectedLineBgColor []string `yaml:"selectedLineBgColor"` OptionsTextColor []string `yaml:"optionsTextColor"`
SelectedRangeBgColor []string `yaml:"selectedRangeBgColor"` SelectedLineBgColor []string `yaml:"selectedLineBgColor"`
CherryPickedCommitBgColor []string `yaml:"cherryPickedCommitBgColor"` SelectedRangeBgColor []string `yaml:"selectedRangeBgColor"`
CherryPickedCommitFgColor []string `yaml:"cherryPickedCommitFgColor"` CherryPickedCommitBgColor []string `yaml:"cherryPickedCommitBgColor"`
UnstagedChangesColor []string `yaml:"unstagedChangesColor"` CherryPickedCommitFgColor []string `yaml:"cherryPickedCommitFgColor"`
DefaultFgColor []string `yaml:"defaultFgColor"` UnstagedChangesColor []string `yaml:"unstagedChangesColor"`
DefaultFgColor []string `yaml:"defaultFgColor"`
} }
type CommitLengthConfig struct { type CommitLengthConfig struct {
@ -409,15 +410,16 @@ func GetDefaultConfig() *UserConfig {
TimeFormat: "02 Jan 06", TimeFormat: "02 Jan 06",
ShortTimeFormat: time.Kitchen, ShortTimeFormat: time.Kitchen,
Theme: ThemeConfig{ Theme: ThemeConfig{
ActiveBorderColor: []string{"green", "bold"}, ActiveBorderColor: []string{"green", "bold"},
InactiveBorderColor: []string{"default"}, SearchingActiveBorderColor: []string{"cyan", "bold"},
OptionsTextColor: []string{"blue"}, InactiveBorderColor: []string{"default"},
SelectedLineBgColor: []string{"blue"}, OptionsTextColor: []string{"blue"},
SelectedRangeBgColor: []string{"blue"}, SelectedLineBgColor: []string{"blue"},
CherryPickedCommitBgColor: []string{"cyan"}, SelectedRangeBgColor: []string{"blue"},
CherryPickedCommitFgColor: []string{"blue"}, CherryPickedCommitBgColor: []string{"cyan"},
UnstagedChangesColor: []string{"red"}, CherryPickedCommitFgColor: []string{"blue"},
DefaultFgColor: []string{"default"}, UnstagedChangesColor: []string{"red"},
DefaultFgColor: []string{"default"},
}, },
CommitLength: CommitLengthConfig{Show: true}, CommitLength: CommitLengthConfig{Show: true},
SkipNoStagedFilesWarning: false, SkipNoStagedFilesWarning: false,

View File

@ -201,11 +201,13 @@ func (self *SearchHelper) OnPromptContentChanged(searchString string) {
func (self *SearchHelper) DisplaySearchStatusIfSearching(c types.Context) { func (self *SearchHelper) DisplaySearchStatusIfSearching(c types.Context) {
if searchableContext, ok := c.(types.ISearchableContext); ok { if searchableContext, ok := c.(types.ISearchableContext); ok {
if searchableContext.IsSearching() { if searchableContext.IsSearching() {
self.setSearchingFrameColor()
self.DisplaySearchStatus(searchableContext) self.DisplaySearchStatus(searchableContext)
} }
} }
if filterableContext, ok := c.(types.IFilterableContext); ok { if filterableContext, ok := c.(types.IFilterableContext); ok {
if filterableContext.IsFiltering() { if filterableContext.IsFiltering() {
self.setSearchingFrameColor()
self.DisplayFilterStatus(filterableContext) self.DisplayFilterStatus(filterableContext)
} }
} }
@ -232,6 +234,18 @@ func (self *SearchHelper) CancelSearchIfSearching(c types.Context) {
} }
func (self *SearchHelper) HidePrompt() { func (self *SearchHelper) HidePrompt() {
self.setNonSearchingFrameColor()
state := self.searchState() state := self.searchState()
state.Context = nil state.Context = nil
} }
func (self *SearchHelper) setSearchingFrameColor() {
self.c.GocuiGui().SelFgColor = theme.SearchingActiveBorderColor
self.c.GocuiGui().SelFrameColor = theme.SearchingActiveBorderColor
}
func (self *SearchHelper) setNonSearchingFrameColor() {
self.c.GocuiGui().SelFgColor = theme.ActiveBorderColor
self.c.GocuiGui().SelFrameColor = theme.ActiveBorderColor
}

View File

@ -91,10 +91,14 @@ func (gui *Gui) createAllViews() error {
gui.Views.Options.Frame = false gui.Views.Options.Frame = false
gui.Views.SearchPrefix.BgColor = gocui.ColorDefault gui.Views.SearchPrefix.BgColor = gocui.ColorDefault
gui.Views.SearchPrefix.FgColor = gocui.ColorGreen gui.Views.SearchPrefix.FgColor = gocui.ColorCyan
gui.Views.SearchPrefix.Frame = false gui.Views.SearchPrefix.Frame = false
gui.c.SetViewContent(gui.Views.SearchPrefix, gui.Tr.SearchPrefix) gui.c.SetViewContent(gui.Views.SearchPrefix, gui.Tr.SearchPrefix)
gui.Views.Search.BgColor = gocui.ColorDefault
gui.Views.Search.FgColor = gocui.ColorCyan
gui.Views.Search.Editable = true
gui.Views.Search.Frame = false
gui.Views.Search.Editor = gocui.EditorFunc(gui.searchEditor) gui.Views.Search.Editor = gocui.EditorFunc(gui.searchEditor)
gui.Views.Stash.Title = gui.c.Tr.StashTitle gui.Views.Stash.Title = gui.c.Tr.StashTitle
@ -143,11 +147,6 @@ func (gui *Gui) createAllViews() error {
gui.Views.Status.Title = gui.c.Tr.StatusTitle gui.Views.Status.Title = gui.c.Tr.StatusTitle
gui.Views.Search.BgColor = gocui.ColorDefault
gui.Views.Search.FgColor = gocui.ColorGreen
gui.Views.Search.Editable = true
gui.Views.Search.Frame = false
gui.Views.AppStatus.BgColor = gocui.ColorDefault gui.Views.AppStatus.BgColor = gocui.ColorDefault
gui.Views.AppStatus.FgColor = gocui.ColorCyan gui.Views.AppStatus.FgColor = gocui.ColorCyan
gui.Views.AppStatus.Visible = false gui.Views.AppStatus.Visible = false

View File

@ -19,6 +19,9 @@ var (
// InactiveBorderColor is the border color of the inactive active frames // InactiveBorderColor is the border color of the inactive active frames
InactiveBorderColor gocui.Attribute InactiveBorderColor gocui.Attribute
// FilteredActiveBorderColor is the border color of the active frame, when it's being searched/filtered
SearchingActiveBorderColor gocui.Attribute
// GocuiSelectedLineBgColor is the background color for the selected line in gocui // GocuiSelectedLineBgColor is the background color for the selected line in gocui
GocuiSelectedLineBgColor gocui.Attribute GocuiSelectedLineBgColor gocui.Attribute
@ -44,6 +47,7 @@ var (
func UpdateTheme(themeConfig config.ThemeConfig) { func UpdateTheme(themeConfig config.ThemeConfig) {
ActiveBorderColor = GetGocuiStyle(themeConfig.ActiveBorderColor) ActiveBorderColor = GetGocuiStyle(themeConfig.ActiveBorderColor)
InactiveBorderColor = GetGocuiStyle(themeConfig.InactiveBorderColor) InactiveBorderColor = GetGocuiStyle(themeConfig.InactiveBorderColor)
SearchingActiveBorderColor = GetGocuiStyle(themeConfig.SearchingActiveBorderColor)
SelectedLineBgColor = GetTextStyle(themeConfig.SelectedLineBgColor, true) SelectedLineBgColor = GetTextStyle(themeConfig.SelectedLineBgColor, true)
SelectedRangeBgColor = GetTextStyle(themeConfig.SelectedRangeBgColor, true) SelectedRangeBgColor = GetTextStyle(themeConfig.SelectedRangeBgColor, true)