Add ^A and ^E keybindings

This commit is contained in:
Christian Rocha 2020-01-29 21:46:03 -05:00
parent 48e19e3b0d
commit 501f9cbbe1
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
3 changed files with 14 additions and 3 deletions

5
go.mod
View File

@ -2,4 +2,7 @@ module github.com/charmbracelet/teaparty
go 1.13
require github.com/charmbracelet/tea v0.0.0-20200126032228-29799c315162
require (
github.com/charmbracelet/tea v0.0.0-20200130023737-bb06373836b4
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 // indirect
)

6
go.sum
View File

@ -1,6 +1,8 @@
github.com/charmbracelet/tea v0.0.0-20200126032228-29799c315162 h1:BderJi+l/5OV27L0wfE3yUA6rXaDldcKAHVUt8DfYVw=
github.com/charmbracelet/tea v0.0.0-20200126032228-29799c315162/go.mod h1:UsFFdg04MNbcYi1r2FBtdDEFY07bObaYDKHhE1xZUaQ=
github.com/charmbracelet/tea v0.0.0-20200130023737-bb06373836b4 h1:O8IGyYrKQuCwZZ98JP3DvzQCoPiXM5Y2zjwlDY7mOFM=
github.com/charmbracelet/tea v0.0.0-20200130023737-bb06373836b4/go.mod h1:UsFFdg04MNbcYi1r2FBtdDEFY07bObaYDKHhE1xZUaQ=
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd/D9hzL95SuoOQAaFNdLU0=
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
golang.org/x/sys v0.0.0-20200120151820-655fe14d7479 h1:LhLiKguPgZL+Tglay4GhVtfF0kb8cvOJ0dHTCBO8YNI=
golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

View File

@ -51,6 +51,12 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
m.pos++
}
return m, nil
case tea.KeyCtrlA: // ^A, beginning
m.pos = 0
return m, nil
case tea.KeyCtrlE: // ^E, end
m.pos = len(m.Value) - 1
return m, nil
case tea.KeyRune:
m.Value = m.Value[:m.pos] + msg.String() + m.Value[m.pos:]
m.pos++