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:
parent
a29f1c2f86
commit
1dd4f21deb
29
color.go
29
color.go
@ -5,8 +5,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
themes_name = []string{"Gruvbox", "Nord"}
|
themes_name = []string{"Gruvbox", "Nord"}
|
||||||
Themes = map[string]map[string]tcell.Color{
|
Transparent tcell.Color = tcell.ColorDefault
|
||||||
|
Themes = map[string]map[string]tcell.Color{
|
||||||
"Gruvbox": {
|
"Gruvbox": {
|
||||||
"bg": tcell.NewHexColor(0x282828),
|
"bg": tcell.NewHexColor(0x282828),
|
||||||
"fg": tcell.NewHexColor(0xebdbb2),
|
"fg": tcell.NewHexColor(0xebdbb2),
|
||||||
@ -37,6 +38,7 @@ type Colors struct {
|
|||||||
foreground_color tcell.Color
|
foreground_color tcell.Color
|
||||||
border_color tcell.Color
|
border_color tcell.Color
|
||||||
text_color tcell.Color
|
text_color tcell.Color
|
||||||
|
title_color tcell.Color
|
||||||
selected_color tcell.Color
|
selected_color tcell.Color
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,11 +48,20 @@ type Window struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) color_init() {
|
func (w *Window) color_init() {
|
||||||
w.src.background_color = Themes["Gruvbox"]["bg"]
|
theme := "Gruvbox"
|
||||||
w.src.border_color = Themes["Gruvbox"]["red"]
|
transparent := true
|
||||||
w.src.foreground_color = Themes["Gruvbox"]["fg"]
|
if transparent {
|
||||||
w.src.selected_color = Themes["Gruvbox"]["gray"]
|
w.src.background_color = Transparent
|
||||||
w.dest.background_color = Themes["Gruvbox"]["bg"]
|
w.dest.background_color = Transparent
|
||||||
w.dest.border_color = Themes["Gruvbox"]["blue"]
|
} else {
|
||||||
w.dest.foreground_color = Themes["Gruvbox"]["fg"]
|
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
10
ui.go
@ -8,7 +8,7 @@ func ui_init() {
|
|||||||
src_box.SetBorder(true).
|
src_box.SetBorder(true).
|
||||||
SetTitle(translator.src_lang).
|
SetTitle(translator.src_lang).
|
||||||
SetBorderColor(window.src.border_color).
|
SetBorderColor(window.src.border_color).
|
||||||
SetTitleColor(window.src.border_color).
|
SetTitleColor(window.src.title_color).
|
||||||
SetBackgroundColor(window.src.background_color)
|
SetBackgroundColor(window.src.background_color)
|
||||||
src_box.SetTextStyle(tcell.StyleDefault.
|
src_box.SetTextStyle(tcell.StyleDefault.
|
||||||
Background(window.src.background_color).
|
Background(window.src.background_color).
|
||||||
@ -21,13 +21,15 @@ func ui_init() {
|
|||||||
dest_box.SetBorder(true).
|
dest_box.SetBorder(true).
|
||||||
SetTitle(translator.dest_lang).
|
SetTitle(translator.dest_lang).
|
||||||
SetBorderColor(window.dest.border_color).
|
SetBorderColor(window.dest.border_color).
|
||||||
SetTitleColor(window.dest.border_color).
|
SetTitleColor(window.dest.title_color).
|
||||||
SetBackgroundColor(window.dest.background_color)
|
SetBackgroundColor(window.dest.background_color)
|
||||||
dest_box.SetTextColor(window.dest.foreground_color)
|
dest_box.SetTextColor(window.dest.foreground_color)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InputHandle(event *tcell.EventKey) *tcell.EventKey {
|
func InputHandle(event *tcell.EventKey) *tcell.EventKey {
|
||||||
key := event.Key()
|
key := event.Key()
|
||||||
|
// panic(event.Name())
|
||||||
|
|
||||||
switch key {
|
switch key {
|
||||||
case tcell.KeyCtrlJ:
|
case tcell.KeyCtrlJ:
|
||||||
result, err := translator.Translate(src_box.GetText())
|
result, err := translator.Translate(src_box.GetText())
|
||||||
@ -39,9 +41,9 @@ func InputHandle(event *tcell.EventKey) *tcell.EventKey {
|
|||||||
case tcell.KeyCtrlQ:
|
case tcell.KeyCtrlQ:
|
||||||
src_box.SetText("", true)
|
src_box.SetText("", true)
|
||||||
case tcell.KeyCtrlN:
|
case tcell.KeyCtrlN:
|
||||||
dest_box.SetText("NNN")
|
translator.PlaySound(translator.src_lang, src_box.GetText())
|
||||||
case tcell.KeyCtrlP:
|
case tcell.KeyCtrlP:
|
||||||
dest_box.SetText("PPP")
|
translator.PlaySound(translator.dest_lang, dest_box.GetText(false))
|
||||||
case tcell.KeyCtrlT:
|
case tcell.KeyCtrlT:
|
||||||
dest_box.SetText("TTT")
|
dest_box.SetText("TTT")
|
||||||
case tcell.KeyCtrlS:
|
case tcell.KeyCtrlS:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user