v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-19 01:00:20 -07:00

Tab & Backtab to cycle through layout

This commit is contained in:
eeeXun 2022-10-24 17:19:37 +08:00
parent 9e8379d6a5
commit 457d94ed9f

14
ui.go
View File

@ -30,6 +30,10 @@ func (ui *UICycle) Increase() {
ui.index = (ui.index + 1) % ui.len
}
func (ui *UICycle) Decrease() {
ui.index = ((ui.index-1)%ui.len + ui.len) % ui.len
}
func (ui *UICycle) GetCurrentUI() tview.Primitive {
return ui.widget[ui.index]
}
@ -407,9 +411,12 @@ func translatePageHandler(event *tcell.EventKey) *tcell.EventKey {
func langDropDownHandler(key tcell.Key) {
switch key {
case tcell.KeyTAB:
case tcell.KeyTab:
langCycle.Increase()
app.SetFocus(langCycle.GetCurrentUI())
case tcell.KeyBacktab:
langCycle.Decrease()
app.SetFocus(langCycle.GetCurrentUI())
case tcell.KeyEsc:
mainPage.HidePage("langPage")
}
@ -417,9 +424,12 @@ func langDropDownHandler(key tcell.Key) {
func styleDropDownHandler(key tcell.Key) {
switch key {
case tcell.KeyTAB:
case tcell.KeyTab:
styleCycle.Increase()
app.SetFocus(styleCycle.GetCurrentUI())
case tcell.KeyBacktab:
styleCycle.Decrease()
app.SetFocus(styleCycle.GetCurrentUI())
case tcell.KeyEsc:
mainPage.HidePage("stylePage")
}