Add ^D to delete character under cursor

This commit is contained in:
Christian Rocha 2020-01-29 22:19:47 -05:00
parent 3ac2b4881b
commit 127afac006
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018

View File

@ -56,6 +56,11 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
case tea.KeyCtrlA: // ^A, beginning
m.pos = 0
return m, nil
case tea.KeyCtrlD: // ^D, delete char under cursor
if len(m.Value) > 0 && m.pos < len(m.Value) {
m.Value = m.Value[:m.pos] + m.Value[m.pos+1:]
}
return m, nil
case tea.KeyCtrlE: // ^E, end
m.pos = len(m.Value) - 1
return m, nil