v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-21 10:00:59 -07:00

Merge branch 'master' into part_of_speech

This commit is contained in:
eeeXun 2023-01-11 22:20:50 +08:00
commit b994a3d872

139
ui.go
View File

@ -11,6 +11,8 @@ import (
) )
const ( const (
popOutWindowHeight int = 20
langStrMaxLength int = 32
keyMapText string = `[#%[1]s]<C-c>[-] keyMapText string = `[#%[1]s]<C-c>[-]
Exit program. Exit program.
[#%[1]s]<Esc>[-] [#%[1]s]<Esc>[-]
@ -71,55 +73,22 @@ func updateBackgroundColor() {
Foreground(style.ForegroundColor())) Foreground(style.ForegroundColor()))
// dropdown // dropdown
srcLangDropDown.SetListStyles(tcell.StyleDefault. for _, dropdown := range []*tview.DropDown{
Background(style.BackgroundColor()). srcLangDropDown,
Foreground(style.ForegroundColor()), dstLangDropDown,
tcell.StyleDefault. themeDropDown,
Background(style.SelectedColor()). transparentDropDown,
Foreground(style.PrefixColor())). hideBelowDropDown,
SetBackgroundColor(style.BackgroundColor()) srcBorderDropDown,
dstLangDropDown.SetListStyles(tcell.StyleDefault. dstBorderDropDown} {
Background(style.BackgroundColor()). dropdown.SetListStyles(tcell.StyleDefault.
Foreground(style.ForegroundColor()),
tcell.StyleDefault.
Background(style.SelectedColor()).
Foreground(style.PrefixColor())).
SetBackgroundColor(style.BackgroundColor())
themeDropDown.SetListStyles(tcell.StyleDefault.
Background(style.BackgroundColor()).
Foreground(style.ForegroundColor()),
tcell.StyleDefault.
Background(style.SelectedColor()).
Foreground(style.PrefixColor())).
SetBackgroundColor(style.BackgroundColor())
transparentDropDown.SetListStyles(tcell.StyleDefault.
Background(style.BackgroundColor()).
Foreground(style.ForegroundColor()),
tcell.StyleDefault.
Background(style.SelectedColor()).
Foreground(style.PrefixColor())).
SetBackgroundColor(style.BackgroundColor())
hideBelowDropDown.SetListStyles(tcell.StyleDefault.
Background(style.BackgroundColor()).
Foreground(style.ForegroundColor()),
tcell.StyleDefault.
Background(style.SelectedColor()).
Foreground(style.PrefixColor())).
SetBackgroundColor(style.BackgroundColor())
srcBorderDropDown.SetListStyles(tcell.StyleDefault.
Background(style.BackgroundColor()).
Foreground(style.ForegroundColor()),
tcell.StyleDefault.
Background(style.SelectedColor()).
Foreground(style.PrefixColor())).
SetBackgroundColor(style.BackgroundColor())
dstBorderDropDown.SetListStyles(tcell.StyleDefault.
Background(style.BackgroundColor()). Background(style.BackgroundColor()).
Foreground(style.ForegroundColor()), Foreground(style.ForegroundColor()),
tcell.StyleDefault. tcell.StyleDefault.
Background(style.SelectedColor()). Background(style.SelectedColor()).
Foreground(style.PrefixColor())). Foreground(style.PrefixColor())).
SetBackgroundColor(style.BackgroundColor()) SetBackgroundColor(style.BackgroundColor())
}
// key map // key map
keyMapMenu.SetBackgroundColor(style.BackgroundColor()) keyMapMenu.SetBackgroundColor(style.BackgroundColor())
@ -137,15 +106,15 @@ func updateBorderColor() {
SetTitleColor(style.DstBorderColor()) SetTitleColor(style.DstBorderColor())
// dropdown // dropdown
srcLangDropDown.SetBorderColor(style.SrcBorderColor()). for _, srcDropDown := range []*tview.DropDown{srcLangDropDown, srcBorderDropDown} {
srcDropDown.SetBorderColor(style.SrcBorderColor()).
SetTitleColor(style.SrcBorderColor()) SetTitleColor(style.SrcBorderColor())
dstLangDropDown.SetBorderColor(style.DstBorderColor()). }
SetTitleColor(style.DstBorderColor()) for _, dstDropDown := range []*tview.DropDown{dstLangDropDown, dstBorderDropDown} {
srcBorderDropDown.SetBorderColor(style.SrcBorderColor()). dstDropDown.SetBorderColor(style.DstBorderColor()).
SetTitleColor(style.SrcBorderColor())
dstBorderDropDown.SetBorderColor(style.DstBorderColor()).
SetTitleColor(style.DstBorderColor()) SetTitleColor(style.DstBorderColor())
} }
}
func updateNonConfigColor() { func updateNonConfigColor() {
// input/output // input/output
@ -161,46 +130,30 @@ func updateNonConfigColor() {
Foreground(style.ForegroundColor())) Foreground(style.ForegroundColor()))
// dropdown // dropdown
srcLangDropDown.SetFieldBackgroundColor(style.SelectedColor()). for _, noLabelDropDown := range []*tview.DropDown{srcLangDropDown, dstLangDropDown} {
noLabelDropDown.SetFieldBackgroundColor(style.SelectedColor()).
SetFieldTextColor(style.ForegroundColor()). SetFieldTextColor(style.ForegroundColor()).
SetPrefixTextColor(style.PrefixColor()) SetPrefixTextColor(style.PrefixColor())
dstLangDropDown.SetFieldBackgroundColor(style.SelectedColor()). }
SetFieldTextColor(style.ForegroundColor()). for _, labelDropDown := range []*tview.DropDown{
SetPrefixTextColor(style.PrefixColor()) themeDropDown,
themeDropDown.SetLabelColor(style.LabelColor()). transparentDropDown,
SetFieldBackgroundColor(style.SelectedColor()). hideBelowDropDown,
SetFieldTextColor(style.ForegroundColor()). srcBorderDropDown,
SetPrefixTextColor(style.PrefixColor()) dstBorderDropDown} {
transparentDropDown.SetLabelColor(style.LabelColor()). labelDropDown.SetLabelColor(style.LabelColor()).
SetFieldBackgroundColor(style.SelectedColor()).
SetFieldTextColor(style.ForegroundColor()).
SetPrefixTextColor(style.PrefixColor())
hideBelowDropDown.SetLabelColor(style.LabelColor()).
SetFieldBackgroundColor(style.SelectedColor()).
SetFieldTextColor(style.ForegroundColor()).
SetPrefixTextColor(style.PrefixColor())
srcBorderDropDown.SetLabelColor(style.LabelColor()).
SetFieldBackgroundColor(style.SelectedColor()).
SetFieldTextColor(style.ForegroundColor()).
SetPrefixTextColor(style.PrefixColor())
dstBorderDropDown.SetLabelColor(style.LabelColor()).
SetFieldBackgroundColor(style.SelectedColor()). SetFieldBackgroundColor(style.SelectedColor()).
SetFieldTextColor(style.ForegroundColor()). SetFieldTextColor(style.ForegroundColor()).
SetPrefixTextColor(style.PrefixColor()) SetPrefixTextColor(style.PrefixColor())
}
// button // button
langButton.SetLabelColor(style.ForegroundColor()). for _, button := range []*tview.Button{langButton, styleButton, keyMapButton} {
SetBackgroundColorActivated(style.PressColor()). button.SetLabelColor(style.ForegroundColor()).
SetLabelColorActivated(style.ForegroundColor()).
SetBackgroundColor(style.SelectedColor())
styleButton.SetLabelColor(style.ForegroundColor()).
SetBackgroundColorActivated(style.PressColor()).
SetLabelColorActivated(style.ForegroundColor()).
SetBackgroundColor(style.SelectedColor())
keyMapButton.SetLabelColor(style.ForegroundColor()).
SetBackgroundColorActivated(style.PressColor()). SetBackgroundColorActivated(style.PressColor()).
SetLabelColorActivated(style.ForegroundColor()). SetLabelColorActivated(style.ForegroundColor()).
SetBackgroundColor(style.SelectedColor()) SetBackgroundColor(style.SelectedColor())
}
// key map // key map
keyMapMenu.SetTextColor(style.ForegroundColor()). keyMapMenu.SetTextColor(style.ForegroundColor()).
@ -252,10 +205,10 @@ func uiInit() {
SetTitle("Part of speech") SetTitle("Part of speech")
// dropdown // dropdown
srcLangDropDown.SetOptions(translate.Lang, nil). for _, langDropDown := range []*tview.DropDown{srcLangDropDown, dstLangDropDown} {
SetBorder(true) langDropDown.SetOptions(translate.Lang, nil).
dstLangDropDown.SetOptions(translate.Lang, nil).
SetBorder(true) SetBorder(true)
}
themeDropDown.SetLabel("Theme: "). themeDropDown.SetLabel("Theme: ").
SetOptions(color.AllTheme, nil). SetOptions(color.AllTheme, nil).
SetCurrentOption(IndexOf(style.Theme, color.AllTheme)) SetCurrentOption(IndexOf(style.Theme, color.AllTheme))
@ -303,10 +256,10 @@ func uiInit() {
AddItem(nil, 0, 1, false). AddItem(nil, 0, 1, false).
AddItem(tview.NewFlex().SetDirection(tview.FlexColumn). AddItem(tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(nil, 0, 1, false). AddItem(nil, 0, 1, false).
AddItem(srcLangDropDown, 32, 1, true). AddItem(srcLangDropDown, langStrMaxLength, 1, true).
AddItem(dstLangDropDown, 32, 1, false). AddItem(dstLangDropDown, langStrMaxLength, 1, false).
AddItem(nil, 0, 1, false), AddItem(nil, 0, 1, false),
20, 1, true). popOutWindowHeight, 1, true).
AddItem(attachButton(), 1, 1, false). AddItem(attachButton(), 1, 1, false).
AddItem(nil, 0, 1, false) AddItem(nil, 0, 1, false)
styleWindow.SetDirection(tview.FlexRow). styleWindow.SetDirection(tview.FlexRow).
@ -317,28 +270,28 @@ func uiInit() {
AddItem(tview.NewFlex().SetDirection(tview.FlexColumn). AddItem(tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(nil, 0, 1, false). AddItem(nil, 0, 1, false).
AddItem(tview.NewFlex().SetDirection(tview.FlexRow). AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(themeDropDown, 1, 1, true). AddItem(themeDropDown, 0, 1, true).
AddItem(transparentDropDown, 1, 1, false). AddItem(transparentDropDown, 0, 1, false).
AddItem(hideBelowDropDown, 0, 1, false), AddItem(hideBelowDropDown, 0, 1, false),
0, 1, true). 0, 1, true).
AddItem(nil, 0, 1, false), AddItem(nil, 0, 1, false),
3, 1, true). 3, 1, true).
AddItem(tview.NewFlex().SetDirection(tview.FlexColumn). AddItem(tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(srcBorderDropDown, 32, 1, false). AddItem(srcBorderDropDown, 0, 1, false).
AddItem(dstBorderDropDown, 32, 1, false), AddItem(dstBorderDropDown, 0, 1, false),
0, 1, false), 0, 1, false),
64, 1, true). 2*langStrMaxLength, 1, true).
AddItem(nil, 0, 1, false), AddItem(nil, 0, 1, false),
20, 1, true). popOutWindowHeight, 1, true).
AddItem(attachButton(), 1, 1, false). AddItem(attachButton(), 1, 1, false).
AddItem(nil, 0, 1, false) AddItem(nil, 0, 1, false)
keyMapWindow.SetDirection(tview.FlexRow). keyMapWindow.SetDirection(tview.FlexRow).
AddItem(nil, 0, 1, false). AddItem(nil, 0, 1, false).
AddItem(tview.NewFlex().SetDirection(tview.FlexColumn). AddItem(tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(nil, 0, 1, false). AddItem(nil, 0, 1, false).
AddItem(keyMapMenu, 64, 1, true). AddItem(keyMapMenu, 2*langStrMaxLength, 1, true).
AddItem(nil, 0, 1, false), AddItem(nil, 0, 1, false),
20, 1, true). popOutWindowHeight, 1, true).
AddItem(attachButton(), 1, 1, false). AddItem(attachButton(), 1, 1, false).
AddItem(nil, 0, 1, false) AddItem(nil, 0, 1, false)