refactor(ui): match tview.InputField api

This commit is contained in:
ayn2op 2026-06-11 21:25:38 -04:00
parent 7556744eca
commit 85ce6cae34
4 changed files with 10 additions and 10 deletions

2
go.mod
View file

@ -11,7 +11,7 @@ require (
github.com/alecthomas/chroma/v2 v2.26.1
github.com/andybalholm/brotli v1.2.1
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97
github.com/ayn2op/tview v0.0.0-20260611195720-1b42febf254f
github.com/ayn2op/tview v0.0.0-20260612231537-97f061269b21
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb
github.com/diamondburned/arikawa/v3 v3.6.1-0.20260518050745-b430932b3ee1
github.com/diamondburned/ningen/v3 v3.0.1-0.20260306213430-5a08d3a709b4

4
go.sum
View file

@ -14,8 +14,8 @@ github.com/andybalholm/brotli v1.2.1 h1:R+f5xP285VArJDRgowrfb9DqL18yVK0gKAW/F+eT
github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97 h1:WujETUV+v0DEJyZgjeLzQvihWyL80c0Tg4qf0dDo+Io=
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97/go.mod h1:3kFnpNCa3dF6WryzOMCDao7PfZ7DTCh+pievlfuwV80=
github.com/ayn2op/tview v0.0.0-20260611195720-1b42febf254f h1:KDJCUac/3+ENCi7BwS8bkjKtQGeFwplbqdkyBF5Fc2g=
github.com/ayn2op/tview v0.0.0-20260611195720-1b42febf254f/go.mod h1:CaEiemJYKtmWqR0khyMI3HzVIia6B61jOPcLeZ7y4xk=
github.com/ayn2op/tview v0.0.0-20260612231537-97f061269b21 h1:vpWN5iVxK0bNdi4Kc5B+MNJnV96rJDd7xewy2mups8s=
github.com/ayn2op/tview v0.0.0-20260612231537-97f061269b21/go.mod h1:CaEiemJYKtmWqR0khyMI3HzVIia6B61jOPcLeZ7y4xk=
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=

View file

@ -113,9 +113,9 @@ func (c *composer) resizeForContent() {
_, _, _, parentH := c.chat.rightFlex.InnerRect()
visible := min(
strings.Count(c.GetText(), "\n")+1, // newline-driven height
max(c.cfg.Composer.MaxHeight, 1), // user-configured cap
max(parentH-frame-1, 1), // available room, reserving 1 row for messages
strings.Count(c.Text(), "\n")+1, // newline-driven height
max(c.cfg.Composer.MaxHeight, 1), // user-configured cap
max(parentH-frame-1, 1), // available room, reserving 1 row for messages
)
c.chat.rightFlex.ResizeItem(c, visible+frame, 1) // outer height = inner content + frame
@ -338,7 +338,7 @@ func (c *composer) send() tview.Cmd {
return nil
}
text := strings.TrimSpace(c.GetText())
text := strings.TrimSpace(c.Text())
if text == "" && len(c.sendMessageData.Files) == 0 {
return nil
}
@ -771,7 +771,7 @@ func (c *composer) editor() {
defer file.Close()
defer os.Remove(file.Name())
file.WriteString(c.GetText())
file.WriteString(c.Text())
if c.cfg.Editor == "" {
slog.Warn("Attempt to open file with editor, but no editor is set")

View file

@ -11,7 +11,7 @@ type Model struct {
func NewModel() *Model {
form := tview.NewForm().
AddPasswordField("Token", "", 0, 0, nil).
AddPasswordField("Token", "", 0, 0).
AddButton("Login")
return &Model{Form: form}
}
@ -25,7 +25,7 @@ func (m *Model) Label() string {
func (m *Model) Update(msg tview.Msg) tview.Cmd {
switch msg.(type) {
case tview.FormSubmitMsg:
token := m.GetFormItem(0).(*tview.InputField).GetText()
token := m.GetFormItem(0).(*tview.InputField).Text()
if token == "" {
return nil
}