From 5a8dc2d4b34cc7deae5cdb3493b02660aed54f02 Mon Sep 17 00:00:00 2001 From: Alexandru Placinta Date: Sun, 12 Nov 2023 18:52:10 +0100 Subject: [PATCH] Add colour config for container picker (#2140) --- internal/config/styles.go | 17 +++++++++++++++++ internal/view/picker.go | 9 ++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/internal/config/styles.go b/internal/config/styles.go index 89dbe630..9e119416 100644 --- a/internal/config/styles.go +++ b/internal/config/styles.go @@ -104,6 +104,7 @@ type ( Xray Xray `yaml:"xray"` Charts Charts `yaml:"charts"` Yaml Yaml `yaml:"yaml"` + Picker Picker `yaml:"picker"` Log Log `yaml:"logs"` } @@ -126,6 +127,13 @@ type ( Indicator LogIndicator `yaml:"indicator"` } + // Picker tracks color when selecting containers + Picker struct { + MainColor Color `yaml:"mainColor"` + FocusColor Color `yaml:"focusColor"` + ShortcutColor Color `yaml:"shortcutColor"` + } + // LogIndicator tracks log view indicator. LogIndicator struct { FgColor Color `yaml:"fgColor"` @@ -321,6 +329,7 @@ func newViews() Views { Xray: newXray(), Charts: newCharts(), Yaml: newYaml(), + Picker: newPicker(), Log: newLog(), } } @@ -370,6 +379,14 @@ func newStatus() Status { } } +func newPicker() Picker { + return Picker{ + MainColor: "white", + FocusColor: "aqua", + ShortcutColor: "aqua", + } +} + func newLog() Log { return Log{ FgColor: "lightskyblue", diff --git a/internal/view/picker.go b/internal/view/picker.go index 4ead1fca..c789a370 100644 --- a/internal/view/picker.go +++ b/internal/view/picker.go @@ -30,14 +30,17 @@ func (p *Picker) Init(ctx context.Context) error { if err != nil { return err } + + pickerView := app.Styles.Views().Picker p.actions[tcell.KeyEscape] = ui.NewKeyAction("Back", app.PrevCmd, true) p.SetBorder(true) - p.SetMainTextColor(tcell.ColorWhite) + p.SetMainTextColor(pickerView.MainColor.Color()) p.ShowSecondaryText(false) - p.SetShortcutColor(tcell.ColorAqua) - p.SetSelectedBackgroundColor(tcell.ColorAqua) + p.SetShortcutColor(pickerView.ShortcutColor.Color()) + p.SetSelectedBackgroundColor(pickerView.FocusColor.Color()) p.SetTitle(" [aqua::b]Containers Picker ") + p.SetInputCapture(func(evt *tcell.EventKey) *tcell.EventKey { if a, ok := p.actions[evt.Key()]; ok { a.Action(evt)