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

View File

@ -94,8 +94,8 @@ func NewPrompt(noIcons bool, styles *config.Styles) *Prompt {
p.SetDynamicColors(true)
p.SetBorder(true)
p.SetBorderPadding(0, 0, 1, 1)
p.SetBackgroundColor(styles.BgColor())
p.SetTextColor(styles.FgColor())
p.SetBackgroundColor(styles.K9s.Prompt.BgColor.Color())
p.SetTextColor(styles.K9s.Prompt.FgColor.Color())
styles.AddListener(&p)
p.SetInputCapture(p.keyboard)
@ -164,8 +164,8 @@ func (p *Prompt) keyboard(evt *tcell.EventKey) *tcell.EventKey {
// StylesChanged notifies skin changed.
func (p *Prompt) StylesChanged(s *config.Styles) {
p.styles = s
p.SetBackgroundColor(s.BgColor())
p.SetTextColor(s.FgColor())
p.SetBackgroundColor(s.K9s.Prompt.BgColor.Color())
p.SetTextColor(s.K9s.Prompt.FgColor.Color())
}
// 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))
txt := text
if suggest != "" {
txt += "[dodgerblue::-]" + suggest
txt += fmt.Sprintf("[%s::-]%s", p.styles.K9s.Prompt.SuggestColor, suggest)
}
fmt.Fprintf(p, defaultPrompt, p.icon, txt)
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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