add 'cmd-lowercase-word' to downcase word to end

This commit is contained in:
Gokcehan 2018-05-14 01:38:19 +03:00
parent 18f6d954a7
commit 6e6cca33b8
4 changed files with 13 additions and 0 deletions

1
doc.go
View File

@ -76,6 +76,7 @@ keybindings:
cmd-capitalize-word (default '<a-c>')
cmd-delete-word (default '<a-d>')
cmd-uppercase-word (default '<a-u>')
cmd-lowercase-word (default '<a-l>')
The following options can be used to customize the behavior of lf:

View File

@ -80,6 +80,7 @@ keybindings:
cmd-capitalize-word (default '<a-c>')
cmd-delete-word (default '<a-d>')
cmd-uppercase-word (default '<a-u>')
cmd-lowercase-word (default '<a-l>')
The following options can be used to customize the behavior of lf:

10
eval.go
View File

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

View File

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