add 'cmd-delete-word' to delete word to end

This commit is contained in:
Gokcehan 2018-05-14 01:25:26 +03:00
parent afefc30a67
commit 1a95df7b64
4 changed files with 12 additions and 0 deletions

1
doc.go
View File

@ -74,6 +74,7 @@ keybindings:
cmd-word (default '<a-f>')
cmd-word-back (default '<a-b>')
cmd-capitalize-word (default '<a-c>')
cmd-delete-word (default '<a-d>')
The following options can be used to customize the behavior of lf:

View File

@ -78,6 +78,7 @@ keybindings:
cmd-word (default '<a-f>')
cmd-word-back (default '<a-b>')
cmd-capitalize-word (default '<a-c>')
cmd-delete-word (default '<a-d>')
The following options can be used to customize the behavior of lf:

View File

@ -642,6 +642,15 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdAccRight[:ind]...)
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
}
case "cmd-delete-word":
if len(app.ui.cmdAccRight) > 0 {
loc := reWordEnd.FindStringIndex(string(app.ui.cmdAccRight))
if loc == nil {
return
}
ind := loc[0] + 1
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
}
default:
cmd, ok := gOpts.cmds[e.name]
if !ok {

View File

@ -145,6 +145,7 @@ func init() {
gOpts.cmdkeys["<a-f>"] = &callExpr{"cmd-word", nil, 1}
gOpts.cmdkeys["<a-b>"] = &callExpr{"cmd-word-back", nil, 1}
gOpts.cmdkeys["<a-c>"] = &callExpr{"cmd-capitalize-word", nil, 1}
gOpts.cmdkeys["<a-d>"] = &callExpr{"cmd-delete-word", nil, 1}
// TODO: implement the rest of readline keys