Reorder commands to be consistent with documentation (#2075)
This commit is contained in:
1 parent
47b3bc5617
commit
9183e81f7f
4 files changed
+622
-601
No files matched your search
@@ -57,13 +57,10 @@ The following commands are provided by lf:
|
||||
middle (default 'M')
|
||||
low (default 'L')
|
||||
toggle
|
||||
visual (default 'V')
|
||||
invert (default 'v')
|
||||
unselect (default 'u')
|
||||
glob-select
|
||||
glob-unselect
|
||||
calcdirsize
|
||||
clearmaps
|
||||
copy (default 'y')
|
||||
cut (default 'd')
|
||||
paste (default 'p')
|
||||
@@ -73,15 +70,8 @@ The following commands are provided by lf:
|
||||
redraw (default '<c-l>')
|
||||
load
|
||||
reload (default '<c-r>')
|
||||
echo
|
||||
echomsg
|
||||
echoerr
|
||||
cd
|
||||
select
|
||||
delete (modal)
|
||||
rename (modal) (default 'r')
|
||||
source
|
||||
push
|
||||
read (modal) (default ':')
|
||||
shell (modal) (default '$')
|
||||
shell-pipe (modal) (default '%')
|
||||
@@ -102,8 +92,18 @@ The following commands are provided by lf:
|
||||
mark-remove (modal) (default '"')
|
||||
tag
|
||||
tag-toggle (default 't')
|
||||
echo
|
||||
echomsg
|
||||
echoerr
|
||||
cd
|
||||
select
|
||||
source
|
||||
push
|
||||
addcustominfo
|
||||
calcdirsize
|
||||
clearmaps
|
||||
tty-write
|
||||
visual (default 'V')
|
||||
|
||||
The following Visual mode commands are provided by lf:
|
||||
|
||||
@@ -114,6 +114,7 @@ The following Visual mode commands are provided by lf:
|
||||
|
||||
The following Command-line mode commands are provided by lf:
|
||||
|
||||
cmd-insert
|
||||
cmd-escape (default '<esc>')
|
||||
cmd-complete (default '<tab>')
|
||||
cmd-menu-complete
|
||||
@@ -414,27 +415,6 @@ Move the current file selection to the high/middle/low of the screen.
|
||||
|
||||
Toggle the selection of the current file or files given as arguments.
|
||||
|
||||
## visual (default `V`)
|
||||
|
||||
Switch to Visual mode.
|
||||
If already in Visual mode, discard the visual selection and stay in Visual mode.
|
||||
|
||||
## visual-accept (default `V`)
|
||||
|
||||
Add the visual selection to the selection list, quit Visual mode and return to Normal mode.
|
||||
|
||||
## visual-unselect
|
||||
|
||||
Remove the visual selection from the selection list, quit Visual mode and return to Normal mode.
|
||||
|
||||
## visual-discard (default `<esc>`)
|
||||
|
||||
Discard the visual selection, quit Visual mode and return to Normal mode.
|
||||
|
||||
## visual-change (default `o`)
|
||||
|
||||
Go to the other end of the current Visual mode selection.
|
||||
|
||||
## invert (default `v`)
|
||||
|
||||
Reverse the selection of all files in the current directory (i.e. `toggle` all files).
|
||||
@@ -449,18 +429,6 @@ Remove the selection of all files in all directories.
|
||||
|
||||
Select/unselect files that match the given glob.
|
||||
|
||||
## calcdirsize
|
||||
|
||||
Calculate the total size for each of the selected directories.
|
||||
Option `info` should include `size` and option `dircounts` should be disabled to show this size.
|
||||
If the total size of a directory is not calculated, it will be shown as `-`.
|
||||
|
||||
## clearmaps
|
||||
|
||||
Remove all keybindings associated with the `map`, `nmap` and `vmap` command.
|
||||
This command can be used in the config file to remove the default keybindings.
|
||||
For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`.
|
||||
|
||||
## copy (default `y`)
|
||||
|
||||
If there are no selections, save the path of the current file to the copy buffer, otherwise, copy the paths of selected files.
|
||||
@@ -501,26 +469,6 @@ This command is automatically called when required.
|
||||
|
||||
Flush the cache and reload all files and directories.
|
||||
|
||||
## echo
|
||||
|
||||
Print the given arguments to the message line at the bottom.
|
||||
|
||||
## echomsg
|
||||
|
||||
Print the given arguments to the message line at the bottom and also to the log file.
|
||||
|
||||
## echoerr
|
||||
|
||||
Print given arguments to the message line at the bottom as `errorfmt` and also to the log file.
|
||||
|
||||
## cd
|
||||
|
||||
Change the working directory to the given argument.
|
||||
|
||||
## select
|
||||
|
||||
Change the current file selection to the given argument.
|
||||
|
||||
## delete (modal)
|
||||
|
||||
Remove the current file or selected file(s).
|
||||
@@ -531,14 +479,6 @@ A custom `delete` command can be defined to override this default.
|
||||
Rename the current file using the built-in method.
|
||||
A custom `rename` command can be defined to override this default.
|
||||
|
||||
## source
|
||||
|
||||
Read the configuration file given in the argument.
|
||||
|
||||
## push
|
||||
|
||||
Simulate key pushes given in the argument.
|
||||
|
||||
## read (modal) (default `:`)
|
||||
|
||||
Read a command to evaluate.
|
||||
@@ -595,19 +535,82 @@ You can define a new tag-clearing command by combining `tag` with `tag-toggle` (
|
||||
|
||||
Tag a file with `*` or a single width character given in the argument if the file is untagged, otherwise remove the tag.
|
||||
|
||||
## echo
|
||||
|
||||
Print the given arguments to the message line at the bottom.
|
||||
|
||||
## echomsg
|
||||
|
||||
Print the given arguments to the message line at the bottom and also to the log file.
|
||||
|
||||
## echoerr
|
||||
|
||||
Print given arguments to the message line at the bottom as `errorfmt` and also to the log file.
|
||||
|
||||
## cd
|
||||
|
||||
Change the working directory to the given argument.
|
||||
|
||||
## select
|
||||
|
||||
Change the current file selection to the given argument.
|
||||
|
||||
## source
|
||||
|
||||
Read the configuration file given in the argument.
|
||||
|
||||
## push
|
||||
|
||||
Simulate key pushes given in the argument.
|
||||
|
||||
## addcustominfo
|
||||
|
||||
Update the `custom` info field of the given file with the given string.
|
||||
The info string may contain ANSI escape codes to further customize its appearance.
|
||||
If no info is provided, clear the file's info instead.
|
||||
|
||||
## calcdirsize
|
||||
|
||||
Calculate the total size for each of the selected directories.
|
||||
Option `info` should include `size` and option `dircounts` should be disabled to show this size.
|
||||
If the total size of a directory is not calculated, it will be shown as `-`.
|
||||
|
||||
## clearmaps
|
||||
|
||||
Remove all keybindings associated with the `map`, `nmap` and `vmap` command.
|
||||
This command can be used in the config file to remove the default keybindings.
|
||||
For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`.
|
||||
|
||||
## tty-write
|
||||
|
||||
Write the given string to the tty.
|
||||
This is useful for sending escape sequences to the terminal to control its behavior (e.g. OSC 0 to set the window title).
|
||||
Using `tty-write` is preferred over directly writing to `/dev/tty` because the latter is not synchronized and can interfere with drawing the UI.
|
||||
|
||||
# COMMAND LINE COMMANDS
|
||||
## visual (default `V`)
|
||||
|
||||
Switch to Visual mode.
|
||||
If already in Visual mode, discard the visual selection and stay in Visual mode.
|
||||
|
||||
# VISUAL MODE COMMANDS
|
||||
|
||||
## visual-accept (default `V`)
|
||||
|
||||
Add the visual selection to the selection list, quit Visual mode and return to Normal mode.
|
||||
|
||||
## visual-unselect
|
||||
|
||||
Remove the visual selection from the selection list, quit Visual mode and return to Normal mode.
|
||||
|
||||
## visual-discard (default `<esc>`)
|
||||
|
||||
Discard the visual selection, quit Visual mode and return to Normal mode.
|
||||
|
||||
## visual-change (default `o`)
|
||||
|
||||
Go to the other end of the current Visual mode selection.
|
||||
|
||||
# COMMAND-LINE MODE COMMANDS
|
||||
|
||||
The prompt character specifies which of the several Command-line modes you are in.
|
||||
For example, the `read` command takes you to the `:` mode.
|
||||
@@ -618,6 +621,11 @@ You can go back with `cmd-delete-back` (`<backspace>` by default).
|
||||
The command line commands should be mostly compatible with readline keybindings.
|
||||
A character refers to a Unicode code point, a word consists of letters and digits, and a unix word consists of any non-blank characters.
|
||||
|
||||
## cmd-insert
|
||||
|
||||
Insert the character given in the argument.
|
||||
This command is automatically called when required.
|
||||
|
||||
## cmd-escape (default `<esc>`)
|
||||
|
||||
Quit Command-line mode and return to Normal mode.
|
||||
|
||||
@@ -47,13 +47,10 @@ The following commands are provided by lf:
|
||||
middle (default 'M')
|
||||
low (default 'L')
|
||||
toggle
|
||||
visual (default 'V')
|
||||
invert (default 'v')
|
||||
unselect (default 'u')
|
||||
glob-select
|
||||
glob-unselect
|
||||
calcdirsize
|
||||
clearmaps
|
||||
copy (default 'y')
|
||||
cut (default 'd')
|
||||
paste (default 'p')
|
||||
@@ -63,15 +60,8 @@ The following commands are provided by lf:
|
||||
redraw (default '<c-l>')
|
||||
load
|
||||
reload (default '<c-r>')
|
||||
echo
|
||||
echomsg
|
||||
echoerr
|
||||
cd
|
||||
select
|
||||
delete (modal)
|
||||
rename (modal) (default 'r')
|
||||
source
|
||||
push
|
||||
read (modal) (default ':')
|
||||
shell (modal) (default '$')
|
||||
shell-pipe (modal) (default '%')
|
||||
@@ -92,8 +82,18 @@ The following commands are provided by lf:
|
||||
mark-remove (modal) (default '"')
|
||||
tag
|
||||
tag-toggle (default 't')
|
||||
echo
|
||||
echomsg
|
||||
echoerr
|
||||
cd
|
||||
select
|
||||
source
|
||||
push
|
||||
addcustominfo
|
||||
calcdirsize
|
||||
clearmaps
|
||||
tty-write
|
||||
visual (default 'V')
|
||||
|
||||
The following Visual mode commands are provided by lf:
|
||||
|
||||
@@ -104,6 +104,7 @@ The following Visual mode commands are provided by lf:
|
||||
|
||||
The following Command-line mode commands are provided by lf:
|
||||
|
||||
cmd-insert
|
||||
cmd-escape (default '<esc>')
|
||||
cmd-complete (default '<tab>')
|
||||
cmd-menu-complete
|
||||
@@ -413,30 +414,6 @@ toggle
|
||||
|
||||
Toggle the selection of the current file or files given as arguments.
|
||||
|
||||
visual (default V)
|
||||
|
||||
Switch to Visual mode. If already in Visual mode, discard the visual
|
||||
selection and stay in Visual mode.
|
||||
|
||||
visual-accept (default V)
|
||||
|
||||
Add the visual selection to the selection list, quit Visual mode and
|
||||
return to Normal mode.
|
||||
|
||||
visual-unselect
|
||||
|
||||
Remove the visual selection from the selection list, quit Visual mode
|
||||
and return to Normal mode.
|
||||
|
||||
visual-discard (default <esc>)
|
||||
|
||||
Discard the visual selection, quit Visual mode and return to Normal
|
||||
mode.
|
||||
|
||||
visual-change (default o)
|
||||
|
||||
Go to the other end of the current Visual mode selection.
|
||||
|
||||
invert (default v)
|
||||
|
||||
Reverse the selection of all files in the current directory (i.e. toggle
|
||||
@@ -454,21 +431,6 @@ glob-select, glob-unselect
|
||||
|
||||
Select/unselect files that match the given glob.
|
||||
|
||||
calcdirsize
|
||||
|
||||
Calculate the total size for each of the selected directories. Option
|
||||
info should include size and option dircounts should be disabled to show
|
||||
this size. If the total size of a directory is not calculated, it will
|
||||
be shown as -.
|
||||
|
||||
clearmaps
|
||||
|
||||
Remove all keybindings associated with the map, nmap and vmap command.
|
||||
This command can be used in the config file to remove the default
|
||||
keybindings. For safety purposes, : is left mapped to the read command,
|
||||
and cmap keybindings are retained so that it is still possible to exit
|
||||
lf using :quit.
|
||||
|
||||
copy (default y)
|
||||
|
||||
If there are no selections, save the path of the current file to the
|
||||
@@ -510,28 +472,6 @@ reload (default <c-r>)
|
||||
|
||||
Flush the cache and reload all files and directories.
|
||||
|
||||
echo
|
||||
|
||||
Print the given arguments to the message line at the bottom.
|
||||
|
||||
echomsg
|
||||
|
||||
Print the given arguments to the message line at the bottom and also to
|
||||
the log file.
|
||||
|
||||
echoerr
|
||||
|
||||
Print given arguments to the message line at the bottom as errorfmt and
|
||||
also to the log file.
|
||||
|
||||
cd
|
||||
|
||||
Change the working directory to the given argument.
|
||||
|
||||
select
|
||||
|
||||
Change the current file selection to the given argument.
|
||||
|
||||
delete (modal)
|
||||
|
||||
Remove the current file or selected file(s). A custom delete command can
|
||||
@@ -542,14 +482,6 @@ rename (modal) (default r)
|
||||
Rename the current file using the built-in method. A custom rename
|
||||
command can be defined to override this default.
|
||||
|
||||
source
|
||||
|
||||
Read the configuration file given in the argument.
|
||||
|
||||
push
|
||||
|
||||
Simulate key pushes given in the argument.
|
||||
|
||||
read (modal) (default :)
|
||||
|
||||
Read a command to evaluate.
|
||||
@@ -613,12 +545,57 @@ tag-toggle (default t)
|
||||
Tag a file with * or a single width character given in the argument if
|
||||
the file is untagged, otherwise remove the tag.
|
||||
|
||||
echo
|
||||
|
||||
Print the given arguments to the message line at the bottom.
|
||||
|
||||
echomsg
|
||||
|
||||
Print the given arguments to the message line at the bottom and also to
|
||||
the log file.
|
||||
|
||||
echoerr
|
||||
|
||||
Print given arguments to the message line at the bottom as errorfmt and
|
||||
also to the log file.
|
||||
|
||||
cd
|
||||
|
||||
Change the working directory to the given argument.
|
||||
|
||||
select
|
||||
|
||||
Change the current file selection to the given argument.
|
||||
|
||||
source
|
||||
|
||||
Read the configuration file given in the argument.
|
||||
|
||||
push
|
||||
|
||||
Simulate key pushes given in the argument.
|
||||
|
||||
addcustominfo
|
||||
|
||||
Update the custom info field of the given file with the given string.
|
||||
The info string may contain ANSI escape codes to further customize its
|
||||
appearance. If no info is provided, clear the file's info instead.
|
||||
|
||||
calcdirsize
|
||||
|
||||
Calculate the total size for each of the selected directories. Option
|
||||
info should include size and option dircounts should be disabled to show
|
||||
this size. If the total size of a directory is not calculated, it will
|
||||
be shown as -.
|
||||
|
||||
clearmaps
|
||||
|
||||
Remove all keybindings associated with the map, nmap and vmap command.
|
||||
This command can be used in the config file to remove the default
|
||||
keybindings. For safety purposes, : is left mapped to the read command,
|
||||
and cmap keybindings are retained so that it is still possible to exit
|
||||
lf using :quit.
|
||||
|
||||
tty-write
|
||||
|
||||
Write the given string to the tty. This is useful for sending escape
|
||||
@@ -627,7 +604,33 @@ window title). Using tty-write is preferred over directly writing to
|
||||
/dev/tty because the latter is not synchronized and can interfere with
|
||||
drawing the UI.
|
||||
|
||||
COMMAND LINE COMMANDS
|
||||
visual (default V)
|
||||
|
||||
Switch to Visual mode. If already in Visual mode, discard the visual
|
||||
selection and stay in Visual mode.
|
||||
|
||||
VISUAL MODE COMMANDS
|
||||
|
||||
visual-accept (default V)
|
||||
|
||||
Add the visual selection to the selection list, quit Visual mode and
|
||||
return to Normal mode.
|
||||
|
||||
visual-unselect
|
||||
|
||||
Remove the visual selection from the selection list, quit Visual mode
|
||||
and return to Normal mode.
|
||||
|
||||
visual-discard (default <esc>)
|
||||
|
||||
Discard the visual selection, quit Visual mode and return to Normal
|
||||
mode.
|
||||
|
||||
visual-change (default o)
|
||||
|
||||
Go to the other end of the current Visual mode selection.
|
||||
|
||||
COMMAND-LINE MODE COMMANDS
|
||||
|
||||
The prompt character specifies which of the several Command-line modes
|
||||
you are in. For example, the read command takes you to the : mode.
|
||||
@@ -641,6 +644,11 @@ keybindings. A character refers to a Unicode code point, a word consists
|
||||
of letters and digits, and a unix word consists of any non-blank
|
||||
characters.
|
||||
|
||||
cmd-insert
|
||||
|
||||
Insert the character given in the argument. This command is
|
||||
automatically called when required.
|
||||
|
||||
cmd-escape (default <esc>)
|
||||
|
||||
Quit Command-line mode and return to Normal mode.
|
||||
|
||||
@@ -1071,6 +1071,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
os.Setenv("lf_count", strconv.Itoa(e.count))
|
||||
|
||||
switch e.name {
|
||||
case "quit":
|
||||
app.quitChan <- struct{}{}
|
||||
case "up":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1127,19 +1129,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "tty-write":
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("tty-write: requires an argument")
|
||||
return
|
||||
}
|
||||
|
||||
tty, ok := app.ui.screen.Tty()
|
||||
if !ok {
|
||||
log.Printf("tty-write: failed to get tty")
|
||||
return
|
||||
}
|
||||
|
||||
tty.Write([]byte(e.args[0]))
|
||||
case "scroll-down":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1200,16 +1189,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
if cmd, ok := gOpts.cmds["open"]; ok {
|
||||
cmd.eval(app, e.args)
|
||||
}
|
||||
case "jump-prev":
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
for range e.count {
|
||||
app.nav.cdJumpListPrev()
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
case "jump-next":
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
@@ -1220,8 +1199,16 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
case "quit":
|
||||
app.quitChan <- struct{}{}
|
||||
case "jump-prev":
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
for range e.count {
|
||||
app.nav.cdJumpListPrev()
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
case "top":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1296,56 +1283,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case "tag-toggle":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
|
||||
tag := "*"
|
||||
if len(e.args) != 0 {
|
||||
tag = e.args[0]
|
||||
}
|
||||
|
||||
if err := app.nav.tagToggle(tag); err != nil {
|
||||
app.ui.echoerrf("tag-toggle: %s", err)
|
||||
} else if err := app.nav.writeTags(); err != nil {
|
||||
app.ui.echoerrf("tag-toggle: %s", err)
|
||||
}
|
||||
|
||||
if gSingleMode {
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("tag-toggle: %s", err)
|
||||
}
|
||||
} else {
|
||||
if err := remote("send sync"); err != nil {
|
||||
app.ui.echoerrf("tag-toggle: %s", err)
|
||||
}
|
||||
}
|
||||
case "tag":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
|
||||
tag := "*"
|
||||
if len(e.args) != 0 {
|
||||
tag = e.args[0]
|
||||
}
|
||||
|
||||
if err := app.nav.tag(tag); err != nil {
|
||||
app.ui.echoerrf("tag: %s", err)
|
||||
} else if err := app.nav.writeTags(); err != nil {
|
||||
app.ui.echoerrf("tag: %s", err)
|
||||
}
|
||||
|
||||
if gSingleMode {
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("tag: %s", err)
|
||||
}
|
||||
} else {
|
||||
if err := remote("send sync"); err != nil {
|
||||
app.ui.echoerrf("tag: %s", err)
|
||||
}
|
||||
}
|
||||
case "invert":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1353,24 +1290,30 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.invert()
|
||||
case "unselect":
|
||||
app.nav.unselect()
|
||||
case "calcdirsize":
|
||||
case "glob-select":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
err := app.nav.calcDirSize()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("calcdirsize: %s", err)
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("glob-select: requires a pattern to match")
|
||||
return
|
||||
}
|
||||
if err := app.nav.globSel(e.args[0], false); err != nil {
|
||||
app.ui.echoerrf("%s", err)
|
||||
return
|
||||
}
|
||||
case "glob-unselect":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("glob-unselect: requires a pattern to match")
|
||||
return
|
||||
}
|
||||
if err := app.nav.globSel(e.args[0], true); err != nil {
|
||||
app.ui.echoerrf("%s", err)
|
||||
return
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
case "clearmaps":
|
||||
// leave `:` and cmaps bound so the user can still exit using `:quit`
|
||||
clear(gOpts.nkeys)
|
||||
clear(gOpts.vkeys)
|
||||
gOpts.nkeys[":"] = &callExpr{"read", nil, 1}
|
||||
gOpts.vkeys[":"] = &callExpr{"read", nil, 1}
|
||||
case "copy":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1428,6 +1371,65 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "clear":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
if err := saveFiles(nil, false); err != nil {
|
||||
app.ui.echoerrf("clear: %s", err)
|
||||
return
|
||||
}
|
||||
if gSingleMode {
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("clear: %s", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err := remote("send sync"); err != nil {
|
||||
app.ui.echoerrf("clear: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "sync":
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("sync: %s", err)
|
||||
}
|
||||
case "draw":
|
||||
case "redraw":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
app.ui.renew()
|
||||
app.ui.screen.Sync()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
app.nav.height = app.ui.wins[0].h
|
||||
clear(app.nav.regCache)
|
||||
}
|
||||
if gOpts.sixel {
|
||||
clear(app.nav.regCache)
|
||||
app.ui.sxScreen.forceClear = true
|
||||
}
|
||||
for _, dir := range app.nav.dirs {
|
||||
dir.boundPos(app.nav.height)
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
onRedraw(app)
|
||||
case "load":
|
||||
if !app.nav.init || gOpts.watch {
|
||||
return
|
||||
}
|
||||
app.nav.renew()
|
||||
app.ui.loadFile(app, false)
|
||||
case "reload":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
if err := app.nav.reload(); err != nil {
|
||||
app.ui.echoerrf("reload: %s", err)
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "delete":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1463,61 +1465,42 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "clear":
|
||||
case "rename":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
if err := saveFiles(nil, false); err != nil {
|
||||
app.ui.echoerrf("clear: %s", err)
|
||||
return
|
||||
}
|
||||
if gSingleMode {
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("clear: %s", err)
|
||||
return
|
||||
if cmd, ok := gOpts.cmds["rename"]; ok {
|
||||
cmd.eval(app, e.args)
|
||||
if gSingleMode {
|
||||
app.nav.renew()
|
||||
app.ui.loadFile(app, true)
|
||||
} else {
|
||||
if err := remote("send load"); err != nil {
|
||||
app.ui.echoerrf("rename: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err := remote("send sync"); err != nil {
|
||||
app.ui.echoerrf("clear: %s", err)
|
||||
curr, err := app.nav.currFile()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("rename: %s:", err)
|
||||
return
|
||||
}
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "rename: "
|
||||
extension := getFileExtension(curr)
|
||||
if len(extension) == 0 {
|
||||
// no extension or .hidden or is directory
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name())...)
|
||||
} else {
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name()[:len(curr.Name())-len(extension)])...)
|
||||
app.ui.cmdAccRight = append(app.ui.cmdAccRight, []rune(extension)...)
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "draw":
|
||||
case "redraw":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
app.ui.renew()
|
||||
app.ui.screen.Sync()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
app.nav.height = app.ui.wins[0].h
|
||||
clear(app.nav.regCache)
|
||||
}
|
||||
if gOpts.sixel {
|
||||
clear(app.nav.regCache)
|
||||
app.ui.sxScreen.forceClear = true
|
||||
}
|
||||
for _, dir := range app.nav.dirs {
|
||||
dir.boundPos(app.nav.height)
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
onRedraw(app)
|
||||
case "load":
|
||||
if !app.nav.init || gOpts.watch {
|
||||
return
|
||||
}
|
||||
app.nav.renew()
|
||||
app.ui.loadFile(app, false)
|
||||
case "reload":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
if err := app.nav.reload(); err != nil {
|
||||
app.ui.echoerrf("reload: %s", err)
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "read":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
@@ -1720,45 +1703,55 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
normal(app)
|
||||
app.ui.menu = listMarks(app.nav.marks)
|
||||
app.ui.cmdPrefix = "mark-remove: "
|
||||
case "rename":
|
||||
case "tag":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
if cmd, ok := gOpts.cmds["rename"]; ok {
|
||||
cmd.eval(app, e.args)
|
||||
if gSingleMode {
|
||||
app.nav.renew()
|
||||
app.ui.loadFile(app, true)
|
||||
} else {
|
||||
if err := remote("send load"); err != nil {
|
||||
app.ui.echoerrf("rename: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
tag := "*"
|
||||
if len(e.args) != 0 {
|
||||
tag = e.args[0]
|
||||
}
|
||||
|
||||
if err := app.nav.tag(tag); err != nil {
|
||||
app.ui.echoerrf("tag: %s", err)
|
||||
} else if err := app.nav.writeTags(); err != nil {
|
||||
app.ui.echoerrf("tag: %s", err)
|
||||
}
|
||||
|
||||
if gSingleMode {
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("tag: %s", err)
|
||||
}
|
||||
} else {
|
||||
curr, err := app.nav.currFile()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("rename: %s:", err)
|
||||
return
|
||||
}
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "rename: "
|
||||
extension := getFileExtension(curr)
|
||||
if len(extension) == 0 {
|
||||
// no extension or .hidden or is directory
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name())...)
|
||||
} else {
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name()[:len(curr.Name())-len(extension)])...)
|
||||
app.ui.cmdAccRight = append(app.ui.cmdAccRight, []rune(extension)...)
|
||||
if err := remote("send sync"); err != nil {
|
||||
app.ui.echoerrf("tag: %s", err)
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "sync":
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("sync: %s", err)
|
||||
case "tag-toggle":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
|
||||
tag := "*"
|
||||
if len(e.args) != 0 {
|
||||
tag = e.args[0]
|
||||
}
|
||||
|
||||
if err := app.nav.tagToggle(tag); err != nil {
|
||||
app.ui.echoerrf("tag-toggle: %s", err)
|
||||
} else if err := app.nav.writeTags(); err != nil {
|
||||
app.ui.echoerrf("tag-toggle: %s", err)
|
||||
}
|
||||
|
||||
if gSingleMode {
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("tag-toggle: %s", err)
|
||||
}
|
||||
} else {
|
||||
if err := remote("send sync"); err != nil {
|
||||
app.ui.echoerrf("tag-toggle: %s", err)
|
||||
}
|
||||
}
|
||||
case "echo":
|
||||
app.ui.echo(strings.Join(e.args, " "))
|
||||
@@ -1842,30 +1835,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
}
|
||||
case "glob-select":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("glob-select: requires a pattern to match")
|
||||
return
|
||||
}
|
||||
if err := app.nav.globSel(e.args[0], false); err != nil {
|
||||
app.ui.echoerrf("%s", err)
|
||||
return
|
||||
}
|
||||
case "glob-unselect":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("glob-unselect: requires a pattern to match")
|
||||
return
|
||||
}
|
||||
if err := app.nav.globSel(e.args[0], true); err != nil {
|
||||
app.ui.echoerrf("%s", err)
|
||||
return
|
||||
}
|
||||
case "source":
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("source: requires an argument")
|
||||
@@ -1882,12 +1851,134 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
for _, val := range splitKeys(e.args[0]) {
|
||||
app.ui.keyChan <- val
|
||||
}
|
||||
case "on-focus-gained":
|
||||
onFocusGained(app)
|
||||
case "on-focus-lost":
|
||||
onFocusLost(app)
|
||||
case "on-init":
|
||||
onInit(app)
|
||||
case "addcustominfo":
|
||||
var k, v string
|
||||
switch len(e.args) {
|
||||
case 1:
|
||||
k, v = e.args[0], ""
|
||||
case 2:
|
||||
k, v = e.args[0], e.args[1]
|
||||
default:
|
||||
app.ui.echoerr("addcustominfo: requires either 1 or 2 arguments")
|
||||
return
|
||||
}
|
||||
|
||||
path, err := filepath.Abs(replaceTilde(k))
|
||||
if err != nil {
|
||||
app.ui.echoerrf("addcustominfo: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
dir := filepath.Dir(path)
|
||||
d, ok := app.nav.dirCache[dir]
|
||||
if !ok {
|
||||
app.ui.echoerrf("addcustominfo: dir not loaded: %s", dir)
|
||||
return
|
||||
}
|
||||
|
||||
var f *file
|
||||
for _, file := range d.allFiles {
|
||||
if file.path == path {
|
||||
f = file
|
||||
break
|
||||
}
|
||||
}
|
||||
if f == nil {
|
||||
app.ui.echoerrf("addcustominfo: file not found: %s", path)
|
||||
return
|
||||
}
|
||||
|
||||
if len(strings.Trim(v, " ")) == 0 {
|
||||
v = ""
|
||||
}
|
||||
if f.customInfo != v {
|
||||
f.customInfo = v
|
||||
// only sort when order changes
|
||||
if getSortBy(dir) == customSort {
|
||||
d.sort()
|
||||
}
|
||||
}
|
||||
case "calcdirsize":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
err := app.nav.calcDirSize()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("calcdirsize: %s", err)
|
||||
return
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
case "clearmaps":
|
||||
// leave `:` and cmaps bound so the user can still exit using `:quit`
|
||||
clear(gOpts.nkeys)
|
||||
clear(gOpts.vkeys)
|
||||
gOpts.nkeys[":"] = &callExpr{"read", nil, 1}
|
||||
gOpts.vkeys[":"] = &callExpr{"read", nil, 1}
|
||||
case "tty-write":
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("tty-write: requires an argument")
|
||||
return
|
||||
}
|
||||
|
||||
tty, ok := app.ui.screen.Tty()
|
||||
if !ok {
|
||||
log.Printf("tty-write: failed to get tty")
|
||||
return
|
||||
}
|
||||
|
||||
tty.Write([]byte(e.args[0]))
|
||||
case "visual":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
visual(app)
|
||||
case "visual-accept":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
for _, path := range dir.visualSelections() {
|
||||
if _, ok := app.nav.selections[path]; !ok {
|
||||
app.nav.selections[path] = app.nav.selectionInd
|
||||
app.nav.selectionInd++
|
||||
}
|
||||
}
|
||||
// resetting Visual mode here instead of inside `normal()`
|
||||
// allows us to use Visual mode inside search, find etc.
|
||||
dir.visualAnchor = -1
|
||||
normal(app)
|
||||
case "visual-unselect":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
for _, path := range dir.visualSelections() {
|
||||
delete(app.nav.selections, path)
|
||||
}
|
||||
if len(app.nav.selections) == 0 {
|
||||
app.nav.selectionInd = 0
|
||||
}
|
||||
dir.visualAnchor = -1
|
||||
normal(app)
|
||||
case "visual-discard":
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
dir.visualAnchor = -1
|
||||
normal(app)
|
||||
case "visual-change":
|
||||
if !app.nav.isVisualMode() {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
beg := max(dir.ind-dir.pos, 0)
|
||||
dir.ind, dir.visualAnchor = dir.visualAnchor, dir.ind
|
||||
dir.pos = dir.ind - beg
|
||||
dir.visualWrap = -dir.visualWrap
|
||||
dir.boundPos(app.nav.height)
|
||||
case "cmd-insert":
|
||||
if len(e.args) == 0 {
|
||||
return
|
||||
@@ -2069,6 +2160,16 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
default:
|
||||
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
||||
}
|
||||
case "cmd-interrupt":
|
||||
if app.cmd != nil {
|
||||
err := shellKill(app.cmd)
|
||||
if err != nil {
|
||||
app.ui.echoerrf("kill: %s", err)
|
||||
} else {
|
||||
app.ui.echoerr("process interrupt")
|
||||
}
|
||||
}
|
||||
normal(app)
|
||||
case "cmd-history-next":
|
||||
if !slices.Contains([]string{":", "$", "!", "%", "&"}, app.ui.cmdPrefix) {
|
||||
return
|
||||
@@ -2100,6 +2201,24 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.cmdHistoryInd = historyInd
|
||||
app.ui.cmdPrefix = cmd.prefix
|
||||
app.ui.cmdAccLeft = []rune(cmd.value)
|
||||
case "cmd-left":
|
||||
if len(app.ui.cmdAccLeft) == 0 {
|
||||
return
|
||||
}
|
||||
app.ui.cmdAccRight = append([]rune{app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1]}, app.ui.cmdAccRight...)
|
||||
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:len(app.ui.cmdAccLeft)-1]
|
||||
case "cmd-right":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdAccRight[0])
|
||||
app.ui.cmdAccRight = app.ui.cmdAccRight[1:]
|
||||
case "cmd-home":
|
||||
app.ui.cmdAccRight = append(app.ui.cmdAccLeft, app.ui.cmdAccRight...)
|
||||
app.ui.cmdAccLeft = nil
|
||||
case "cmd-end":
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdAccRight...)
|
||||
app.ui.cmdAccRight = nil
|
||||
case "cmd-delete":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
@@ -2122,24 +2241,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:len(app.ui.cmdAccLeft)-1]
|
||||
update(app)
|
||||
case "cmd-left":
|
||||
if len(app.ui.cmdAccLeft) == 0 {
|
||||
return
|
||||
}
|
||||
app.ui.cmdAccRight = append([]rune{app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1]}, app.ui.cmdAccRight...)
|
||||
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:len(app.ui.cmdAccLeft)-1]
|
||||
case "cmd-right":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdAccRight[0])
|
||||
app.ui.cmdAccRight = app.ui.cmdAccRight[1:]
|
||||
case "cmd-home":
|
||||
app.ui.cmdAccRight = append(app.ui.cmdAccLeft, app.ui.cmdAccRight...)
|
||||
app.ui.cmdAccLeft = nil
|
||||
case "cmd-end":
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdAccRight...)
|
||||
app.ui.cmdAccRight = nil
|
||||
case "cmd-delete-home":
|
||||
if len(app.ui.cmdAccLeft) == 0 {
|
||||
return
|
||||
@@ -2168,106 +2269,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1], app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-2] = app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-2], app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1]
|
||||
update(app)
|
||||
case "cmd-interrupt":
|
||||
if app.cmd != nil {
|
||||
err := shellKill(app.cmd)
|
||||
if err != nil {
|
||||
app.ui.echoerrf("kill: %s", err)
|
||||
} else {
|
||||
app.ui.echoerr("process interrupt")
|
||||
}
|
||||
}
|
||||
normal(app)
|
||||
case "cmd-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
ind := loc[3]
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(string(app.ui.cmdAccRight)[:ind])...)
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
case "cmd-word-back":
|
||||
if len(app.ui.cmdAccLeft) == 0 {
|
||||
return
|
||||
}
|
||||
locs := reWordBeg.FindAllStringSubmatchIndex(string(app.ui.cmdAccLeft), -1)
|
||||
if locs == nil {
|
||||
return
|
||||
}
|
||||
ind := locs[len(locs)-1][3]
|
||||
old := app.ui.cmdAccRight
|
||||
app.ui.cmdAccRight = append([]rune(string(app.ui.cmdAccLeft)[ind:]), old...)
|
||||
app.ui.cmdAccLeft = []rune(string(app.ui.cmdAccLeft)[:ind])
|
||||
case "cmd-capitalize-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
ind := 0
|
||||
for ; ind < len(app.ui.cmdAccRight) && unicode.IsSpace(app.ui.cmdAccRight[ind]); ind++ {
|
||||
}
|
||||
if ind >= len(app.ui.cmdAccRight) {
|
||||
return
|
||||
}
|
||||
app.ui.cmdAccRight[ind] = unicode.ToUpper(app.ui.cmdAccRight[ind])
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
ind = loc[3]
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(string(app.ui.cmdAccRight)[:ind])...)
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
update(app)
|
||||
case "cmd-delete-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
ind := loc[3]
|
||||
app.ui.cmdYankBuf = []rune(string(app.ui.cmdAccRight)[:ind])
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
update(app)
|
||||
case "cmd-delete-word-back":
|
||||
if len(app.ui.cmdAccLeft) == 0 {
|
||||
return
|
||||
}
|
||||
locs := reWordBeg.FindAllStringSubmatchIndex(string(app.ui.cmdAccLeft), -1)
|
||||
if locs == nil {
|
||||
return
|
||||
}
|
||||
ind := locs[len(locs)-1][3]
|
||||
app.ui.cmdYankBuf = []rune(string(app.ui.cmdAccLeft)[ind:])
|
||||
app.ui.cmdAccLeft = []rune(string(app.ui.cmdAccLeft)[:ind])
|
||||
update(app)
|
||||
case "cmd-uppercase-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
ind := loc[3]
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(strings.ToUpper(string(app.ui.cmdAccRight)[:ind]))...)
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
update(app)
|
||||
case "cmd-lowercase-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
ind := loc[3]
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(strings.ToLower(string(app.ui.cmdAccRight)[:ind]))...)
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
update(app)
|
||||
case "cmd-transpose-word":
|
||||
if len(app.ui.cmdAccLeft) == 0 {
|
||||
return
|
||||
@@ -2300,103 +2301,102 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
[]rune(string(app.ui.cmdAccLeft)[end2:]),
|
||||
)
|
||||
update(app)
|
||||
case "addcustominfo":
|
||||
var k, v string
|
||||
switch len(e.args) {
|
||||
case 1:
|
||||
k, v = e.args[0], ""
|
||||
case 2:
|
||||
k, v = e.args[0], e.args[1]
|
||||
default:
|
||||
app.ui.echoerr("addcustominfo: requires either 1 or 2 arguments")
|
||||
case "cmd-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
path, err := filepath.Abs(replaceTilde(k))
|
||||
if err != nil {
|
||||
app.ui.echoerrf("addcustominfo: %s", err)
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
|
||||
dir := filepath.Dir(path)
|
||||
d, ok := app.nav.dirCache[dir]
|
||||
if !ok {
|
||||
app.ui.echoerrf("addcustominfo: dir not loaded: %s", dir)
|
||||
ind := loc[3]
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(string(app.ui.cmdAccRight)[:ind])...)
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
case "cmd-word-back":
|
||||
if len(app.ui.cmdAccLeft) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
var f *file
|
||||
for _, file := range d.allFiles {
|
||||
if file.path == path {
|
||||
f = file
|
||||
break
|
||||
}
|
||||
}
|
||||
if f == nil {
|
||||
app.ui.echoerrf("addcustominfo: file not found: %s", path)
|
||||
locs := reWordBeg.FindAllStringSubmatchIndex(string(app.ui.cmdAccLeft), -1)
|
||||
if locs == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if len(strings.Trim(v, " ")) == 0 {
|
||||
v = ""
|
||||
}
|
||||
if f.customInfo != v {
|
||||
f.customInfo = v
|
||||
// only sort when order changes
|
||||
if getSortBy(dir) == customSort {
|
||||
d.sort()
|
||||
}
|
||||
}
|
||||
case "visual":
|
||||
if !app.nav.init {
|
||||
ind := locs[len(locs)-1][3]
|
||||
old := app.ui.cmdAccRight
|
||||
app.ui.cmdAccRight = append([]rune(string(app.ui.cmdAccLeft)[ind:]), old...)
|
||||
app.ui.cmdAccLeft = []rune(string(app.ui.cmdAccLeft)[:ind])
|
||||
case "cmd-delete-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
visual(app)
|
||||
case "visual-accept":
|
||||
if !app.nav.init {
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
for _, path := range dir.visualSelections() {
|
||||
if _, ok := app.nav.selections[path]; !ok {
|
||||
app.nav.selections[path] = app.nav.selectionInd
|
||||
app.nav.selectionInd++
|
||||
}
|
||||
}
|
||||
// resetting Visual mode here instead of inside `normal()`
|
||||
// allows us to use Visual mode inside search, find etc.
|
||||
dir.visualAnchor = -1
|
||||
normal(app)
|
||||
case "visual-unselect":
|
||||
if !app.nav.init {
|
||||
ind := loc[3]
|
||||
app.ui.cmdYankBuf = []rune(string(app.ui.cmdAccRight)[:ind])
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
update(app)
|
||||
case "cmd-delete-word-back":
|
||||
if len(app.ui.cmdAccLeft) == 0 {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
for _, path := range dir.visualSelections() {
|
||||
delete(app.nav.selections, path)
|
||||
}
|
||||
if len(app.nav.selections) == 0 {
|
||||
app.nav.selectionInd = 0
|
||||
}
|
||||
dir.visualAnchor = -1
|
||||
normal(app)
|
||||
case "visual-discard":
|
||||
if !app.nav.init {
|
||||
locs := reWordBeg.FindAllStringSubmatchIndex(string(app.ui.cmdAccLeft), -1)
|
||||
if locs == nil {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
dir.visualAnchor = -1
|
||||
normal(app)
|
||||
case "visual-change":
|
||||
if !app.nav.isVisualMode() {
|
||||
ind := locs[len(locs)-1][3]
|
||||
app.ui.cmdYankBuf = []rune(string(app.ui.cmdAccLeft)[ind:])
|
||||
app.ui.cmdAccLeft = []rune(string(app.ui.cmdAccLeft)[:ind])
|
||||
update(app)
|
||||
case "cmd-capitalize-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
beg := max(dir.ind-dir.pos, 0)
|
||||
dir.ind, dir.visualAnchor = dir.visualAnchor, dir.ind
|
||||
dir.pos = dir.ind - beg
|
||||
dir.visualWrap = -dir.visualWrap
|
||||
dir.boundPos(app.nav.height)
|
||||
ind := 0
|
||||
for ; ind < len(app.ui.cmdAccRight) && unicode.IsSpace(app.ui.cmdAccRight[ind]); ind++ {
|
||||
}
|
||||
if ind >= len(app.ui.cmdAccRight) {
|
||||
return
|
||||
}
|
||||
app.ui.cmdAccRight[ind] = unicode.ToUpper(app.ui.cmdAccRight[ind])
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
ind = loc[3]
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(string(app.ui.cmdAccRight)[:ind])...)
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
update(app)
|
||||
case "cmd-uppercase-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
ind := loc[3]
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(strings.ToUpper(string(app.ui.cmdAccRight)[:ind]))...)
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
update(app)
|
||||
case "cmd-lowercase-word":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
}
|
||||
loc := reWordEnd.FindStringSubmatchIndex(string(app.ui.cmdAccRight))
|
||||
if loc == nil {
|
||||
return
|
||||
}
|
||||
ind := loc[3]
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(strings.ToLower(string(app.ui.cmdAccRight)[:ind]))...)
|
||||
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
|
||||
update(app)
|
||||
case "on-focus-gained":
|
||||
onFocusGained(app)
|
||||
case "on-focus-lost":
|
||||
onFocusLost(app)
|
||||
case "on-init":
|
||||
onInit(app)
|
||||
default:
|
||||
cmd, ok := gOpts.cmds[e.name]
|
||||
if !ok {
|
||||
|
||||
@@ -56,13 +56,10 @@ high (default \(aqH\(aq)
|
||||
middle (default \(aqM\(aq)
|
||||
low (default \(aqL\(aq)
|
||||
toggle
|
||||
visual (default \(aqV\(aq)
|
||||
invert (default \(aqv\(aq)
|
||||
unselect (default \(aqu\(aq)
|
||||
glob\-select
|
||||
glob\-unselect
|
||||
calcdirsize
|
||||
clearmaps
|
||||
copy (default \(aqy\(aq)
|
||||
cut (default \(aqd\(aq)
|
||||
paste (default \(aqp\(aq)
|
||||
@@ -72,15 +69,8 @@ draw
|
||||
redraw (default \(aq<c\-l>\(aq)
|
||||
load
|
||||
reload (default \(aq<c\-r>\(aq)
|
||||
echo
|
||||
echomsg
|
||||
echoerr
|
||||
cd
|
||||
select
|
||||
delete (modal)
|
||||
rename (modal) (default \(aqr\(aq)
|
||||
source
|
||||
push
|
||||
read (modal) (default \(aq:\(aq)
|
||||
shell (modal) (default \(aq$\(aq)
|
||||
shell\-pipe (modal) (default \(aq%\(aq)
|
||||
@@ -101,8 +91,18 @@ mark\-load (modal) (default \(dq\(aq\(dq)
|
||||
mark\-remove (modal) (default \(aq\(dq\(aq)
|
||||
tag
|
||||
tag\-toggle (default \(aqt\(aq)
|
||||
echo
|
||||
echomsg
|
||||
echoerr
|
||||
cd
|
||||
select
|
||||
source
|
||||
push
|
||||
addcustominfo
|
||||
calcdirsize
|
||||
clearmaps
|
||||
tty\-write
|
||||
visual (default \(aqV\(aq)
|
||||
.EE
|
||||
.PP
|
||||
The following Visual mode commands are provided by lf:
|
||||
@@ -117,6 +117,7 @@ visual\-change (default \(aqo\(aq)
|
||||
The following Command\-line mode commands are provided by lf:
|
||||
.IP
|
||||
.EX
|
||||
cmd\-insert
|
||||
cmd\-escape (default \(aq<esc>\(aq)
|
||||
cmd\-complete (default \(aq<tab>\(aq)
|
||||
cmd\-menu\-complete
|
||||
@@ -436,21 +437,6 @@ A count can be specified to move to a specific line, for example, use
|
||||
Move the current file selection to the high/middle/low of the screen.
|
||||
.SS toggle
|
||||
Toggle the selection of the current file or files given as arguments.
|
||||
.SS visual (default \f[CR]V\f[R])
|
||||
Switch to Visual mode.
|
||||
If already in Visual mode, discard the visual selection and stay in
|
||||
Visual mode.
|
||||
.SS visual\-accept (default \f[CR]V\f[R])
|
||||
Add the visual selection to the selection list, quit Visual mode and
|
||||
return to Normal mode.
|
||||
.SS visual\-unselect
|
||||
Remove the visual selection from the selection list, quit Visual mode
|
||||
and return to Normal mode.
|
||||
.SS visual\-discard (default \f[CR]<esc>\f[R])
|
||||
Discard the visual selection, quit Visual mode and return to Normal
|
||||
mode.
|
||||
.SS visual\-change (default \f[CR]o\f[R])
|
||||
Go to the other end of the current Visual mode selection.
|
||||
.SS invert (default \f[CR]v\f[R])
|
||||
Reverse the selection of all files in the current directory (i.e.
|
||||
\f[CR]toggle\f[R] all files).
|
||||
@@ -463,20 +449,6 @@ remove selections in other directories.
|
||||
Remove the selection of all files in all directories.
|
||||
.SS glob\-select, glob\-unselect
|
||||
Select/unselect files that match the given glob.
|
||||
.SS calcdirsize
|
||||
Calculate the total size for each of the selected directories.
|
||||
Option \f[CR]info\f[R] should include \f[CR]size\f[R] and option
|
||||
\f[CR]dircounts\f[R] should be disabled to show this size.
|
||||
If the total size of a directory is not calculated, it will be shown as
|
||||
\f[CR]\-\f[R].
|
||||
.SS clearmaps
|
||||
Remove all keybindings associated with the \f[CR]map\f[R],
|
||||
\f[CR]nmap\f[R] and \f[CR]vmap\f[R] command.
|
||||
This command can be used in the config file to remove the default
|
||||
keybindings.
|
||||
For safety purposes, \f[CR]:\f[R] is left mapped to the \f[CR]read\f[R]
|
||||
command, and \f[CR]cmap\f[R] keybindings are retained so that it is
|
||||
still possible to exit \f[CR]lf\f[R] using \f[CR]:quit\f[R].
|
||||
.SS copy (default \f[CR]y\f[R])
|
||||
If there are no selections, save the path of the current file to the
|
||||
copy buffer, otherwise, copy the paths of selected files.
|
||||
@@ -502,18 +474,6 @@ Load modified files and directories.
|
||||
This command is automatically called when required.
|
||||
.SS reload (default \f[CR]<c\-r>\f[R])
|
||||
Flush the cache and reload all files and directories.
|
||||
.SS echo
|
||||
Print the given arguments to the message line at the bottom.
|
||||
.SS echomsg
|
||||
Print the given arguments to the message line at the bottom and also to
|
||||
the log file.
|
||||
.SS echoerr
|
||||
Print given arguments to the message line at the bottom as
|
||||
\f[CR]errorfmt\f[R] and also to the log file.
|
||||
.SS cd
|
||||
Change the working directory to the given argument.
|
||||
.SS select
|
||||
Change the current file selection to the given argument.
|
||||
.SS delete (modal)
|
||||
Remove the current file or selected file(s).
|
||||
A custom \f[CR]delete\f[R] command can be defined to override this
|
||||
@@ -522,10 +482,6 @@ default.
|
||||
Rename the current file using the built\-in method.
|
||||
A custom \f[CR]rename\f[R] command can be defined to override this
|
||||
default.
|
||||
.SS source
|
||||
Read the configuration file given in the argument.
|
||||
.SS push
|
||||
Simulate key pushes given in the argument.
|
||||
.SS read (modal) (default \f[CR]:\f[R])
|
||||
Read a command to evaluate.
|
||||
.SS shell (modal) (default \f[CR]$\f[R])
|
||||
@@ -567,12 +523,42 @@ with \f[CR]tag\-toggle\f[R] (i.e.
|
||||
.SS tag\-toggle (default \f[CR]t\f[R])
|
||||
Tag a file with \f[CR]*\f[R] or a single width character given in the
|
||||
argument if the file is untagged, otherwise remove the tag.
|
||||
.SS echo
|
||||
Print the given arguments to the message line at the bottom.
|
||||
.SS echomsg
|
||||
Print the given arguments to the message line at the bottom and also to
|
||||
the log file.
|
||||
.SS echoerr
|
||||
Print given arguments to the message line at the bottom as
|
||||
\f[CR]errorfmt\f[R] and also to the log file.
|
||||
.SS cd
|
||||
Change the working directory to the given argument.
|
||||
.SS select
|
||||
Change the current file selection to the given argument.
|
||||
.SS source
|
||||
Read the configuration file given in the argument.
|
||||
.SS push
|
||||
Simulate key pushes given in the argument.
|
||||
.SS addcustominfo
|
||||
Update the \f[CR]custom\f[R] info field of the given file with the given
|
||||
string.
|
||||
The info string may contain ANSI escape codes to further customize its
|
||||
appearance.
|
||||
If no info is provided, clear the file\(aqs info instead.
|
||||
.SS calcdirsize
|
||||
Calculate the total size for each of the selected directories.
|
||||
Option \f[CR]info\f[R] should include \f[CR]size\f[R] and option
|
||||
\f[CR]dircounts\f[R] should be disabled to show this size.
|
||||
If the total size of a directory is not calculated, it will be shown as
|
||||
\f[CR]\-\f[R].
|
||||
.SS clearmaps
|
||||
Remove all keybindings associated with the \f[CR]map\f[R],
|
||||
\f[CR]nmap\f[R] and \f[CR]vmap\f[R] command.
|
||||
This command can be used in the config file to remove the default
|
||||
keybindings.
|
||||
For safety purposes, \f[CR]:\f[R] is left mapped to the \f[CR]read\f[R]
|
||||
command, and \f[CR]cmap\f[R] keybindings are retained so that it is
|
||||
still possible to exit \f[CR]lf\f[R] using \f[CR]:quit\f[R].
|
||||
.SS tty\-write
|
||||
Write the given string to the tty.
|
||||
This is useful for sending escape sequences to the terminal to control
|
||||
@@ -581,7 +567,23 @@ OSC 0 to set the window title).
|
||||
Using \f[CR]tty\-write\f[R] is preferred over directly writing to
|
||||
\f[CR]/dev/tty\f[R] because the latter is not synchronized and can
|
||||
interfere with drawing the UI.
|
||||
.SH COMMAND LINE COMMANDS
|
||||
.SS visual (default \f[CR]V\f[R])
|
||||
Switch to Visual mode.
|
||||
If already in Visual mode, discard the visual selection and stay in
|
||||
Visual mode.
|
||||
.SH VISUAL MODE COMMANDS
|
||||
.SS visual\-accept (default \f[CR]V\f[R])
|
||||
Add the visual selection to the selection list, quit Visual mode and
|
||||
return to Normal mode.
|
||||
.SS visual\-unselect
|
||||
Remove the visual selection from the selection list, quit Visual mode
|
||||
and return to Normal mode.
|
||||
.SS visual\-discard (default \f[CR]<esc>\f[R])
|
||||
Discard the visual selection, quit Visual mode and return to Normal
|
||||
mode.
|
||||
.SS visual\-change (default \f[CR]o\f[R])
|
||||
Go to the other end of the current Visual mode selection.
|
||||
.SH COMMAND\-LINE MODE COMMANDS
|
||||
The prompt character specifies which of the several Command\-line modes
|
||||
you are in.
|
||||
For example, the \f[CR]read\f[R] command takes you to the \f[CR]:\f[R]
|
||||
@@ -597,6 +599,9 @@ The command line commands should be mostly compatible with readline
|
||||
keybindings.
|
||||
A character refers to a Unicode code point, a word consists of letters
|
||||
and digits, and a unix word consists of any non\-blank characters.
|
||||
.SS cmd\-insert
|
||||
Insert the character given in the argument.
|
||||
This command is automatically called when required.
|
||||
.SS cmd\-escape (default \f[CR]<esc>\f[R])
|
||||
Quit Command\-line mode and return to Normal mode.
|
||||
.SS cmd\-complete (default \f[CR]<tab>\f[R])
|
||||
|
||||
Reference in new issue
Block a user