v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-18 00:30:40 -07:00

add title_color

This commit is contained in:
eeeXun 2022-10-20 13:53:38 +08:00
parent a29f1c2f86
commit 1dd4f21deb
2 changed files with 26 additions and 13 deletions

View File

@ -6,6 +6,7 @@ import (
var (
themes_name = []string{"Gruvbox", "Nord"}
Transparent tcell.Color = tcell.ColorDefault
Themes = map[string]map[string]tcell.Color{
"Gruvbox": {
"bg": tcell.NewHexColor(0x282828),
@ -37,6 +38,7 @@ type Colors struct {
foreground_color tcell.Color
border_color tcell.Color
text_color tcell.Color
title_color tcell.Color
selected_color tcell.Color
}
@ -46,11 +48,20 @@ type Window struct {
}
func (w *Window) color_init() {
w.src.background_color = Themes["Gruvbox"]["bg"]
w.src.border_color = Themes["Gruvbox"]["red"]
w.src.foreground_color = Themes["Gruvbox"]["fg"]
w.src.selected_color = Themes["Gruvbox"]["gray"]
w.dest.background_color = Themes["Gruvbox"]["bg"]
w.dest.border_color = Themes["Gruvbox"]["blue"]
w.dest.foreground_color = Themes["Gruvbox"]["fg"]
theme := "Gruvbox"
transparent := true
if transparent {
w.src.background_color = Transparent
w.dest.background_color = Transparent
} else {
w.src.background_color = Themes[theme]["bg"]
w.dest.background_color = Themes[theme]["bg"]
}
w.src.border_color = Themes[theme]["red"]
w.src.foreground_color = Themes[theme]["fg"]
w.src.title_color = Themes[theme]["yellow"]
w.src.selected_color = Themes[theme]["gray"]
w.dest.foreground_color = Themes[theme]["fg"]
w.dest.border_color = Themes[theme]["blue"]
w.dest.title_color = Themes[theme]["cyan"]
}

10
ui.go
View File

@ -8,7 +8,7 @@ func ui_init() {
src_box.SetBorder(true).
SetTitle(translator.src_lang).
SetBorderColor(window.src.border_color).
SetTitleColor(window.src.border_color).
SetTitleColor(window.src.title_color).
SetBackgroundColor(window.src.background_color)
src_box.SetTextStyle(tcell.StyleDefault.
Background(window.src.background_color).
@ -21,13 +21,15 @@ func ui_init() {
dest_box.SetBorder(true).
SetTitle(translator.dest_lang).
SetBorderColor(window.dest.border_color).
SetTitleColor(window.dest.border_color).
SetTitleColor(window.dest.title_color).
SetBackgroundColor(window.dest.background_color)
dest_box.SetTextColor(window.dest.foreground_color)
}
func InputHandle(event *tcell.EventKey) *tcell.EventKey {
key := event.Key()
// panic(event.Name())
switch key {
case tcell.KeyCtrlJ:
result, err := translator.Translate(src_box.GetText())
@ -39,9 +41,9 @@ func InputHandle(event *tcell.EventKey) *tcell.EventKey {
case tcell.KeyCtrlQ:
src_box.SetText("", true)
case tcell.KeyCtrlN:
dest_box.SetText("NNN")
translator.PlaySound(translator.src_lang, src_box.GetText())
case tcell.KeyCtrlP:
dest_box.SetText("PPP")
translator.PlaySound(translator.dest_lang, dest_box.GetText(false))
case tcell.KeyCtrlT:
dest_box.SetText("TTT")
case tcell.KeyCtrlS: