Update mauview

Fixes #367
This commit is contained in:
Tulir Asokan 2022-04-17 23:54:40 +03:00
parent c45a66bbf9
commit fa79dc0ca1
5 changed files with 18 additions and 26 deletions

6
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/kyokomi/emoji/v2 v2.2.9
github.com/lithammer/fuzzysearch v1.1.3
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-runewidth v0.0.13
github.com/mattn/go-runewidth v0.0.14-0.20220323023645-f9d555329d96
github.com/mattn/go-sqlite3 v1.14.12
github.com/rivo/uniseg v0.2.0
github.com/sasha-s/go-deadlock v0.3.1
@ -17,8 +17,8 @@ require (
github.com/zyedidia/clipboard v1.0.3
go.etcd.io/bbolt v1.3.6
go.mau.fi/cbind v0.0.0-20220415094356-e1d579b7925e
go.mau.fi/mauview v0.1.4-0.20220416164650-aac1ebd3a472
go.mau.fi/tcell v0.0.0-20220416164612-f5dbb33f6c9c
go.mau.fi/mauview v0.1.4-0.20220417205338-69b850bc4440
go.mau.fi/tcell v0.0.0-20220417202829-9f14d62226c5
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
golang.org/x/net v0.0.0-20220412020605-290c469a71a5
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2

11
go.sum
View File

@ -26,8 +26,9 @@ github.com/lithammer/fuzzysearch v1.1.3 h1:+t5SevHLfi3IHcTx7LT3S+od4OcUmjzxD1xmn
github.com/lithammer/fuzzysearch v1.1.3/go.mod h1:1R1LRNk7yKid1BaQkmuLQaHruxcC4HmAH30Dh61Ih1Q=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.14-0.20220323023645-f9d555329d96 h1:Fi8cONnzPQ1oBhXgY8DEtMiVNV+1oE7/Cw/MXIdAF/A=
github.com/mattn/go-runewidth v0.0.14-0.20220323023645-f9d555329d96/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0=
github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
@ -63,11 +64,11 @@ go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
go.mau.fi/cbind v0.0.0-20220415094356-e1d579b7925e h1:zY4TZmHAaUhrMFJQfh02dqxDYSfnnXlw/qRoFanxZTw=
go.mau.fi/cbind v0.0.0-20220415094356-e1d579b7925e/go.mod h1:9nnzlslhUo/xO+8tsQgkFqG/W+SgD+r0iTYAuglzlmA=
go.mau.fi/mauview v0.1.4-0.20220416164650-aac1ebd3a472 h1:1Rx+gZAORRrkevGQuLfDEM8E5cYxNRAA3lx2Rc19H5g=
go.mau.fi/mauview v0.1.4-0.20220416164650-aac1ebd3a472/go.mod h1:3W0lnT2QE0M/HF0d5dgyCG71QEc+pS/+RQf1lGybEzE=
go.mau.fi/mauview v0.1.4-0.20220417205338-69b850bc4440 h1:DegGruuno4o8/+cc9/Vck11amgHY0jXoCEdjnt05eIA=
go.mau.fi/mauview v0.1.4-0.20220417205338-69b850bc4440/go.mod h1:6bDnPL+UUkFvg0ueTlBQr1VcQwWJ4v8c+1ezoAG/Q5w=
go.mau.fi/tcell v0.0.0-20220415093808-07c67d224693/go.mod h1:HQLPCz9v8YfYewMetOKrg9pe87XEyNcIfCYYq8VxQbU=
go.mau.fi/tcell v0.0.0-20220416164612-f5dbb33f6c9c h1:BdwxPvI30uM9Yhr1t99sHHoEzbK8JLfRntQDpm/QCdg=
go.mau.fi/tcell v0.0.0-20220416164612-f5dbb33f6c9c/go.mod h1:HQLPCz9v8YfYewMetOKrg9pe87XEyNcIfCYYq8VxQbU=
go.mau.fi/tcell v0.0.0-20220417202829-9f14d62226c5 h1:JhL64rfGvgjnaaVmUTcG46hW9L48hxLlWtsIvQKeARY=
go.mau.fi/tcell v0.0.0-20220417202829-9f14d62226c5/go.mod h1:Nq9HUYmTdDVZnEyh5xzJR9tdamalR1yzAxq9BClI8EY=
golang.org/x/crypto v0.0.0-20220408190544-5352b0902921 h1:iU7T1X1J6yxDr0rda54sWGkHgOp5XJrqm79gcNlC2VM=
golang.org/x/crypto v0.0.0-20220408190544-5352b0902921/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=

View File

@ -84,9 +84,7 @@ func (ui *GomuksUI) Stop() {
}
func (ui *GomuksUI) Finish() {
if ui.app.Screen() != nil {
ui.app.Screen().Fini()
}
ui.app.ForceStop()
}
func (ui *GomuksUI) Render() {
@ -106,15 +104,7 @@ func (ui *GomuksUI) HandleNewPreferences() {
}
func (ui *GomuksUI) SetView(name View) {
ui.app.Root = ui.views[name]
focusable, ok := ui.app.Root.(mauview.Focusable)
if ok {
focusable.Focus()
}
if ui.app.Screen() != nil {
ui.app.Screen().Clear()
ui.Render()
}
ui.app.SetRoot(ui.views[name])
}
func (ui *GomuksUI) MainView() ifc.MainView {
@ -122,14 +112,14 @@ func (ui *GomuksUI) MainView() ifc.MainView {
}
func (ui *GomuksUI) RunExternal(executablePath string, args ...string) error {
var err error
callback := make(chan error)
ui.app.Suspend(func() {
cmd := exec.Command(executablePath, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Env = os.Environ()
err = cmd.Run()
callback <- cmd.Run()
})
return err
return <-callback
}

View File

@ -19,6 +19,8 @@ package ui
import (
"math"
"github.com/mattn/go-runewidth"
"go.mau.fi/mauview"
"go.mau.fi/tcell"
@ -139,7 +141,7 @@ func (view *LoginView) Error(err string) {
view.AddComponent(view.error, 1, 11, 3, 1)
}
view.error.SetText(err)
errorHeight := int(math.Ceil(float64(mauview.StringWidth(err)) / 45))
errorHeight := int(math.Ceil(float64(runewidth.StringWidth(err)) / 45))
view.container.SetHeight(14 + errorHeight)
view.SetRow(11, errorHeight)
}

View File

@ -41,8 +41,7 @@ func WriteLineColor(screen mauview.Screen, align int, line string, x, y, maxWidt
func WriteLine(screen mauview.Screen, align int, line string, x, y, maxWidth int, style tcell.Style) {
offsetX := 0
if align == mauview.AlignRight {
// TODO is mauview.StringWidth correct here?
offsetX = maxWidth - mauview.StringWidth(line)
offsetX = maxWidth - runewidth.StringWidth(line)
}
if offsetX < 0 {
offsetX = 0