* Use Ctrl-F and Ctrl-B to move forward/backward one character
* Use Alt-F and Alt-B to move forward/backward one word
* Use Ctrl-A and Ctrl-E to move to the beginning/end of the input line
* Use Ctrl-K to delete all text from the cursor position to the end of
the current line
---
app.go | 14 ++++++++++++++doc/senpai.1.scd | 22 ++++++++++++++++++++++ui/editor.go | 15 +++++++++++++++ui/ui.go | 4 ++++
4 files changed, 55 insertions(+)
diff --git a/app.go b/app.go
index b044a06..768327f 100644
--- a/app.go+++ b/app.go
@@ -505,6 +505,16 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) {
} else {
app.win.InputSet("/quit")
}
+ case tcell.KeyCtrlA:+ app.win.InputHome()+ case tcell.KeyCtrlB:+ app.win.InputLeft()+ case tcell.KeyCtrlE:+ app.win.InputEnd()+ case tcell.KeyCtrlF:+ app.win.InputRight()+ case tcell.KeyCtrlK:+ app.win.InputKillLine() case tcell.KeyCtrlL:
app.win.Resize()
case tcell.KeyCtrlU, tcell.KeyPgUp:
@@ -614,6 +624,10 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) {
app.win.ScrollDownHighlight()
case 'p':
app.win.ScrollUpHighlight()
+ case 'f':+ app.win.InputRightWord()+ case 'b':+ app.win.InputLeftWord() case '1', '2', '3', '4', '5', '6', '7', '8', '9':
app.win.GoToBufferNo(int(ev.Rune()-'0') - 1)
}
diff --git a/doc/senpai.1.scd b/doc/senpai.1.scd
index abb0af8..4e62405 100644
--- a/doc/senpai.1.scd+++ b/doc/senpai.1.scd
@@ -65,9 +65,25 @@ of messages are in the timeline:
# KEYBOARD SHORTCUTS
+*CTRL-A*+ Move the cursor to the beginning of the input field.++*CTRL-B*+ Move the cursor backward one character.++*CTRL-E*+ Move the cursor to the end of the input field.++*CTRL-F*+ Move the cursor forward one character.+*CTRL-C*
Clear input line.
+*CTRL-K*+ Remove all of the text from the cursor position to the end of the input+ line.+*CTRL-U*, *PgUp*
Go up in the timeline.
@@ -86,6 +102,12 @@ of messages are in the timeline:
*ALT-END*
Go to the last buffer.
+*ALT-B*+ Move the cursor backward one word.++*ALT-F*+ Move the cursor forward one word.+*ALT-P*
Go to the previous highlight
diff --git a/ui/editor.go b/ui/editor.go
index 606bf8d..ddd7039 100644
--- a/ui/editor.go+++ b/ui/editor.go
@@ -143,6 +143,21 @@ func (e *Editor) RemRuneForward() (ok bool) {
return
}
+func (e *Editor) RemLineForward() (ok bool) {+ ok = e.cursorIdx < len(e.text[e.lineIdx])+ if !ok {+ return+ }++ for i := len(e.text[e.lineIdx]); i > e.cursorIdx; i-- {+ e.remRuneAt(i - 1)+ }++ e.autoCache = nil+ e.backsearchEnd()+ return+}+func (e *Editor) remRuneAt(idx int) {
// TODO avoid looping twice
rw := e.textWidth[idx+1] - e.textWidth[idx]
diff --git a/ui/ui.go b/ui/ui.go
index 77757cb..98e048e 100644
--- a/ui/ui.go+++ b/ui/ui.go
@@ -377,6 +377,10 @@ func (ui *UI) InputDeleteWord() (ok bool) {
return ui.e.RemWord()
}
+func (ui *UI) InputKillLine() (ok bool) {+ return ui.e.RemLineForward()+}+func (ui *UI) InputAutoComplete(offset int) (ok bool) {
return ui.e.AutoComplete(offset)
}
--
2.35.3