Add cmd-menu-discard command (#2146)
* [WIP] Add `cmd-menu-discard` command * Add `compmenu` to $lf_mode * Add `cmd-menu-discard` command * Update documentation
This commit is contained in:
1 parent
9e5f6af3b7
commit
5aeb9a490b
6 files changed
+40
-10
No files matched your search
@@ -9,6 +9,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@@ -694,8 +695,9 @@ func (app *app) menuComplete(direction int) {
|
|||||||
app.menuCompInd = len(app.menuComps) - 1
|
app.menuCompInd = len(app.menuComps) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
app.menuCompTmp[len(app.menuCompTmp)-1] = app.menuComps[app.menuCompInd].result
|
toks := slices.Clone(app.menuCompTmp)
|
||||||
app.ui.cmdAccLeft = []rune(strings.Join(app.menuCompTmp, " "))
|
toks[len(toks)-1] = app.menuComps[app.menuCompInd].result
|
||||||
|
app.ui.cmdAccLeft = []rune(strings.Join(toks, " "))
|
||||||
}
|
}
|
||||||
app.ui.menu, app.ui.menuSelect = listMatches(app.ui.screen, app.menuComps, app.menuCompInd)
|
app.ui.menu, app.ui.menuSelect = listMatches(app.ui.screen, app.menuComps, app.menuCompInd)
|
||||||
}
|
}
|
||||||
@@ -717,6 +719,10 @@ func (app *app) watchDir(dir *dir) {
|
|||||||
|
|
||||||
func (app *app) exportMode() {
|
func (app *app) exportMode() {
|
||||||
getMode := func() string {
|
getMode := func() string {
|
||||||
|
if app.menuCompActive {
|
||||||
|
return "compmenu"
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(app.ui.cmdPrefix, "delete") {
|
if strings.HasPrefix(app.ui.cmdPrefix, "delete") {
|
||||||
return "delete"
|
return "delete"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ var (
|
|||||||
"cmd-left",
|
"cmd-left",
|
||||||
"cmd-lowercase-word",
|
"cmd-lowercase-word",
|
||||||
"cmd-menu-accept",
|
"cmd-menu-accept",
|
||||||
|
"cmd-menu-discard",
|
||||||
"cmd-menu-complete",
|
"cmd-menu-complete",
|
||||||
"cmd-menu-complete-back",
|
"cmd-menu-complete-back",
|
||||||
"cmd-right",
|
"cmd-right",
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ The following Command-line mode commands are provided by lf:
|
|||||||
cmd-menu-complete
|
cmd-menu-complete
|
||||||
cmd-menu-complete-back
|
cmd-menu-complete-back
|
||||||
cmd-menu-accept
|
cmd-menu-accept
|
||||||
|
cmd-menu-discard
|
||||||
cmd-enter (default '<c-j>' and '<enter>')
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
cmd-interrupt (default '<c-c>')
|
cmd-interrupt (default '<c-c>')
|
||||||
cmd-history-next (default '<c-n>' and '<down>')
|
cmd-history-next (default '<c-n>' and '<down>')
|
||||||
@@ -654,6 +655,10 @@ You can use the assigned keys to display the menu and then cycle through complet
|
|||||||
|
|
||||||
Accept the currently selected match in menu completion and close the menu.
|
Accept the currently selected match in menu completion and close the menu.
|
||||||
|
|
||||||
|
## cmd-menu-discard
|
||||||
|
|
||||||
|
Discard the currently selected match in menu completion and close the menu.
|
||||||
|
|
||||||
## cmd-enter (default `<c-j>` and `<enter>`)
|
## cmd-enter (default `<c-j>` and `<enter>`)
|
||||||
|
|
||||||
Execute the current line.
|
Execute the current line.
|
||||||
@@ -1240,7 +1245,7 @@ Value of the count associated with the current command.
|
|||||||
|
|
||||||
Current mode that `lf` is operating in.
|
Current mode that `lf` is operating in.
|
||||||
This is useful for customizing keybindings depending on what the current mode is.
|
This is useful for customizing keybindings depending on what the current mode is.
|
||||||
Possible values are `delete`, `rename`, `filter`, `find`, `mark`, `search`, `command`, `shell`, `pipe` (when running a shell-pipe command), `normal`, `visual` and `unknown`.
|
Possible values are `compmenu`, `delete`, `rename`, `filter`, `find`, `mark`, `search`, `command`, `shell`, `pipe` (when running a shell-pipe command), `normal`, `visual` and `unknown`.
|
||||||
|
|
||||||
# SPECIAL COMMANDS
|
# SPECIAL COMMANDS
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ The following Command-line mode commands are provided by lf:
|
|||||||
cmd-menu-complete
|
cmd-menu-complete
|
||||||
cmd-menu-complete-back
|
cmd-menu-complete-back
|
||||||
cmd-menu-accept
|
cmd-menu-accept
|
||||||
|
cmd-menu-discard
|
||||||
cmd-enter (default '<c-j>' and '<enter>')
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
cmd-interrupt (default '<c-c>')
|
cmd-interrupt (default '<c-c>')
|
||||||
cmd-history-next (default '<c-n>' and '<down>')
|
cmd-history-next (default '<c-n>' and '<down>')
|
||||||
@@ -680,6 +681,11 @@ cmd-menu-accept
|
|||||||
Accept the currently selected match in menu completion and close the
|
Accept the currently selected match in menu completion and close the
|
||||||
menu.
|
menu.
|
||||||
|
|
||||||
|
cmd-menu-discard
|
||||||
|
|
||||||
|
Discard the currently selected match in menu completion and close the
|
||||||
|
menu.
|
||||||
|
|
||||||
cmd-enter (default <c-j> and <enter>)
|
cmd-enter (default <c-j> and <enter>)
|
||||||
|
|
||||||
Execute the current line.
|
Execute the current line.
|
||||||
@@ -1340,8 +1346,8 @@ lf_mode
|
|||||||
|
|
||||||
Current mode that lf is operating in. This is useful for customizing
|
Current mode that lf is operating in. This is useful for customizing
|
||||||
keybindings depending on what the current mode is. Possible values are
|
keybindings depending on what the current mode is. Possible values are
|
||||||
delete, rename, filter, find, mark, search, command, shell, pipe (when
|
compmenu, delete, rename, filter, find, mark, search, command, shell,
|
||||||
running a shell-pipe command), normal, visual and unknown.
|
pipe (when running a shell-pipe command), normal, visual and unknown.
|
||||||
|
|
||||||
SPECIAL COMMANDS
|
SPECIAL COMMANDS
|
||||||
|
|
||||||
|
|||||||
@@ -1850,6 +1850,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.menu = ""
|
app.ui.menu = ""
|
||||||
app.ui.menuSelect = nil
|
app.ui.menuSelect = nil
|
||||||
app.menuCompActive = false
|
app.menuCompActive = false
|
||||||
|
case "cmd-menu-discard":
|
||||||
|
if app.menuCompActive {
|
||||||
|
app.ui.cmdAccLeft = []rune(strings.Join(app.menuCompTmp, " "))
|
||||||
|
}
|
||||||
|
app.ui.menu = ""
|
||||||
|
app.ui.menuSelect = nil
|
||||||
|
app.menuCompActive = false
|
||||||
case "cmd-enter":
|
case "cmd-enter":
|
||||||
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
|
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
|
||||||
if len(s) == 0 && app.ui.cmdPrefix != "filter: " && app.ui.cmdPrefix != ">" {
|
if len(s) == 0 && app.ui.cmdPrefix != "filter: " && app.ui.cmdPrefix != ">" {
|
||||||
@@ -2270,6 +2277,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
"cmd-menu-complete",
|
"cmd-menu-complete",
|
||||||
"cmd-menu-complete-back",
|
"cmd-menu-complete-back",
|
||||||
"cmd-menu-accept",
|
"cmd-menu-accept",
|
||||||
|
"cmd-menu-discard",
|
||||||
"cmd-enter",
|
"cmd-enter",
|
||||||
"cmd-interrupt",
|
"cmd-interrupt",
|
||||||
"cmd-history-next",
|
"cmd-history-next",
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ cmd\-complete (default \(aq<tab>\(aq)
|
|||||||
cmd\-menu\-complete
|
cmd\-menu\-complete
|
||||||
cmd\-menu\-complete\-back
|
cmd\-menu\-complete\-back
|
||||||
cmd\-menu\-accept
|
cmd\-menu\-accept
|
||||||
|
cmd\-menu\-discard
|
||||||
cmd\-enter (default \(aq<c\-j>\(aq and \(aq<enter>\(aq)
|
cmd\-enter (default \(aq<c\-j>\(aq and \(aq<enter>\(aq)
|
||||||
cmd\-interrupt (default \(aq<c\-c>\(aq)
|
cmd\-interrupt (default \(aq<c\-c>\(aq)
|
||||||
cmd\-history\-next (default \(aq<c\-n>\(aq and \(aq<down>\(aq)
|
cmd\-history\-next (default \(aq<c\-n>\(aq and \(aq<down>\(aq)
|
||||||
@@ -626,6 +627,9 @@ completion options.
|
|||||||
.SS cmd\-menu\-accept
|
.SS cmd\-menu\-accept
|
||||||
Accept the currently selected match in menu completion and close the
|
Accept the currently selected match in menu completion and close the
|
||||||
menu.
|
menu.
|
||||||
|
.SS cmd\-menu\-discard
|
||||||
|
Discard the currently selected match in menu completion and close the
|
||||||
|
menu.
|
||||||
.SS cmd\-enter (default \f[CR]<c\-j>\f[R] and \f[CR]<enter>\f[R])
|
.SS cmd\-enter (default \f[CR]<c\-j>\f[R] and \f[CR]<enter>\f[R])
|
||||||
Execute the current line.
|
Execute the current line.
|
||||||
.SS cmd\-interrupt (default \f[CR]<c\-c>\f[R])
|
.SS cmd\-interrupt (default \f[CR]<c\-c>\f[R])
|
||||||
@@ -1151,11 +1155,11 @@ Value of the count associated with the current command.
|
|||||||
Current mode that \f[CR]lf\f[R] is operating in.
|
Current mode that \f[CR]lf\f[R] is operating in.
|
||||||
This is useful for customizing keybindings depending on what the current
|
This is useful for customizing keybindings depending on what the current
|
||||||
mode is.
|
mode is.
|
||||||
Possible values are \f[CR]delete\f[R], \f[CR]rename\f[R],
|
Possible values are \f[CR]compmenu\f[R], \f[CR]delete\f[R],
|
||||||
\f[CR]filter\f[R], \f[CR]find\f[R], \f[CR]mark\f[R], \f[CR]search\f[R],
|
\f[CR]rename\f[R], \f[CR]filter\f[R], \f[CR]find\f[R], \f[CR]mark\f[R],
|
||||||
\f[CR]command\f[R], \f[CR]shell\f[R], \f[CR]pipe\f[R] (when running a
|
\f[CR]search\f[R], \f[CR]command\f[R], \f[CR]shell\f[R], \f[CR]pipe\f[R]
|
||||||
shell\-pipe command), \f[CR]normal\f[R], \f[CR]visual\f[R] and
|
(when running a shell\-pipe command), \f[CR]normal\f[R],
|
||||||
\f[CR]unknown\f[R].
|
\f[CR]visual\f[R] and \f[CR]unknown\f[R].
|
||||||
.SH SPECIAL COMMANDS
|
.SH SPECIAL COMMANDS
|
||||||
This section shows information about special shell commands.
|
This section shows information about special shell commands.
|
||||||
.SS open
|
.SS open
|
||||||
|
|||||||
Reference in new issue
Block a user