mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-17 00:00:16 -07:00
feat: lock in translator
This commit is contained in:
parent
bf24cc548d
commit
4a666c3749
2
main.go
2
main.go
@ -7,7 +7,7 @@ import (
|
||||
|
||||
var (
|
||||
// Translate
|
||||
translator Translator
|
||||
translator = NewTranslator()
|
||||
// UI
|
||||
app = tview.NewApplication()
|
||||
src_box = tview.NewTextArea()
|
||||
|
@ -20,6 +20,13 @@ const (
|
||||
type Translator struct {
|
||||
srcLang string
|
||||
dstLang string
|
||||
soundLock *Lock
|
||||
}
|
||||
|
||||
func NewTranslator() Translator {
|
||||
return Translator{
|
||||
soundLock: NewLock(),
|
||||
}
|
||||
}
|
||||
|
||||
func (t Translator) Translate(message string) (string, error) {
|
||||
|
24
utils.go
24
utils.go
@ -10,5 +10,27 @@ func IndexOf(candidate string, arr []string) int {
|
||||
}
|
||||
|
||||
func SetTermTitle(title string) {
|
||||
print("\033]0;" , title , "\007")
|
||||
print("\033]0;", title, "\007")
|
||||
}
|
||||
|
||||
type Lock struct {
|
||||
stop bool
|
||||
threadCount int8
|
||||
}
|
||||
|
||||
func NewLock() *Lock {
|
||||
return &Lock{
|
||||
stop: true,
|
||||
threadCount: 0,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Lock) Aquire() {
|
||||
l.stop = false
|
||||
l.threadCount++
|
||||
}
|
||||
|
||||
func (l *Lock) Release() {
|
||||
l.stop = true
|
||||
l.threadCount--
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user