refactor: remove ExtraPrompt

This commit is contained in:
Jan De Dobbeleer 2022-03-27 15:38:12 +02:00 committed by Jan De Dobbeleer
parent ee3b1127de
commit b225c0ad39
2 changed files with 8 additions and 16 deletions

View file

@ -36,11 +36,11 @@ type Config struct {
TerminalBackground string `json:"terminal_background,omitempty"`
Blocks []*Block `json:"blocks,omitempty"`
Tooltips []*Segment `json:"tooltips,omitempty"`
TransientPrompt *ExtraPrompt `json:"transient_prompt,omitempty"`
ValidLine *ExtraPrompt `json:"valid_line,omitempty"`
ErrorLine *ExtraPrompt `json:"error_line,omitempty"`
SecondaryPrompt *ExtraPrompt `json:"secondary_prompt,omitempty"`
DebugPrompt *ExtraPrompt `json:"debug_prompt,omitempty"`
TransientPrompt *Segment `json:"transient_prompt,omitempty"`
ValidLine *Segment `json:"valid_line,omitempty"`
ErrorLine *Segment `json:"error_line,omitempty"`
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty"`
DebugPrompt *Segment `json:"debug_prompt,omitempty"`
Palette color.Palette `json:"palette,omitempty"`
Output string `json:"-"`
@ -58,14 +58,6 @@ func (cfg *Config) MakeColors(env environment.Environment) color.AnsiColors {
return color.MakeColors(cfg.Palette, !cacheDisabled)
}
type ExtraPrompt struct {
Template string `json:"template,omitempty"`
Foreground string `json:"foreground,omitempty"`
ForegroundTemplates color.Templates `json:"foreground_templates,omitempty"`
Background string `json:"background,omitempty"`
BackgroundTemplates color.Templates `json:"background_templates,omitempty"`
}
func (cfg *Config) print(message string) {
if cfg.eval {
fmt.Printf("echo \"%s\"", message)
@ -130,7 +122,7 @@ func loadConfig(env environment.Environment) *Config {
// initialize default values
if cfg.TransientPrompt == nil {
cfg.TransientPrompt = &ExtraPrompt{}
cfg.TransientPrompt = &Segment{}
}
return &cfg

View file

@ -280,7 +280,7 @@ const (
)
func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
var prompt *ExtraPrompt
var prompt *Segment
switch promptType {
case Debug:
prompt = e.Config.DebugPrompt
@ -294,7 +294,7 @@ func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
prompt = e.Config.SecondaryPrompt
}
if prompt == nil {
prompt = &ExtraPrompt{}
prompt = &Segment{}
}
getTemplate := func(template string) string {
if len(template) != 0 {