Make menu foreground style configurable through skins (#2965)
* Make menu foreground style configurable through skins * Added menu fgStyle info to README --------- Co-authored-by: Fernand Galiana <fernand.galiana@gmail.com>mine
parent
cc1c86ccb4
commit
ea162b06e5
|
|
@ -1030,6 +1030,8 @@ k9s:
|
||||||
# MenuView attributes and styles.
|
# MenuView attributes and styles.
|
||||||
menu:
|
menu:
|
||||||
fgColor: darkblue
|
fgColor: darkblue
|
||||||
|
# Style of menu text. Supported options are "dim" (default), "normal", and "bold"
|
||||||
|
fgStyle: dim
|
||||||
keyColor: cornflowerblue
|
keyColor: cornflowerblue
|
||||||
# Used for favorite namespaces
|
# Used for favorite namespaces
|
||||||
numKeyColor: cadetblue
|
numKeyColor: cadetblue
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,27 @@ type StyleListener interface {
|
||||||
StylesChanged(*Styles)
|
StylesChanged(*Styles)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TextStyle string
|
||||||
|
|
||||||
|
const (
|
||||||
|
TextStyleNormal TextStyle = "normal"
|
||||||
|
TextStyleBold TextStyle = "bold"
|
||||||
|
TextStyleDim TextStyle = "dim"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (ts TextStyle) ToShortString() string {
|
||||||
|
switch ts {
|
||||||
|
case TextStyleNormal:
|
||||||
|
return "-"
|
||||||
|
case TextStyleBold:
|
||||||
|
return "b"
|
||||||
|
case TextStyleDim:
|
||||||
|
return "d"
|
||||||
|
default:
|
||||||
|
return "d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// Styles tracks K9s styling options.
|
// Styles tracks K9s styling options.
|
||||||
Styles struct {
|
Styles struct {
|
||||||
|
|
@ -200,9 +221,10 @@ type (
|
||||||
|
|
||||||
// Menu tracks menu styles.
|
// Menu tracks menu styles.
|
||||||
Menu struct {
|
Menu struct {
|
||||||
FgColor Color `json:"fgColor" yaml:"fgColor"`
|
FgColor Color `json:"fgColor" yaml:"fgColor"`
|
||||||
KeyColor Color `json:"keyColor" yaml:"keyColor"`
|
FgStyle TextStyle `json:"fgStyle" yaml:"fgStyle"`
|
||||||
NumKeyColor Color `json:"numKeyColor" yaml:"numKeyColor"`
|
KeyColor Color `json:"keyColor" yaml:"keyColor"`
|
||||||
|
NumKeyColor Color `json:"numKeyColor" yaml:"numKeyColor"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Charts tracks charts styles.
|
// Charts tracks charts styles.
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
menuIndexFmt = " [key:-:b]<%d> [fg:-:d]%s "
|
menuIndexFmt = " [key:-:b]<%d> [fg:-:fgstyle]%s "
|
||||||
maxRows = 6
|
maxRows = 6
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -199,15 +199,17 @@ func formatNSMenu(i int, name string, styles config.Frame) string {
|
||||||
fmat := strings.Replace(menuIndexFmt, "[key", "["+styles.Menu.NumKeyColor.String(), 1)
|
fmat := strings.Replace(menuIndexFmt, "[key", "["+styles.Menu.NumKeyColor.String(), 1)
|
||||||
fmat = strings.Replace(fmat, ":bg:", ":"+styles.Title.BgColor.String()+":", -1)
|
fmat = strings.Replace(fmat, ":bg:", ":"+styles.Title.BgColor.String()+":", -1)
|
||||||
fmat = strings.Replace(fmat, "[fg", "["+styles.Menu.FgColor.String(), 1)
|
fmat = strings.Replace(fmat, "[fg", "["+styles.Menu.FgColor.String(), 1)
|
||||||
|
fmat = strings.Replace(fmat, "fgstyle]", styles.Menu.FgStyle.ToShortString()+"]", 1)
|
||||||
|
|
||||||
return fmt.Sprintf(fmat, i, name)
|
return fmt.Sprintf(fmat, i, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatPlainMenu(h model.MenuHint, size int, styles config.Frame) string {
|
func formatPlainMenu(h model.MenuHint, size int, styles config.Frame) string {
|
||||||
menuFmt := " [key:-:b]%-" + strconv.Itoa(size+2) + "s [fg:-:d]%s "
|
menuFmt := " [key:-:b]%-" + strconv.Itoa(size+2) + "s [fg:-:fgstyle]%s "
|
||||||
fmat := strings.Replace(menuFmt, "[key", "["+styles.Menu.KeyColor.String(), 1)
|
fmat := strings.Replace(menuFmt, "[key", "["+styles.Menu.KeyColor.String(), 1)
|
||||||
fmat = strings.Replace(fmat, "[fg", "["+styles.Menu.FgColor.String(), 1)
|
fmat = strings.Replace(fmat, "[fg", "["+styles.Menu.FgColor.String(), 1)
|
||||||
fmat = strings.Replace(fmat, ":bg:", ":"+styles.Title.BgColor.String()+":", -1)
|
fmat = strings.Replace(fmat, ":bg:", ":"+styles.Title.BgColor.String()+":", -1)
|
||||||
|
fmat = strings.Replace(fmat, "fgstyle]", styles.Menu.FgStyle.ToShortString()+"]", 1)
|
||||||
|
|
||||||
return fmt.Sprintf(fmat, ToMnemonic(h.Mnemonic), h.Description)
|
return fmt.Sprintf(fmat, ToMnemonic(h.Mnemonic), h.Description)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ k9s:
|
||||||
focusColor: aqua
|
focusColor: aqua
|
||||||
menu:
|
menu:
|
||||||
fgColor: white
|
fgColor: white
|
||||||
|
fgStyle: dim
|
||||||
keyColor: dodgerblue
|
keyColor: dodgerblue
|
||||||
numKeyColor: fuchsia
|
numKeyColor: fuchsia
|
||||||
crumbs:
|
crumbs:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue