From 23f5f3328325778efc4d0a0fb8883d9fb9918a17 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 29 Jan 2020 22:25:39 -0500 Subject: [PATCH] Add ^U, ^B and ^F keybindings --- input/input.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/input/input.go b/input/input.go index 09952a3..e443a0e 100644 --- a/input/input.go +++ b/input/input.go @@ -43,11 +43,15 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) { m.pos-- } return m, nil + case tea.KeyCtrlF: // ^F, forward one character + fallthrough case tea.KeyLeft: if m.pos > 0 { m.pos-- } return m, nil + case tea.KeyCtrlB: // ^B, back one charcter + fallthrough case tea.KeyRight: if m.pos < len(m.Value) { m.pos++ @@ -68,6 +72,10 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) { m.Value = m.Value[:m.pos] m.pos = len(m.Value) return m, nil + case tea.KeyCtrlU: // ^U, kill text before cursor + m.Value = m.Value[m.pos:] + m.pos = 0 + return m, nil case tea.KeyRune: m.Value = m.Value[:m.pos] + msg.String() + m.Value[m.pos:] m.pos++