From 501f9cbbe157f3172dbc42611c76c935687bcd0a Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 29 Jan 2020 21:46:03 -0500 Subject: [PATCH] Add ^A and ^E keybindings --- go.mod | 5 ++++- go.sum | 6 ++++-- input/input.go | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a0e36f1..623acb5 100644 --- a/go.mod +++ b/go.mod @@ -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 +) diff --git a/go.sum b/go.sum index 6867ad7..9c48a5e 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/input/input.go b/input/input.go index 17a4c00..fdd88c2 100644 --- a/input/input.go +++ b/input/input.go @@ -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++