Fix #1163 add prompt styles (#1172)

mine
Fernand Galiana 2021-06-29 08:23:17 -06:00 committed by GitHub
parent 107c0acd33
commit 164b8658dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 93 additions and 15 deletions

View File

@ -35,6 +35,7 @@ type (
// Style tracks K9s styles. // Style tracks K9s styles.
Style struct { Style struct {
Body Body `yaml:"body"` Body Body `yaml:"body"`
Prompt Prompt `yaml:"prompt"`
Help Help `yaml:"help"` Help Help `yaml:"help"`
Frame Frame `yaml:"frame"` Frame Frame `yaml:"frame"`
Info Info `yaml:"info"` Info Info `yaml:"info"`
@ -42,6 +43,13 @@ type (
Dialog Dialog `yaml:"dialog"` Dialog Dialog `yaml:"dialog"`
} }
// Prompt tracks command styles
Prompt struct {
FgColor Color `yaml:"fgColor"`
BgColor Color `yaml:"bgColor"`
SuggestColor Color `yaml:"suggestColor"`
}
// Help tracks help styles. // Help tracks help styles.
Help struct { Help struct {
FgColor Color `yaml:"fgColor"` FgColor Color `yaml:"fgColor"`
@ -246,6 +254,7 @@ func (c Colors) Colors() []tcell.Color {
func newStyle() Style { func newStyle() Style {
return Style{ return Style{
Body: newBody(), Body: newBody(),
Prompt: newPrompt(),
Help: newHelp(), Help: newHelp(),
Frame: newFrame(), Frame: newFrame(),
Info: newInfo(), Info: newInfo(),
@ -267,6 +276,14 @@ func newDialog() Dialog {
} }
} }
func newPrompt() Prompt {
return Prompt{
FgColor: "cadetBlue",
BgColor: "black",
SuggestColor: "dodgerblue",
}
}
func newCharts() Charts { func newCharts() Charts {
return Charts{ return Charts{
BgColor: "black", BgColor: "black",

View File

@ -94,8 +94,8 @@ func NewPrompt(noIcons bool, styles *config.Styles) *Prompt {
p.SetDynamicColors(true) p.SetDynamicColors(true)
p.SetBorder(true) p.SetBorder(true)
p.SetBorderPadding(0, 0, 1, 1) p.SetBorderPadding(0, 0, 1, 1)
p.SetBackgroundColor(styles.BgColor()) p.SetBackgroundColor(styles.K9s.Prompt.BgColor.Color())
p.SetTextColor(styles.FgColor()) p.SetTextColor(styles.K9s.Prompt.FgColor.Color())
styles.AddListener(&p) styles.AddListener(&p)
p.SetInputCapture(p.keyboard) p.SetInputCapture(p.keyboard)
@ -164,8 +164,8 @@ func (p *Prompt) keyboard(evt *tcell.EventKey) *tcell.EventKey {
// StylesChanged notifies skin changed. // StylesChanged notifies skin changed.
func (p *Prompt) StylesChanged(s *config.Styles) { func (p *Prompt) StylesChanged(s *config.Styles) {
p.styles = s p.styles = s
p.SetBackgroundColor(s.BgColor()) p.SetBackgroundColor(s.K9s.Prompt.BgColor.Color())
p.SetTextColor(s.FgColor()) p.SetTextColor(s.K9s.Prompt.FgColor.Color())
} }
// InCmdMode returns true if command is active, false otherwise. // InCmdMode returns true if command is active, false otherwise.
@ -196,7 +196,7 @@ func (p *Prompt) write(text, suggest string) {
p.SetCursorIndex(p.spacer + len(text)) p.SetCursorIndex(p.spacer + len(text))
txt := text txt := text
if suggest != "" { if suggest != "" {
txt += "[dodgerblue::-]" + suggest txt += fmt.Sprintf("[%s::-]%s", p.styles.K9s.Prompt.SuggestColor, suggest)
} }
fmt.Fprintf(p, defaultPrompt, p.icon, txt) fmt.Fprintf(p, defaultPrompt, p.icon, txt)
} }

View File

@ -1,11 +1,11 @@
# Axual Skin contributed by [@JayKus](jimmy@axual.com) # Axual Skin contributed by [@JayKus](jimmy@axual.com)
# Style # Style
blue: &blue '#113851' blue: &blue "#113851"
red: &red '#D7595F' red: &red "#D7595F"
yellow: &yellow '#F2BF40' yellow: &yellow "#F2BF40"
cyan: &cyan '#47B0AB' cyan: &cyan "#47B0AB"
grey: &grey '#A99688' grey: &grey "#A99688"
light: &light '#F1EFE4' light: &light "#F1EFE4"
# Skin # Skin
k9s: k9s:
@ -13,7 +13,13 @@ k9s:
body: body:
fgColor: *yellow fgColor: *yellow
bgColor: *blue bgColor: *blue
logoColor: 'orange' logoColor: orange
# Command prompt styles
prompt:
fgColor: *yellow
bgColor: *blue
suggestColor: orange
# ClusterInfoView styles # ClusterInfoView styles
info: info:
@ -67,7 +73,7 @@ k9s:
bgColor: *blue bgColor: *blue
highlightColor: *cyan highlightColor: *cyan
counterColor: *light counterColor: *light
filterColor: 'slategray' filterColor: "slategray"
# Specific views styles # Specific views styles
views: views:
# TableView attributes. # TableView attributes.
@ -79,7 +85,7 @@ k9s:
header: header:
fgColor: *light fgColor: *light
bgColor: *blue bgColor: *blue
sorterColor: 'orange' sorterColor: "orange"
# Xray style # Xray style
xray: xray:

View File

@ -17,6 +17,10 @@ k9s:
fgColor: *fg fgColor: *fg
bgColor: *bg bgColor: *bg
logoColor: *fg logoColor: *fg
prompt:
fgColor: *fg
bgColor: *bg
suggestColor: &gray
info: info:
fgColor: *text fgColor: *text
sectionColor: *fg sectionColor: *fg

View File

@ -19,6 +19,11 @@ k9s:
fgColor: *foreground fgColor: *foreground
bgColor: *background bgColor: *background
logoColor: *purple logoColor: *purple
# Command prompt styles
prompt:
fgColor: *foreground
bgColor: *background
suggestColor: *purple
# ClusterInfoView styles. # ClusterInfoView styles.
info: info:
fgColor: *pink fgColor: *pink

View File

@ -16,6 +16,10 @@ k9s:
fgColor: *foreground fgColor: *foreground
bgColor: *background bgColor: *background
logoColor: *blue logoColor: *blue
prompt:
fgColor: *foreground
bgColor: *background
suggestColor: *orange
info: info:
fgColor: *magenta fgColor: *magenta
sectionColor: *foreground sectionColor: *foreground

View File

@ -16,6 +16,10 @@ k9s:
fgColor: *foreground fgColor: *foreground
bgColor: *background bgColor: *background
logoColor: *blue logoColor: *blue
prompt:
fgColor: *foreground
bgColor: *background
suggestColor: *orange
info: info:
fgColor: *magenta fgColor: *magenta
sectionColor: *foreground sectionColor: *foreground

View File

@ -23,6 +23,10 @@ k9s:
fgColor: *fg fgColor: *fg
bgColor: *bg bgColor: *bg
logoColor: *blue logoColor: *blue
prompt:
fgColor: *fg
bgColor: *bg
suggestColor: *cadet
info: info:
fgColor: *sky fgColor: *sky
sectionColor: *steel sectionColor: *steel

View File

@ -4,6 +4,10 @@ k9s:
fgColor: default fgColor: default
bgColor: default bgColor: default
logoColor: default logoColor: default
prompt:
fgColor: default
bgColor: default
suggestColor: default
info: info:
fgColor: default fgColor: default
sectionColor: default sectionColor: default

View File

@ -18,6 +18,11 @@ k9s:
fgColor: *foreground fgColor: *foreground
bgColor: *background bgColor: *background
logoColor: *magenta logoColor: *magenta
# Command prompt styles
prompt:
fgColor: *foreground
bgColor: *background
suggestColor: *orange
# ClusterInfoView styles. # ClusterInfoView styles.
info: info:
fgColor: *blue fgColor: *blue
@ -94,7 +99,7 @@ k9s:
- *magenta - *magenta
v1/pods: v1/pods:
- *blue - *blue
- *magenta - *magenta
# TableView attributes. # TableView attributes.
table: table:
fgColor: *foreground fgColor: *foreground

View File

@ -17,6 +17,11 @@ k9s:
fgColor: *foreground fgColor: *foreground
bgColor: default bgColor: default
logoColor: *magenta logoColor: *magenta
# Command prompt styles
prompt:
fgColor: *foreground
bgColor: *background
suggestColor: *orange
# ClusterInfoView styles. # ClusterInfoView styles.
info: info:
fgColor: *blue fgColor: *blue

View File

@ -16,6 +16,10 @@ k9s:
fgColor: *foreground fgColor: *foreground
bgColor: *background bgColor: *background
logoColor: *green logoColor: *green
prompt:
fgColor: *foreground
bgColor: *background
suggestColor: *orange
info: info:
fgColor: *grey fgColor: *grey
sectionColor: *green sectionColor: *green

View File

@ -3,6 +3,10 @@ k9s:
fgColor: "#97979b" fgColor: "#97979b"
bgColor: "#282a36" bgColor: "#282a36"
logoColor: "#5af78e" logoColor: "#5af78e"
prompt:
fgColor: "#97979b"
bgColor: "#282a36"
suggestColor: "#5af78e"
info: info:
fgColor: white fgColor: white
sectionColor: "#5af78e" sectionColor: "#5af78e"

View File

@ -16,6 +16,10 @@ k9s:
fgColor: *foreground fgColor: *foreground
bgColor: *background bgColor: *background
logoColor: *blue logoColor: *blue
prompt:
fgColor: *foreground
bgColor: *background
suggestColor: *orange
info: info:
fgColor: *magenta fgColor: *magenta
sectionColor: *foreground sectionColor: *foreground

View File

@ -17,6 +17,10 @@ k9s:
fgColor: *foreground fgColor: *foreground
bgColor: *background bgColor: *background
logoColor: *blue logoColor: *blue
prompt:
fgColor: *foreground
bgColor: *background
suggestColor: *orange
info: info:
fgColor: *magenta fgColor: *magenta
sectionColor: *foreground sectionColor: *foreground

View File

@ -3,6 +3,10 @@ k9s:
fgColor: dodgerblue fgColor: dodgerblue
bgColor: black bgColor: black
logoColor: orange logoColor: orange
prompt:
fgColor: cadetblue
bgColor: black
suggestColor: dodgerblue
info: info:
fgColor: white fgColor: white
sectionColor: dodgerblue sectionColor: dodgerblue