|
1 | 1 | package view |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "sync/atomic" |
5 | 6 |
|
6 | 7 | "github.com/derailed/k9s/internal/config" |
@@ -47,6 +48,7 @@ func NewLogIndicator(cfg *config.Config, styles *config.Styles, allContainers bo |
47 | 48 | func (l *LogIndicator) StylesChanged(styles *config.Styles) { |
48 | 49 | l.SetBackgroundColor(styles.K9s.Views.Log.Indicator.BgColor.Color()) |
49 | 50 | l.SetTextColor(styles.K9s.Views.Log.Indicator.FgColor.Color()) |
| 51 | + l.Refresh() |
50 | 52 | } |
51 | 53 |
|
52 | 54 | // AutoScroll reports the current scrolling status. |
@@ -111,36 +113,39 @@ func (l *LogIndicator) reset() { |
111 | 113 | func (l *LogIndicator) Refresh() { |
112 | 114 | l.reset() |
113 | 115 |
|
| 116 | + toggleOnFormat := "[::b]%s:[" + string(l.styles.K9s.Views.Log.Indicator.ToggleOnColor) + "::b]On[-::] %s" |
| 117 | + toggleOffFormat := "[::b]%s:[" + string(l.styles.K9s.Views.Log.Indicator.ToggleOffColor) + "::d]Off[-::]%s" |
| 118 | + |
114 | 119 | if l.shouldDisplayAllContainers { |
115 | 120 | if l.allContainers { |
116 | | - l.indicator = append(l.indicator, "[::b]AllContainers:[limegreen::b]On[-::] "+spacer...) |
| 121 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOnFormat, "AllContainers", spacer)...) |
117 | 122 | } else { |
118 | | - l.indicator = append(l.indicator, "[::b]AllContainers:[gray::d]Off[-::]"+spacer...) |
| 123 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOffFormat, "AllContainers", spacer)...) |
119 | 124 | } |
120 | 125 | } |
121 | 126 |
|
122 | 127 | if l.AutoScroll() { |
123 | | - l.indicator = append(l.indicator, "[::b]Autoscroll:[limegreen::b]On[-::] "+spacer...) |
| 128 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOnFormat, "Autoscroll", spacer)...) |
124 | 129 | } else { |
125 | | - l.indicator = append(l.indicator, "[::b]Autoscroll:[gray::d]Off[-::]"+spacer...) |
| 130 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOffFormat, "Autoscroll", spacer)...) |
126 | 131 | } |
127 | 132 |
|
128 | 133 | if l.FullScreen() { |
129 | | - l.indicator = append(l.indicator, "[::b]FullScreen:[limegreen::b]On[-::] "+spacer...) |
| 134 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOnFormat, "FullScreen", spacer)...) |
130 | 135 | } else { |
131 | | - l.indicator = append(l.indicator, "[::b]FullScreen:[gray::d]Off[-::]"+spacer...) |
| 136 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOffFormat, "FullScreen", spacer)...) |
132 | 137 | } |
133 | 138 |
|
134 | 139 | if l.Timestamp() { |
135 | | - l.indicator = append(l.indicator, "[::b]Timestamps:[limegreen::b]On[-::] "+spacer...) |
| 140 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOnFormat, "Timestamps", spacer)...) |
136 | 141 | } else { |
137 | | - l.indicator = append(l.indicator, "[::b]Timestamps:[gray::d]Off[-::]"+spacer...) |
| 142 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOffFormat, "Timestamps", spacer)...) |
138 | 143 | } |
139 | 144 |
|
140 | 145 | if l.TextWrap() { |
141 | | - l.indicator = append(l.indicator, "[::b]Wrap:[limegreen::b]On[-::] "...) |
| 146 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOnFormat, "Wrap", "")...) |
142 | 147 | } else { |
143 | | - l.indicator = append(l.indicator, "[::b]Wrap:[gray::d]Off[-::]"...) |
| 148 | + l.indicator = append(l.indicator, fmt.Sprintf(toggleOffFormat, "Wrap", "")...) |
144 | 149 | } |
145 | 150 |
|
146 | 151 | _, _ = l.Write(l.indicator) |
|
0 commit comments