'toggle' command now toggles selection on its arguments when at least one (#409)

* 'toggle' command now toggles selection on its arguments when given and some cleanup

* update doc
This commit is contained in:
gotroyb127 2020-07-14 19:28:01 +03:00 committed by GitHub
parent 001ee5bfae
commit 75e59cdd08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 8 deletions

3
doc.go
View File

@ -63,7 +63,8 @@ The following commands are provided by lf without default keybindings:
echoerr same as echomsg but red color
cd change working directory to the argument
select change current file selection to the argument
toggle toggle the selection of the current file
toggle toggle the selection of the current file or,
when passed arguments, of its arguments
glob-select select files that match the given glob
glob-unselect unselect files that match the given glob
source read the configuration file in the argument

View File

@ -66,7 +66,8 @@ The following commands are provided by lf without default keybindings:
echoerr same as echomsg but red color
cd change working directory to the argument
select change current file selection to the argument
toggle toggle the selection of the current file
toggle toggle the selection of the current file or,
when passed arguments, of its arguments
glob-select select files that match the given glob
glob-unselect unselect files that match the given glob
source read the configuration file in the argument

16
eval.go
View File

@ -683,15 +683,21 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFile(app.nav)
app.ui.loadFileInfo(app.nav)
case "toggle":
app.nav.toggle()
app.ui.loadFile(app.nav)
app.ui.loadFileInfo(app.nav)
if len(e.args) == 0 {
app.nav.toggle()
} else {
for _, path := range e.args {
if _, err := os.Stat(path); err == nil {
app.nav.toggleSelection(path)
} else {
log.Printf("toggle: %s", err)
}
}
}
case "invert":
app.nav.invert()
app.ui.loadFileInfo(app.nav)
case "unselect":
app.nav.unselect()
app.ui.loadFileInfo(app.nav)
case "copy":
if err := app.nav.save(true); err != nil {
app.ui.echoerrf("copy: %s", err)

3
lf.1
View File

@ -75,7 +75,8 @@ The following commands are provided by lf without default keybindings:
echoerr same as echomsg but red color
cd change working directory to the argument
select change current file selection to the argument
toggle toggle the selection of the current file
toggle toggle the selection of the current file or,
when passed arguments, of its arguments
glob-select select files that match the given glob
glob-unselect unselect files that match the given glob
source read the configuration file in the argument