From 18f6d954a7bd56d87bf2d006af28d2a53082b70a Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Mon, 14 May 2018 01:30:53 +0300 Subject: [PATCH] add 'cmd-uppercase-word' to upcase word to end --- doc.go | 1 + docstring.go | 1 + eval.go | 10 ++++++++++ opts.go | 1 + 4 files changed, 13 insertions(+) diff --git a/doc.go b/doc.go index d511b2b..2b7da17 100644 --- a/doc.go +++ b/doc.go @@ -75,6 +75,7 @@ keybindings: cmd-word-back (default '') cmd-capitalize-word (default '') cmd-delete-word (default '') + cmd-uppercase-word (default '') The following options can be used to customize the behavior of lf: diff --git a/docstring.go b/docstring.go index 7a8c150..ebf6da4 100644 --- a/docstring.go +++ b/docstring.go @@ -79,6 +79,7 @@ keybindings: cmd-word-back (default '') cmd-capitalize-word (default '') cmd-delete-word (default '') + cmd-uppercase-word (default '') The following options can be used to customize the behavior of lf: diff --git a/eval.go b/eval.go index 66d72d0..8a29b98 100644 --- a/eval.go +++ b/eval.go @@ -651,6 +651,16 @@ func (e *callExpr) eval(app *app, args []string) { ind := loc[0] + 1 app.ui.cmdAccRight = app.ui.cmdAccRight[ind:] } + case "cmd-uppercase-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.ToUpper(string(app.ui.cmdAccRight[:ind])))...) + app.ui.cmdAccRight = app.ui.cmdAccRight[ind:] + } default: cmd, ok := gOpts.cmds[e.name] if !ok { diff --git a/opts.go b/opts.go index 9764b49..746b39e 100644 --- a/opts.go +++ b/opts.go @@ -146,6 +146,7 @@ func init() { gOpts.cmdkeys[""] = &callExpr{"cmd-word-back", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-capitalize-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete-word", nil, 1} + gOpts.cmdkeys[""] = &callExpr{"cmd-uppercase-word", nil, 1} // TODO: implement the rest of readline keys