@@ -105,9 +105,8 @@ var (
105
105
106
106
func setupUI () {
107
107
appleSiliconModel := getSOCInfo ()
108
- modelText = w .NewParagraph ()
108
+ modelText , helpText = w . NewParagraph (), w .NewParagraph ()
109
109
modelText .Title = "Apple Silicon"
110
- helpText = w .NewParagraph ()
111
110
helpText .Title = "Help Menu"
112
111
modelName , ok := appleSiliconModel ["name" ].(string )
113
112
if ! ok {
@@ -132,47 +131,28 @@ func setupUI() {
132
131
pCoreCount ,
133
132
gpuCoreCount ,
134
133
)
135
- helpText .Text = "- r: Refresh the UI data manually\n " +
136
- "- l: Toggle the main display's layout\n " +
137
- "- h: Toggle this help menu\n " +
138
- "- ?: Toggle this help menu\n " +
139
- "- q: Quit the application\n " +
140
- "- <C-c>: Quit the application"
134
+ helpText .Text = "- r: Refresh the UI data manually\n - l: Toggle the main display's layout\n - h: Toggle this help menu\n - ?: Toggle this help menu\n - q: Quit the application\n - <C-c>: Quit the application"
141
135
stderrLogger .Printf ("Model: %s\n E-Core Count: %d\n P-Core Count: %d\n GPU Core Count: %s" ,
142
136
modelName ,
143
137
eCoreCount ,
144
138
pCoreCount ,
145
139
gpuCoreCount ,
146
140
)
147
141
148
- cpu1Gauge = w .NewGauge ()
149
- cpu1Gauge .Title = "E-CPU Usage"
150
- cpu1Gauge .Percent = 0
151
- cpu1Gauge .BarColor = ui .ColorGreen
152
-
153
- cpu2Gauge = w .NewGauge ()
154
- cpu2Gauge .Title = "P-CPU Usage"
155
- cpu2Gauge .Percent = 0
156
- cpu2Gauge .BarColor = ui .ColorYellow
157
-
158
- gpuGauge = w .NewGauge ()
159
- gpuGauge .Title = "GPU Usage"
160
- gpuGauge .Percent = 0
161
- gpuGauge .BarColor = ui .ColorMagenta
162
-
163
- aneGauge = w .NewGauge ()
164
- aneGauge .Title = "ANE"
165
- aneGauge .Percent = 0
166
- aneGauge .BarColor = ui .ColorBlue
167
-
168
- PowerChart = w .NewParagraph ()
169
- PowerChart .Title = "Power Usage"
170
-
171
- NetworkInfo = w .NewParagraph ()
172
- NetworkInfo .Title = "Network & Disk Info"
142
+ gauges := []* w.Gauge {
143
+ w .NewGauge (), w .NewGauge (), w .NewGauge (), w .NewGauge (), w .NewGauge (),
144
+ }
145
+ titles := []string {"E-CPU Usage" , "P-CPU Usage" , "GPU Usage" , "ANE" , "Memory Usage" }
146
+ colors := []ui.Color {ui .ColorGreen , ui .ColorYellow , ui .ColorMagenta , ui .ColorBlue , ui .ColorCyan }
147
+ for i , gauge := range gauges {
148
+ gauge .Percent = 0
149
+ gauge .Title = titles [i ]
150
+ gauge .BarColor = colors [i ]
151
+ }
152
+ cpu1Gauge , cpu2Gauge , gpuGauge , aneGauge , memoryGauge = gauges [0 ], gauges [1 ], gauges [2 ], gauges [3 ], gauges [4 ]
173
153
174
- ProcessInfo = w .NewParagraph ()
175
- ProcessInfo .Title = "Process Info"
154
+ PowerChart , NetworkInfo , ProcessInfo = w . NewParagraph (), w . NewParagraph (), w .NewParagraph ()
155
+ PowerChart . Title , NetworkInfo . Title , ProcessInfo .Title = "Power Usage" , "Network & Disk Info" , "Process Info"
176
156
177
157
TotalPowerChart = w .NewBarChart ()
178
158
TotalPowerChart .Title = "~ W Total Power"
@@ -184,10 +164,6 @@ func setupUI() {
184
164
TotalPowerChart .NumFormatter = func (num float64 ) string {
185
165
return ""
186
166
}
187
- memoryGauge = w .NewGauge ()
188
- memoryGauge .Title = "Memory Usage"
189
- memoryGauge .Percent = 0
190
- memoryGauge .BarColor = ui .ColorCyan
191
167
}
192
168
193
169
func setupGrid () {
@@ -258,7 +234,8 @@ func switchGridLayout() {
258
234
}
259
235
260
236
func toggleHelpMenu () {
261
- if ! showHelp {
237
+ showHelp = ! showHelp
238
+ if showHelp {
262
239
newGrid := ui .NewGrid ()
263
240
newGrid .Set (
264
241
ui .NewRow (1.0 ,
@@ -270,16 +247,14 @@ func toggleHelpMenu() {
270
247
helpTextGridHeight := termHeight / 2
271
248
x := (termWidth - helpTextGridWidth ) / 2
272
249
y := (termHeight - helpTextGridHeight ) / 2
273
- newGrid .SetRect (x , y , x + helpTextGridWidth , y + helpTextGridHeight )
250
+ newGrid .SetRect (x , y , x + helpTextGridWidth , y + helpTextGridHeight )
274
251
grid = newGrid
275
- showHelp = ! showHelp
276
252
} else {
277
253
currentGridLayout = map [bool ]string {
278
- true : "alternative" ,
254
+ true : "alternative" ,
279
255
false : "default" ,
280
256
}[currentGridLayout == "default" ]
281
257
switchGridLayout ()
282
- showHelp = ! showHelp
283
258
}
284
259
}
285
260
0 commit comments