mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +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:
		| @@ -36,6 +36,9 @@ gui: | ||||
|       - bold | ||||
|     inactiveBorderColor: | ||||
|       - white | ||||
|     searchingActiveBorderColor: | ||||
|       - cyan | ||||
|       - bold | ||||
|     optionsTextColor: | ||||
|       - blue | ||||
|     selectedLineBgColor: | ||||
|   | ||||
| @@ -60,15 +60,16 @@ type GuiConfig struct { | ||||
| } | ||||
|  | ||||
| type ThemeConfig struct { | ||||
| 	ActiveBorderColor         []string `yaml:"activeBorderColor"` | ||||
| 	InactiveBorderColor       []string `yaml:"inactiveBorderColor"` | ||||
| 	OptionsTextColor          []string `yaml:"optionsTextColor"` | ||||
| 	SelectedLineBgColor       []string `yaml:"selectedLineBgColor"` | ||||
| 	SelectedRangeBgColor      []string `yaml:"selectedRangeBgColor"` | ||||
| 	CherryPickedCommitBgColor []string `yaml:"cherryPickedCommitBgColor"` | ||||
| 	CherryPickedCommitFgColor []string `yaml:"cherryPickedCommitFgColor"` | ||||
| 	UnstagedChangesColor      []string `yaml:"unstagedChangesColor"` | ||||
| 	DefaultFgColor            []string `yaml:"defaultFgColor"` | ||||
| 	ActiveBorderColor          []string `yaml:"activeBorderColor"` | ||||
| 	InactiveBorderColor        []string `yaml:"inactiveBorderColor"` | ||||
| 	SearchingActiveBorderColor []string `yaml:"searchingActiveBorderColor"` | ||||
| 	OptionsTextColor           []string `yaml:"optionsTextColor"` | ||||
| 	SelectedLineBgColor        []string `yaml:"selectedLineBgColor"` | ||||
| 	SelectedRangeBgColor       []string `yaml:"selectedRangeBgColor"` | ||||
| 	CherryPickedCommitBgColor  []string `yaml:"cherryPickedCommitBgColor"` | ||||
| 	CherryPickedCommitFgColor  []string `yaml:"cherryPickedCommitFgColor"` | ||||
| 	UnstagedChangesColor       []string `yaml:"unstagedChangesColor"` | ||||
| 	DefaultFgColor             []string `yaml:"defaultFgColor"` | ||||
| } | ||||
|  | ||||
| type CommitLengthConfig struct { | ||||
| @@ -409,15 +410,16 @@ func GetDefaultConfig() *UserConfig { | ||||
| 			TimeFormat:               "02 Jan 06", | ||||
| 			ShortTimeFormat:          time.Kitchen, | ||||
| 			Theme: ThemeConfig{ | ||||
| 				ActiveBorderColor:         []string{"green", "bold"}, | ||||
| 				InactiveBorderColor:       []string{"default"}, | ||||
| 				OptionsTextColor:          []string{"blue"}, | ||||
| 				SelectedLineBgColor:       []string{"blue"}, | ||||
| 				SelectedRangeBgColor:      []string{"blue"}, | ||||
| 				CherryPickedCommitBgColor: []string{"cyan"}, | ||||
| 				CherryPickedCommitFgColor: []string{"blue"}, | ||||
| 				UnstagedChangesColor:      []string{"red"}, | ||||
| 				DefaultFgColor:            []string{"default"}, | ||||
| 				ActiveBorderColor:          []string{"green", "bold"}, | ||||
| 				SearchingActiveBorderColor: []string{"cyan", "bold"}, | ||||
| 				InactiveBorderColor:        []string{"default"}, | ||||
| 				OptionsTextColor:           []string{"blue"}, | ||||
| 				SelectedLineBgColor:        []string{"blue"}, | ||||
| 				SelectedRangeBgColor:       []string{"blue"}, | ||||
| 				CherryPickedCommitBgColor:  []string{"cyan"}, | ||||
| 				CherryPickedCommitFgColor:  []string{"blue"}, | ||||
| 				UnstagedChangesColor:       []string{"red"}, | ||||
| 				DefaultFgColor:             []string{"default"}, | ||||
| 			}, | ||||
| 			CommitLength:                CommitLengthConfig{Show: true}, | ||||
| 			SkipNoStagedFilesWarning:    false, | ||||
|   | ||||
| @@ -201,11 +201,13 @@ func (self *SearchHelper) OnPromptContentChanged(searchString string) { | ||||
| func (self *SearchHelper) DisplaySearchStatusIfSearching(c types.Context) { | ||||
| 	if searchableContext, ok := c.(types.ISearchableContext); ok { | ||||
| 		if searchableContext.IsSearching() { | ||||
| 			self.setSearchingFrameColor() | ||||
| 			self.DisplaySearchStatus(searchableContext) | ||||
| 		} | ||||
| 	} | ||||
| 	if filterableContext, ok := c.(types.IFilterableContext); ok { | ||||
| 		if filterableContext.IsFiltering() { | ||||
| 			self.setSearchingFrameColor() | ||||
| 			self.DisplayFilterStatus(filterableContext) | ||||
| 		} | ||||
| 	} | ||||
| @@ -232,6 +234,18 @@ func (self *SearchHelper) CancelSearchIfSearching(c types.Context) { | ||||
| } | ||||
|  | ||||
| func (self *SearchHelper) HidePrompt() { | ||||
| 	self.setNonSearchingFrameColor() | ||||
|  | ||||
| 	state := self.searchState() | ||||
| 	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 | ||||
| } | ||||
|   | ||||
| @@ -91,10 +91,14 @@ func (gui *Gui) createAllViews() error { | ||||
| 	gui.Views.Options.Frame = false | ||||
|  | ||||
| 	gui.Views.SearchPrefix.BgColor = gocui.ColorDefault | ||||
| 	gui.Views.SearchPrefix.FgColor = gocui.ColorGreen | ||||
| 	gui.Views.SearchPrefix.FgColor = gocui.ColorCyan | ||||
| 	gui.Views.SearchPrefix.Frame = false | ||||
| 	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.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.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.FgColor = gocui.ColorCyan | ||||
| 	gui.Views.AppStatus.Visible = false | ||||
|   | ||||
| @@ -19,6 +19,9 @@ var ( | ||||
| 	// InactiveBorderColor is the border color of the inactive active frames | ||||
| 	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 gocui.Attribute | ||||
|  | ||||
| @@ -44,6 +47,7 @@ var ( | ||||
| func UpdateTheme(themeConfig config.ThemeConfig) { | ||||
| 	ActiveBorderColor = GetGocuiStyle(themeConfig.ActiveBorderColor) | ||||
| 	InactiveBorderColor = GetGocuiStyle(themeConfig.InactiveBorderColor) | ||||
| 	SearchingActiveBorderColor = GetGocuiStyle(themeConfig.SearchingActiveBorderColor) | ||||
| 	SelectedLineBgColor = GetTextStyle(themeConfig.SelectedLineBgColor, true) | ||||
| 	SelectedRangeBgColor = GetTextStyle(themeConfig.SelectedRangeBgColor, true) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user