-
Notifications
You must be signed in to change notification settings - Fork 9
/
ui.go
636 lines (587 loc) · 18.3 KB
/
ui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
package main
import (
"fmt"
"strconv"
"github.com/eeeXun/gtt/internal/style"
"github.com/eeeXun/gtt/internal/translate"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
type Item struct {
item tview.Primitive
fixedSize int
proportion int
focus bool
}
const (
popOutMenuHeight int = 20
langStrMaxLength int = 32
keyMapText string = `[#%[1]s]<C-c>[-]
Exit program.
[#%[1]s]<Esc>[-]
Toggle pop out menu.
[#%[1]s]<%[2]s>[-]
Translate from source to destination window.
[#%[1]s]<%[3]s>[-]
Swap language.
[#%[1]s]<%[4]s>[-]
Clear all text in source of translation window.
[#%[1]s]<%[5]s>[-]
Copy selected text.
[#%[1]s]<%[6]s>[-]
Copy all text in source of translation window.
[#%[1]s]<%[7]s>[-]
Copy all text in destination of translation window.
[#%[1]s]<%[8]s>[-]
Play text to speech on source of translation window.
[#%[1]s]<%[9]s>[-]
Play text to speech on destination of translation window.
[#%[1]s]<%[10]s>[-]
Stop playing text to speech.
[#%[1]s]<%[11]s>[-]
Toggle transparent.
[#%[1]s]<%[12]s>[-]
Toggle Definition/Example & Part of speech.
[#%[1]s]<Tab>, <S-Tab>[-]
Cycle through the pop out widget.
[#%[1]s]<1>, <2>, <3>[-]
Switch pop out menu.`
)
func updateTranslateWindow() {
if uiStyle.HideBelow {
translateWindow.RemoveItem(translateBelowWidget)
} else {
translateWindow.AddItem(translateBelowWidget, 0, 1, false)
}
}
func updateBackgroundColor() {
// input/output
srcInput.SetTextStyle(tcell.StyleDefault.
Background(uiStyle.BackgroundColor()).
Foreground(uiStyle.ForegroundColor())).
SetBackgroundColor(uiStyle.BackgroundColor())
dstOutput.SetBackgroundColor(uiStyle.BackgroundColor())
defOutput.SetTextStyle(tcell.StyleDefault.
Background(uiStyle.BackgroundColor()).
Foreground(uiStyle.ForegroundColor())).
SetBackgroundColor(uiStyle.BackgroundColor())
posOutput.SetTextStyle(tcell.StyleDefault.
Background(uiStyle.BackgroundColor()).
Foreground(uiStyle.ForegroundColor())).
SetBackgroundColor(uiStyle.BackgroundColor())
// dropdown
for _, dropdown := range []*tview.DropDown{
translatorDropDown,
srcLangDropDown,
dstLangDropDown,
themeDropDown,
transparentDropDown,
hideBelowDropDown,
osc52DropDown,
srcBorderDropDown,
dstBorderDropDown} {
dropdown.SetListStyles(tcell.StyleDefault.
Background(uiStyle.BackgroundColor()).
Foreground(uiStyle.ForegroundColor()),
tcell.StyleDefault.
Background(uiStyle.SelectedColor()).
Foreground(uiStyle.PrefixColor())).
SetBackgroundColor(uiStyle.BackgroundColor())
}
// key map
keyMapMenu.SetBackgroundColor(uiStyle.BackgroundColor())
}
func updateBorderColor() {
// input/output
srcInput.SetBorderColor(uiStyle.SrcBorderColor()).
SetTitleColor(uiStyle.SrcBorderColor())
dstOutput.SetBorderColor(uiStyle.DstBorderColor()).
SetTitleColor(uiStyle.DstBorderColor())
defOutput.SetBorderColor(uiStyle.SrcBorderColor()).
SetTitleColor(uiStyle.SrcBorderColor())
posOutput.SetBorderColor(uiStyle.DstBorderColor()).
SetTitleColor(uiStyle.DstBorderColor())
// dropdown
for _, srcDropDown := range []*tview.DropDown{srcLangDropDown, srcBorderDropDown} {
srcDropDown.SetBorderColor(uiStyle.SrcBorderColor()).
SetTitleColor(uiStyle.SrcBorderColor())
}
for _, dstDropDown := range []*tview.DropDown{dstLangDropDown, dstBorderDropDown} {
dstDropDown.SetBorderColor(uiStyle.DstBorderColor()).
SetTitleColor(uiStyle.DstBorderColor())
}
}
func updateNonConfigColor() {
// input/output
srcInput.SetSelectedStyle(tcell.StyleDefault.
Background(uiStyle.SelectedColor()).
Foreground(uiStyle.ForegroundColor()))
dstOutput.SetTextColor(uiStyle.ForegroundColor())
defOutput.SetSelectedStyle(tcell.StyleDefault.
Background(uiStyle.SelectedColor()).
Foreground(uiStyle.ForegroundColor()))
posOutput.SetSelectedStyle(tcell.StyleDefault.
Background(uiStyle.SelectedColor()).
Foreground(uiStyle.ForegroundColor()))
// dropdown
for _, noLabelDropDown := range []*tview.DropDown{srcLangDropDown, dstLangDropDown} {
noLabelDropDown.SetFieldBackgroundColor(uiStyle.SelectedColor()).
SetFieldTextColor(uiStyle.ForegroundColor()).
SetPrefixTextColor(uiStyle.PrefixColor())
}
for _, labelDropDown := range []*tview.DropDown{
translatorDropDown,
themeDropDown,
transparentDropDown,
hideBelowDropDown,
osc52DropDown,
srcBorderDropDown,
dstBorderDropDown} {
labelDropDown.SetLabelColor(uiStyle.LabelColor()).
SetFieldBackgroundColor(uiStyle.SelectedColor()).
SetFieldTextColor(uiStyle.ForegroundColor()).
SetPrefixTextColor(uiStyle.PrefixColor())
}
// button
for _, button := range []*tview.Button{langButton, styleButton, keyMapButton} {
button.SetStyle(tcell.StyleDefault.
Background(uiStyle.SelectedColor()).
Foreground(uiStyle.ForegroundColor())).
SetActivatedStyle(
tcell.StyleDefault.
Background(uiStyle.PressColor()).
Foreground(uiStyle.ForegroundColor()))
}
// key map
keyMapMenu.SetTextColor(uiStyle.ForegroundColor()).
SetText(fmt.Sprintf(keyMapText,
fmt.Sprintf("%.6x", uiStyle.HighLightColor().TrueColor().Hex()),
keyMaps["translate"],
keyMaps["swap_language"],
keyMaps["clear"],
keyMaps["copy_selected"],
keyMaps["copy_source"],
keyMaps["copy_destination"],
keyMaps["tts_source"],
keyMaps["tts_destination"],
keyMaps["stop_tts"],
keyMaps["toggle_transparent"],
keyMaps["toggle_below"],
)).
SetBorderColor(uiStyle.HighLightColor()).
SetTitleColor(uiStyle.HighLightColor())
}
func updateAllColor() {
updateBackgroundColor()
updateBorderColor()
updateNonConfigColor()
}
// SetSelectedFunc of DropDown need to update when options change
func updateLangDropDown() {
srcLangDropDown.SetOptions(translator.GetAllLang(),
func(text string, index int) {
translator.SetSrcLang(text)
srcInput.SetTitle(text)
srcLangDropDown.SetTitle(text)
})
dstLangDropDown.SetOptions(translator.GetAllLang(),
func(text string, index int) {
translator.SetDstLang(text)
dstOutput.SetTitle(text)
dstLangDropDown.SetTitle(text)
})
}
// Update language title and option
func updateCurrentLang() {
srcInput.SetTitle(translator.GetSrcLang())
dstOutput.SetTitle(translator.GetDstLang())
srcLangDropDown.SetCurrentOption(
IndexOf(translator.GetSrcLang(), translator.GetAllLang())).
SetTitle(translator.GetSrcLang())
dstLangDropDown.SetCurrentOption(
IndexOf(translator.GetDstLang(), translator.GetAllLang())).
SetTitle(translator.GetDstLang())
}
func attachButton() *tview.Flex {
return tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(nil, 0, 1, false).
AddItem(langButton, 11, 1, true).
AddItem(nil, 18, 1, false).
AddItem(styleButton, 8, 1, true).
AddItem(nil, 18, 1, false).
AddItem(keyMapButton, 9, 1, true).
AddItem(nil, 0, 1, false)
}
// If center is true, it will center the items
func attachItems(center bool, direction int, items ...Item) *tview.Flex {
container := tview.NewFlex().SetDirection(direction)
if center {
container.AddItem(nil, 0, 1, false)
}
for _, item := range items {
container.AddItem(item.item, item.fixedSize, item.proportion, item.focus)
}
if center {
container.AddItem(nil, 0, 1, false)
}
return container
}
func showLangPopout() {
mainPage.HidePage("stylePopOut")
mainPage.HidePage("keyMapPopOut")
mainPage.ShowPage("langPopOut")
app.SetFocus(langCycle.GetCurrentUI())
}
func showStylePopout() {
mainPage.HidePage("langPopOut")
mainPage.HidePage("keyMapPopOut")
mainPage.ShowPage("stylePopOut")
app.SetFocus(styleCycle.GetCurrentUI())
}
func showKeyMapPopout() {
mainPage.HidePage("langPopOut")
mainPage.HidePage("stylePopOut")
mainPage.ShowPage("keyMapPopOut")
}
func uiInit() {
// pages
mainPage.AddPage("translateWindow", translateWindow, true, true)
mainPage.AddPage("langPopOut", langPopOut, true, false)
mainPage.AddPage("stylePopOut", stylePopOut, true, false)
mainPage.AddPage("keyMapPopOut", keyMapPopOut, true, false)
// input/output
srcInput.SetBorder(true)
dstOutput.SetBorder(true)
defOutput.SetBorder(true).SetTitle("Definition/Example")
posOutput.SetBorder(true).SetTitle("Part of speech")
// dropdown
translatorDropDown.SetLabel("Translator: ").
SetOptions(translate.AllTranslator, nil).
SetCurrentOption(IndexOf(translator.GetEngineName(), translate.AllTranslator))
srcLangDropDown.SetBorder(true)
dstLangDropDown.SetBorder(true)
themeDropDown.SetLabel("Theme: ").
SetOptions(style.AllTheme, nil).
SetCurrentOption(IndexOf(uiStyle.Theme, style.AllTheme))
transparentDropDown.SetLabel("Transparent: ").
SetOptions([]string{"true", "false"}, nil).
SetCurrentOption(
IndexOf(strconv.FormatBool(uiStyle.Transparent),
[]string{"true", "false"}))
hideBelowDropDown.SetLabel("Hide below: ").
SetOptions([]string{"true", "false"}, nil).
SetCurrentOption(
IndexOf(strconv.FormatBool(uiStyle.HideBelow),
[]string{"true", "false"}))
osc52DropDown.SetLabel("OSC 52: ").
SetOptions([]string{"true", "false"}, nil).
SetCurrentOption(
IndexOf(strconv.FormatBool(uiStyle.OSC52),
[]string{"true", "false"}))
srcBorderDropDown.SetLabel("Border Color: ").
SetOptions(style.Palette, nil).
SetCurrentOption(
IndexOf(uiStyle.SrcBorderStr(),
style.Palette)).
SetBorder(true).
SetTitle("Source")
dstBorderDropDown.SetLabel("Border Color: ").
SetOptions(style.Palette, nil).
SetCurrentOption(
IndexOf(uiStyle.DstBorderStr(),
style.Palette)).
SetBorder(true).
SetTitle("Destination")
// key map
keyMapMenu.SetDynamicColors(true).
SetBorder(true).
SetTitle("Key Map")
// window
translateAboveWidget.SetDirection(tview.FlexColumn).
AddItem(srcInput, 0, 1, true).
AddItem(dstOutput, 0, 1, false)
translateBelowWidget.SetDirection(tview.FlexColumn).
AddItem(defOutput, 0, 1, false).
AddItem(posOutput, 0, 1, false)
translateWindow.SetDirection(tview.FlexRow).
AddItem(translateAboveWidget, 0, 1, true)
updateTranslateWindow()
langPopOut.SetDirection(tview.FlexRow).
AddItem(nil, 0, 1, false).
AddItem(attachItems(true, tview.FlexColumn,
Item{item: attachItems(false, tview.FlexRow,
Item{item: attachItems(true, tview.FlexColumn,
Item{item: attachItems(false, tview.FlexRow,
Item{item: translatorDropDown, fixedSize: 0, proportion: 1, focus: false}),
fixedSize: 0, proportion: 1, focus: false}),
fixedSize: 1, proportion: 1, focus: false},
Item{item: attachItems(false, tview.FlexColumn,
Item{item: srcLangDropDown, fixedSize: 0, proportion: 1, focus: true},
Item{item: dstLangDropDown, fixedSize: 0, proportion: 1, focus: false}),
fixedSize: 0, proportion: 1, focus: true}),
fixedSize: 2 * langStrMaxLength, proportion: 1, focus: true}),
popOutMenuHeight, 1, true).
AddItem(attachButton(), 1, 1, false).
AddItem(nil, 0, 1, false)
stylePopOut.SetDirection(tview.FlexRow).
AddItem(nil, 0, 1, false).
AddItem(attachItems(true, tview.FlexColumn,
Item{item: attachItems(false, tview.FlexRow,
Item{item: attachItems(true, tview.FlexColumn,
Item{item: attachItems(false, tview.FlexRow,
Item{item: themeDropDown, fixedSize: 0, proportion: 1, focus: true},
Item{item: transparentDropDown, fixedSize: 0, proportion: 1, focus: false},
Item{item: hideBelowDropDown, fixedSize: 0, proportion: 1, focus: false},
Item{item: osc52DropDown, fixedSize: 0, proportion: 1, focus: false}),
fixedSize: 0, proportion: 1, focus: true}),
fixedSize: 4, proportion: 1, focus: true},
Item{item: attachItems(false, tview.FlexColumn,
Item{item: srcBorderDropDown, fixedSize: 0, proportion: 1, focus: false},
Item{item: dstBorderDropDown, fixedSize: 0, proportion: 1, focus: false}),
fixedSize: 0, proportion: 1, focus: false}),
fixedSize: 2 * langStrMaxLength, proportion: 1, focus: true}),
popOutMenuHeight, 1, true).
AddItem(attachButton(), 1, 1, false).
AddItem(nil, 0, 1, false)
keyMapPopOut.SetDirection(tview.FlexRow).
AddItem(nil, 0, 1, false).
AddItem(attachItems(true, tview.FlexColumn,
Item{item: keyMapMenu, fixedSize: 2 * langStrMaxLength, proportion: 1, focus: true}),
popOutMenuHeight, 1, true).
AddItem(attachButton(), 1, 1, false).
AddItem(nil, 0, 1, false)
updateAllColor()
updateLangDropDown()
updateCurrentLang()
// handler
app.SetInputCapture(appHandler)
translateWindow.SetInputCapture(translateWindowHandler)
for _, widget := range []*tview.TextArea{srcInput, defOutput, posOutput} {
// fix for loop problem
// https://github.com/golang/go/discussions/56010
widget := widget
widget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
keyName := getKeyName(event)
if len(keyName) == 0 {
return event
}
switch keyName {
case keyMaps["copy_selected"]:
// copy selected text
text, _, _ := widget.GetSelection()
// only copy when text selected
if len(text) > 0 {
CopyToClipboard(text)
}
return nil
}
return event
})
}
langPopOut.SetInputCapture(popOutHandler)
stylePopOut.SetInputCapture(popOutHandler)
keyMapPopOut.SetInputCapture(popOutHandler)
translatorDropDown.SetDoneFunc(langDropDownHandler).
SetSelectedFunc(func(text string, index int) {
translator = translators[text]
updateLangDropDown()
updateCurrentLang()
SetTermTitle(translator.GetEngineName())
})
srcLangDropDown.SetDoneFunc(langDropDownHandler)
dstLangDropDown.SetDoneFunc(langDropDownHandler)
themeDropDown.SetDoneFunc(styleDropDownHandler).
SetSelectedFunc(func(text string, index int) {
uiStyle.Theme = text
updateAllColor()
})
transparentDropDown.SetDoneFunc(styleDropDownHandler).
SetSelectedFunc(func(text string, index int) {
uiStyle.Transparent, _ = strconv.ParseBool(text)
updateBackgroundColor()
})
hideBelowDropDown.SetDoneFunc(styleDropDownHandler).
SetSelectedFunc(func(text string, index int) {
uiStyle.HideBelow, _ = strconv.ParseBool(text)
updateTranslateWindow()
})
osc52DropDown.SetDoneFunc(styleDropDownHandler).
SetSelectedFunc(func(text string, index int) {
uiStyle.OSC52, _ = strconv.ParseBool(text)
})
srcBorderDropDown.SetDoneFunc(styleDropDownHandler).
SetSelectedFunc(func(text string, index int) {
uiStyle.SetSrcBorderColor(text)
updateBorderColor()
})
dstBorderDropDown.SetDoneFunc(styleDropDownHandler).
SetSelectedFunc(func(text string, index int) {
uiStyle.SetDstBorderColor(text)
updateBorderColor()
})
keyMapMenu.SetDoneFunc(func(key tcell.Key) {
switch key {
case tcell.KeyEsc:
mainPage.HidePage("keyMapPopOut")
}
})
langButton.SetSelectedFunc(showLangPopout)
styleButton.SetSelectedFunc(showStylePopout)
keyMapButton.SetSelectedFunc(showKeyMapPopout)
}
func appHandler(event *tcell.EventKey) *tcell.EventKey {
keyName := getKeyName(event)
if len(keyName) == 0 {
return event
}
switch keyName {
case keyMaps["exit"]:
app.Stop()
return nil
case keyMaps["toggle_transparent"]:
// Toggle transparent
uiStyle.Transparent = !uiStyle.Transparent
// The following will trigger transparentDropDown SetDoneFunc
transparentDropDown.SetCurrentOption(
IndexOf(strconv.FormatBool(uiStyle.Transparent),
[]string{"true", "false"}))
return nil
case keyMaps["toggle_below"]:
// Toggle Hide below window
uiStyle.HideBelow = !uiStyle.HideBelow
// The following will trigger hideBelowDropDown SetDoneFunc
hideBelowDropDown.SetCurrentOption(
IndexOf(strconv.FormatBool(uiStyle.HideBelow),
[]string{"true", "false"}))
return nil
}
// Force C-c not to exit program
if event.Key() == tcell.KeyCtrlC {
return tcell.NewEventKey(tcell.KeyCtrlC, 0, tcell.ModNone)
}
return event
}
func translateWindowHandler(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyEsc {
showLangPopout()
return nil
}
keyName := getKeyName(event)
switch keyName {
case keyMaps["translate"]:
message := srcInput.GetText()
// Only translate when message exist
if len(message) > 0 {
translation, err := translator.Translate(message)
if err != nil {
dstOutput.SetText(err.Error())
} else {
dstOutput.SetText(translation.TEXT)
defOutput.SetText(translation.DEF, false)
posOutput.SetText(translation.POS, false)
}
}
return nil
case keyMaps["clear"]:
srcInput.Replace(0, len(srcInput.GetText()), "")
return nil
case keyMaps["copy_source"]:
// copy all text in Input
text := srcInput.GetText()
// only copy when text exist
if len(text) > 0 {
CopyToClipboard(text)
}
return nil
case keyMaps["copy_destination"]:
// copy all text in Output
text := dstOutput.GetText(false)
// only copy when text exist
if len(text) > 0 {
CopyToClipboard(text)
}
return nil
case keyMaps["swap_language"]:
translator.SwapLang()
updateCurrentLang()
tmp := srcInput.GetText()
srcInput.SetText(dstOutput.GetText(false), true)
dstOutput.SetText(tmp)
return nil
case keyMaps["tts_source"]:
// Play text to speech on source of translation window.
if translator.LockAvailable() {
message := srcInput.GetText()
// Only play when message exist
if len(message) > 0 {
translator.AcquireLock()
go func() {
err := translator.PlayTTS(translator.GetSrcLang(), message)
if err != nil {
srcInput.SetText(err.Error(), true)
app.Draw()
}
}()
}
}
return nil
case keyMaps["tts_destination"]:
// Play text to speech on destination of translation window.
if translator.LockAvailable() {
message := dstOutput.GetText(false)
// Only play when message exist
if len(message) > 0 {
translator.AcquireLock()
go func() {
err := translator.PlayTTS(translator.GetDstLang(), message)
if err != nil {
dstOutput.SetText(err.Error())
app.Draw()
}
}()
}
}
return nil
case keyMaps["stop_tts"]:
// Stop play sound
translator.StopTTS()
return nil
}
return event
}
func popOutHandler(event *tcell.EventKey) *tcell.EventKey {
ch := event.Rune()
switch ch {
case '1':
showLangPopout()
case '2':
showStylePopout()
case '3':
showKeyMapPopout()
}
return event
}
func langDropDownHandler(key tcell.Key) {
switch key {
case tcell.KeyTab:
langCycle.Increase()
app.SetFocus(langCycle.GetCurrentUI())
case tcell.KeyBacktab:
langCycle.Decrease()
app.SetFocus(langCycle.GetCurrentUI())
case tcell.KeyEsc:
mainPage.HidePage("langPopOut")
}
}
func styleDropDownHandler(key tcell.Key) {
switch key {
case tcell.KeyTab:
styleCycle.Increase()
app.SetFocus(styleCycle.GetCurrentUI())
case tcell.KeyBacktab:
styleCycle.Decrease()
app.SetFocus(styleCycle.GetCurrentUI())
case tcell.KeyEsc:
mainPage.HidePage("stylePopOut")
}
}