mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
refactor: remove ExtraPrompt
This commit is contained in:
parent
ee3b1127de
commit
b225c0ad39
|
@ -36,11 +36,11 @@ type Config struct {
|
||||||
TerminalBackground string `json:"terminal_background,omitempty"`
|
TerminalBackground string `json:"terminal_background,omitempty"`
|
||||||
Blocks []*Block `json:"blocks,omitempty"`
|
Blocks []*Block `json:"blocks,omitempty"`
|
||||||
Tooltips []*Segment `json:"tooltips,omitempty"`
|
Tooltips []*Segment `json:"tooltips,omitempty"`
|
||||||
TransientPrompt *ExtraPrompt `json:"transient_prompt,omitempty"`
|
TransientPrompt *Segment `json:"transient_prompt,omitempty"`
|
||||||
ValidLine *ExtraPrompt `json:"valid_line,omitempty"`
|
ValidLine *Segment `json:"valid_line,omitempty"`
|
||||||
ErrorLine *ExtraPrompt `json:"error_line,omitempty"`
|
ErrorLine *Segment `json:"error_line,omitempty"`
|
||||||
SecondaryPrompt *ExtraPrompt `json:"secondary_prompt,omitempty"`
|
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty"`
|
||||||
DebugPrompt *ExtraPrompt `json:"debug_prompt,omitempty"`
|
DebugPrompt *Segment `json:"debug_prompt,omitempty"`
|
||||||
Palette color.Palette `json:"palette,omitempty"`
|
Palette color.Palette `json:"palette,omitempty"`
|
||||||
|
|
||||||
Output string `json:"-"`
|
Output string `json:"-"`
|
||||||
|
@ -58,14 +58,6 @@ func (cfg *Config) MakeColors(env environment.Environment) color.AnsiColors {
|
||||||
return color.MakeColors(cfg.Palette, !cacheDisabled)
|
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) {
|
func (cfg *Config) print(message string) {
|
||||||
if cfg.eval {
|
if cfg.eval {
|
||||||
fmt.Printf("echo \"%s\"", message)
|
fmt.Printf("echo \"%s\"", message)
|
||||||
|
@ -130,7 +122,7 @@ func loadConfig(env environment.Environment) *Config {
|
||||||
|
|
||||||
// initialize default values
|
// initialize default values
|
||||||
if cfg.TransientPrompt == nil {
|
if cfg.TransientPrompt == nil {
|
||||||
cfg.TransientPrompt = &ExtraPrompt{}
|
cfg.TransientPrompt = &Segment{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &cfg
|
return &cfg
|
||||||
|
|
|
@ -280,7 +280,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
|
func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
|
||||||
var prompt *ExtraPrompt
|
var prompt *Segment
|
||||||
switch promptType {
|
switch promptType {
|
||||||
case Debug:
|
case Debug:
|
||||||
prompt = e.Config.DebugPrompt
|
prompt = e.Config.DebugPrompt
|
||||||
|
@ -294,7 +294,7 @@ func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
|
||||||
prompt = e.Config.SecondaryPrompt
|
prompt = e.Config.SecondaryPrompt
|
||||||
}
|
}
|
||||||
if prompt == nil {
|
if prompt == nil {
|
||||||
prompt = &ExtraPrompt{}
|
prompt = &Segment{}
|
||||||
}
|
}
|
||||||
getTemplate := func(template string) string {
|
getTemplate := func(template string) string {
|
||||||
if len(template) != 0 {
|
if len(template) != 0 {
|
||||||
|
|
Loading…
Reference in a new issue