Skip to content

Commit

Permalink
Merge branch 'master' into fix/89
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Aug 14, 2024
2 parents 6d90247 + 8a75938 commit 5b590d7
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 214 deletions.
33 changes: 10 additions & 23 deletions cmd/fyneterm/main.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
//go:generate fyne bundle -o translation.go ../../translation/

package main

import (
"encoding/json"
"embed"
"flag"
"image/color"
"os"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/lang"
"fyne.io/fyne/v2/theme"
"github.com/fyne-io/terminal"
"github.com/fyne-io/terminal/cmd/fyneterm/data"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
)

const termOverlay = fyne.ThemeColorName("termOver")

var (
localizer *i18n.Localizer
sizer *termTheme
)
var sizer *termTheme

//go:embed translation
var translations embed.FS

func setupListener(t *terminal.Terminal, w fyne.Window) {
listen := make(chan terminal.Config)
Expand All @@ -44,12 +40,7 @@ func setupListener(t *terminal.Terminal, w fyne.Window) {
}

func termTitle() string {
return localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "Title",
Other: "Fyne Terminal",
},
})
return lang.L("Title")
}

func guessCellSize() fyne.Size {
Expand All @@ -64,11 +55,7 @@ func main() {
flag.BoolVar(&debug, "debug", false, "Show terminal debug messages")
flag.Parse()

bundle := i18n.NewBundle(language.English)
bundle.RegisterUnmarshalFunc("json", json.Unmarshal)
bundle.MustParseMessageFileBytes(resourceActiveFrJson.Content(), resourceActiveFrJson.Name())
bundle.MustParseMessageFileBytes(resourceActiveRuJson.Content(), resourceActiveRuJson.Name())
localizer = i18n.NewLocalizer(bundle, os.Getenv("LANG"))
lang.AddTranslationsFS(translations, "translation")

a := app.New()
a.SetIcon(data.Icon)
Expand All @@ -82,7 +69,7 @@ func newTerminalWindow(a fyne.App, th fyne.Theme, debug bool) fyne.Window {
w := a.NewWindow(termTitle())
w.SetPadded(false)

bg := canvas.NewRectangle(theme.BackgroundColor())
bg := canvas.NewRectangle(theme.Color(theme.ColorNameBackground))
img := canvas.NewImageFromResource(data.FyneLogo)
img.FillMode = canvas.ImageFillContain
over := canvas.NewRectangle(th.Color(termOverlay, a.Settings().ThemeVariant()))
Expand All @@ -92,7 +79,7 @@ func newTerminalWindow(a fyne.App, th fyne.Theme, debug bool) fyne.Window {
for {
<-ch

bg.FillColor = theme.BackgroundColor()
bg.FillColor = theme.Color(theme.ColorNameBackground)
bg.Refresh()
over.FillColor = th.Color(termOverlay, a.Settings().ThemeVariant())
over.Refresh()
Expand Down
22 changes: 0 additions & 22 deletions cmd/fyneterm/translation.go

This file was deleted.

File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions cmd/fyneterm/translation/pl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Title": ""
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions color.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ func (t *Terminal) handleColorMode(modeStr string) {
case 7: // reverse
bg, fg := t.currentBG, t.currentFG
if fg == nil {
t.currentBG = theme.ForegroundColor()
t.currentBG = theme.Color(theme.ColorNameForeground)
} else {
t.currentBG = fg
}
if bg == nil {
t.currentFG = theme.DisabledButtonColor()
t.currentFG = theme.Color(theme.ColorNameDisabledButton)
} else {
t.currentFG = bg
}
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
module github.com/fyne-io/terminal

go 1.17
go 1.19

require (
fyne.io/fyne/v2 v2.4.6-0.20240617212519-759df6f70f7e
fyne.io/fyne/v2 v2.5.1-0.20240723013128-bbfc67312e64
github.com/ActiveState/termtest/conpty v0.5.0
github.com/creack/pty v1.1.21
github.com/nicksnyder/go-i18n/v2 v2.4.0
github.com/stretchr/testify v1.9.0
golang.org/x/text v0.16.0
)

require (
fyne.io/systray v1.10.1-0.20240611130111-26449f257a02 // indirect
fyne.io/systray v1.11.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -29,6 +27,7 @@ require (
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 // indirect
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rymdport/portal v0.2.2 // indirect
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
Expand All @@ -38,5 +37,6 @@ require (
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 5b590d7

Please sign in to comment.