From 6390b056785f6ea3e64acbe58eac163c18af1cbe Mon Sep 17 00:00:00 2001 From: Olivia Bahr Date: Sat, 27 Apr 2024 00:35:25 +0000 Subject: [PATCH] Add three theme options - Make title color options separate from border color options - Add option to change title color of selected tabs in inactive views --- docs/Config.md | 7 ++++ pkg/config/user_config.go | 9 +++++ pkg/gui/controllers/helpers/search_helper.go | 2 +- pkg/gui/gui.go | 5 +-- pkg/theme/theme.go | 12 +++++++ schema/config.json | 37 ++++++++++++++++++++ vendor/github.com/jesseduffield/gocui/gui.go | 24 ++++++++----- 7 files changed, 84 insertions(+), 12 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index c6f5cbbf951..b8745bb181f 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -53,6 +53,13 @@ gui: searchingActiveBorderColor: - cyan - bold + activeTitleColor: + - green + - bold + inactiveTitleColor: + - default + inactiveSelTabTitleColor: # style of 'current tab' title in inactive views + - default # 'default' is activeTitleColor without bold optionsTextColor: - blue selectedLineBgColor: diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 29b46e903d0..b94302a6248 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -161,6 +161,12 @@ type ThemeConfig struct { ActiveBorderColor []string `yaml:"activeBorderColor" jsonschema:"minItems=1,uniqueItems=true"` // Border color of non-focused windows InactiveBorderColor []string `yaml:"inactiveBorderColor" jsonschema:"minItems=1,uniqueItems=true"` + // Title color of focused window + ActiveTitleColor []string `yaml:"activeTitleColor" jsonschema:"minItems=1,uniqueItems=true"` + // Title color of non-focused window + InactiveTitleColor []string `yaml:"inactiveTitleColor" jsonschema:"minItems=1,uniqueItems=true"` + // Title color of selected tab in non-focused window + InactiveSelTabTitleColor []string `yaml:"inactiveSelTabTitleColor" jsonschema:"minItems=1,uniqueItems=true"` // Border color of focused window when searching in that window SearchingActiveBorderColor []string `yaml:"searchingActiveBorderColor" jsonschema:"minItems=1,uniqueItems=true"` // Color of keybindings help text in the bottom line @@ -655,6 +661,9 @@ func GetDefaultConfig() *UserConfig { ActiveBorderColor: []string{"green", "bold"}, SearchingActiveBorderColor: []string{"cyan", "bold"}, InactiveBorderColor: []string{"default"}, + ActiveTitleColor: []string{"green", "bold"}, + InactiveTitleColor: []string{"default"}, + InactiveSelTabTitleColor: []string{"default"}, OptionsTextColor: []string{"blue"}, SelectedLineBgColor: []string{"blue"}, CherryPickedCommitBgColor: []string{"cyan"}, diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index c317209499c..aedab46767f 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -295,6 +295,6 @@ func (self *SearchHelper) setSearchingFrameColor() { } func (self *SearchHelper) setNonSearchingFrameColor() { - self.c.GocuiGui().SelFgColor = theme.ActiveBorderColor + self.c.GocuiGui().SelFgColor = theme.ActiveTitleColor self.c.GocuiGui().SelFrameColor = theme.ActiveBorderColor } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 4bb910bf292..feb892ff8a2 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -944,8 +944,9 @@ func (gui *Gui) setColorScheme() error { userConfig := gui.UserConfig theme.UpdateTheme(userConfig.Gui.Theme) - gui.g.FgColor = theme.InactiveBorderColor - gui.g.SelFgColor = theme.ActiveBorderColor + gui.g.FgColor = theme.InactiveTitleColor + gui.g.SelFgColor = theme.ActiveTitleColor + gui.g.InactiveSelFgColor = theme.InactiveSelTabTitleColor gui.g.FrameColor = theme.InactiveBorderColor gui.g.SelFrameColor = theme.ActiveBorderColor diff --git a/pkg/theme/theme.go b/pkg/theme/theme.go index 78be46fb635..ee3dc404354 100644 --- a/pkg/theme/theme.go +++ b/pkg/theme/theme.go @@ -19,6 +19,15 @@ var ( // InactiveBorderColor is the border color of the inactive active frames InactiveBorderColor gocui.Attribute + // ActiveTitleColor is the foreground color of the active view title + ActiveTitleColor gocui.Attribute + + // InactiveTitleColor is the foreground color of the inactive view titles + InactiveTitleColor gocui.Attribute + + // InactiveSelTabTitleColor is the foreground color of title of 'current' tab in inactive views + InactiveSelTabTitleColor gocui.Attribute + // FilteredActiveBorderColor is the border color of the active frame, when it's being searched/filtered SearchingActiveBorderColor gocui.Attribute @@ -47,6 +56,9 @@ var ( func UpdateTheme(themeConfig config.ThemeConfig) { ActiveBorderColor = GetGocuiStyle(themeConfig.ActiveBorderColor) InactiveBorderColor = GetGocuiStyle(themeConfig.InactiveBorderColor) + ActiveTitleColor = GetGocuiStyle(themeConfig.ActiveTitleColor) + InactiveTitleColor = GetGocuiStyle(themeConfig.InactiveTitleColor) + InactiveSelTabTitleColor = GetGocuiStyle(themeConfig.InactiveSelTabTitleColor) SearchingActiveBorderColor = GetGocuiStyle(themeConfig.SearchingActiveBorderColor) SelectedLineBgColor = GetTextStyle(themeConfig.SelectedLineBgColor, true) diff --git a/schema/config.json b/schema/config.json index 5d259cbd418..2ee67f6caaa 100644 --- a/schema/config.json +++ b/schema/config.json @@ -139,6 +139,43 @@ "default" ] }, + "activeTitleColor": { + "items": { + "type": "string" + }, + "type": "array", + "minItems": 1, + "uniqueItems": true, + "description": "Title color of focused window", + "default": [ + "blue", + "bold" + ] + }, + "inactiveTitleColor": { + "items": { + "type": "string" + }, + "type": "array", + "minItems": 1, + "uniqueItems": true, + "description": "Title color of non-focused window", + "default": [ + "default" + ] + }, + "inactiveSelTabTitleColor": { + "items": { + "type": "string" + }, + "type": "array", + "minItems": 1, + "uniqueItems": true, + "description": "Title color of selected tab in non-focused window", + "default": [ + "default" + ] + }, "searchingActiveBorderColor": { "items": { "type": "string" diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go index e2593b98589..798ae85084a 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/vendor/github.com/jesseduffield/gocui/gui.go @@ -141,7 +141,7 @@ type Gui struct { // SelBgColor and SelFgColor allow to configure the background and // foreground colors of the frame of the current view. - SelBgColor, SelFgColor, SelFrameColor Attribute + SelBgColor, SelFgColor, InactiveSelFgColor, SelFrameColor Attribute // If Highlight is true, Sel{Bg,Fg}Colors will be used to draw the // frame of the current view. @@ -235,7 +235,7 @@ func NewGui(opts NewGuiOpts) (*Gui, error) { } g.BgColor, g.FgColor, g.FrameColor = ColorDefault, ColorDefault, ColorDefault - g.SelBgColor, g.SelFgColor, g.SelFrameColor = ColorDefault, ColorDefault, ColorDefault + g.SelBgColor, g.SelFgColor, g.InactiveSelFgColor, g.SelFrameColor = ColorDefault, ColorDefault, ColorDefault, ColorDefault // SupportOverlaps is true when we allow for view edges to overlap with other // view edges @@ -1063,18 +1063,24 @@ func (g *Gui) drawTitle(v *View, fgColor, bgColor Attribute) error { } currentFgColor := fgColor currentBgColor := bgColor - // if you are the current view and you have multiple tabs, de-highlight the non-selected tabs - if v == g.currentView && len(v.Tabs) > 0 { + + // if view has tabs, only highlight the current tab + if len(v.Tabs) > 0 { currentFgColor = v.FgColor currentBgColor = v.BgColor - } - if i >= currentTabStart && i <= currentTabEnd { - currentFgColor = v.SelFgColor - if v != g.currentView { - currentFgColor -= AttrBold + if i >= currentTabStart && i <= currentTabEnd { + currentFgColor = v.SelFgColor + if v != g.currentView { + if g.InactiveSelFgColor != ColorDefault { + currentFgColor = g.InactiveSelFgColor + } else { + currentFgColor -= AttrBold + } + } } } + if err := g.SetRune(x, v.y0, ch, currentFgColor, currentBgColor); err != nil { return err }