Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49f2a7c6c4 | ||
|
|
d81c84bbb9 | ||
|
|
c5075b6455 | ||
|
|
d2e125d264 | ||
|
|
d2bcae2943 | ||
|
|
f050abc57c | ||
|
|
9c0dc813a3 | ||
|
|
995413426c | ||
|
|
b73daad7cc | ||
|
|
f94c62661a | ||
|
|
168a64a288 | ||
|
|
8dad85197f | ||
|
|
d079cc8719 | ||
|
|
f26b30be18 | ||
|
|
ad5af1b2c7 | ||
|
|
7297e4f522 | ||
|
|
f2d2bb0f2c | ||
|
|
75334c25a5 | ||
|
|
ae583e96d3 | ||
|
|
4fe8f5a858 | ||
|
|
8150586bc2 | ||
|
|
8f97bf806a | ||
|
|
04afd78e65 | ||
|
|
4384e520b5 | ||
|
|
e60c055be3 | ||
|
|
06955cbacc | ||
|
|
13da770af6 | ||
|
|
aba73884e3 | ||
|
|
5a4b0881d7 |
No files matched your search
@@ -19,7 +19,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.23"
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.23"
|
||||
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.23"
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.23"
|
||||
|
||||
|
||||
+27
-1
@@ -8,6 +8,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
- `Added`
|
||||
- `Fixed`
|
||||
|
||||
## [r38](https://github.com/gokcehan/lf/releases/tag/r38)
|
||||
|
||||
### Changed
|
||||
|
||||
- The deprecated `globfilter` and `globsearch` options are now removed (#2108).
|
||||
- Sixel image support is now enabled by default, and the `sixel` option has been removed as it is no longer required (#2109).
|
||||
- The `dircache` option has now been removed (#2110). This was previously used as a workaround to disable the directory cache since at the time changes to files were not detected reliably, but this is no longer the case.
|
||||
- The experimental `locale` option has been removed in favor of the recommendation to use `addcustominfo`/`set sortby custom` for custom sorting (#2111).
|
||||
- The existing `doc` command has been renamed to `help` so that it is more natural for users (#2125).
|
||||
- Text previews are no longer displayed with a padding of two spaces by default (#2131). Instead, a custom padding can be added in the `previewer` script, for example by piping to `sed 's/^/ /'`.
|
||||
|
||||
### Added
|
||||
|
||||
- Sixel image previews can now display multiple images as well as text (#2109).
|
||||
- A new option `sizeunits` is added to allow displaying file sizes in either binary or decimal units (#2118).
|
||||
- `XDG_CONFIG_HOME` and `XDG_DATA_HOME` are now taken into account when looking up config/data files on Windows (#2119).
|
||||
- Three new options `menufmt`, `menuheaderfmt`, and `menuselectfmt` are added to customize the appearance of the menu (#2123).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Error messages are now cleared after running interactive commands such as `invert`/`unselect`/`tag-toggle` (#2117).
|
||||
- The menu is now drawn over sixel images instead of being hidden behind it if they overlap (#2122).
|
||||
- A bug which prevents the user from quitting when copying files with a size of 0 has been fixed (#2130).
|
||||
- `lf -remote` should no longer busy wait and cause high CPU usage if its output is not being read (#2138).
|
||||
- The parameter types for command line options shown by `lf -help` now match the synopsis in the documentation (#2153).
|
||||
|
||||
## [r37](https://github.com/gokcehan/lf/releases/tag/r37)
|
||||
|
||||
### Changed
|
||||
@@ -28,7 +54,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
- The selection in Visual mode now follows wrapping when `wrapscan`/`wrapscroll` is enabled (#2056).
|
||||
- Input pasted from the terminal is now ignored while in Normal mode (#2059). This prevents pasted content from being treated as keybindings, which can result in dangerous unintended behavior.
|
||||
- The Command-line mode completion now supports keywords for the `selmode` and `sortby` options (#2061), as well as the `info` and `preserve` options (#2071).
|
||||
- Command line flags are now exported as environment variables in the form `lf_flag_{flag}` (#2079).
|
||||
- Command line options are now exported as environment variables in the form `lf_flag_{flag}` (#2079).
|
||||
- Support is added for terminal escape sequences that disable text styles (#2101).
|
||||
|
||||
### Fixed
|
||||
|
||||
+6
-3
@@ -28,7 +28,7 @@ Adding a new option usually requires the following steps:
|
||||
- Add option evaluation logic to `setExpr.eval` in `eval.go`
|
||||
- Implement the option somewhere in the code
|
||||
- Add option name and its default value to `Quick Reference` and `Options` sections in `doc.md`
|
||||
- Run `gen/doc.sh` to update the documentation (requires podman/docker)
|
||||
- Run `gen/doc.sh` to update the documentation (optional as it requires `docker`/`podman`, but appreciated)
|
||||
- Commit your changes and send a pull request
|
||||
|
||||
## Adding a new builtin command
|
||||
@@ -40,11 +40,14 @@ Adding a new command usually requires the following steps:
|
||||
- Implement the command somewhere in the code
|
||||
- Add command name to `gCmdWords` in `complete.go` for tab completion
|
||||
- Add command name to `Quick Reference` and `Commands` sections in `doc.md`
|
||||
- Optionally, run `gen/doc.sh` to update the documentation (requires podman/docker)
|
||||
- Run `gen/doc.sh` to update the documentation (optional as it requires `docker`/`podman`, but appreciated)
|
||||
- Commit your changes and send a pull request
|
||||
|
||||
## Platform specific code
|
||||
|
||||
There are two files named `os.go` and `os_windows.go` for unix and windows specific code respectively.
|
||||
There are two files named `os.go` and `os_windows.go` for Unix and Windows specific code respectively.
|
||||
If you add something to either of these files but not the other, you probably break the build for the other platform.
|
||||
If your addition works the same in both platforms, your addition probably belongs to `main.go` instead.
|
||||
|
||||
There are also different variants of the `df` functionality provided by `df_openbsd.go`, `df_statfs.go`, `df_statvfs.go` and `df_windows.go`.
|
||||
Where applicable, ensure that any changes you make are reflected across all of these files for consistency.
|
||||
@@ -340,8 +340,8 @@ func (app *app) loop() {
|
||||
log.Print("bye!")
|
||||
|
||||
return
|
||||
case <-app.nav.copyJobsChan:
|
||||
app.nav.copyJobs += 1
|
||||
case n := <-app.nav.copyJobsChan:
|
||||
app.nav.copyJobs += n
|
||||
app.ui.draw(app.nav)
|
||||
case n := <-app.nav.copyBytesChan:
|
||||
app.nav.copyBytes += n
|
||||
@@ -391,22 +391,17 @@ func (app *app) loop() {
|
||||
}
|
||||
app.ui.draw(app.nav)
|
||||
case d := <-app.nav.dirChan:
|
||||
if gOpts.dircache {
|
||||
prev, ok := app.nav.dirCache[d.path]
|
||||
if ok {
|
||||
d.ind = prev.ind
|
||||
d.pos = prev.pos
|
||||
d.visualAnchor = min(prev.visualAnchor, len(d.files)-1)
|
||||
d.visualWrap = prev.visualWrap
|
||||
d.filter = prev.filter
|
||||
d.sort()
|
||||
d.sel(prev.name(), app.nav.height)
|
||||
}
|
||||
|
||||
app.nav.dirCache[d.path] = d
|
||||
} else {
|
||||
prev, ok := app.nav.dirCache[d.path]
|
||||
if ok {
|
||||
d.ind = prev.ind
|
||||
d.pos = prev.pos
|
||||
d.visualAnchor = min(prev.visualAnchor, len(d.files)-1)
|
||||
d.visualWrap = prev.visualWrap
|
||||
d.filter = prev.filter
|
||||
d.sort()
|
||||
d.sel(prev.name(), app.nav.height)
|
||||
}
|
||||
app.nav.dirCache[d.path] = d
|
||||
|
||||
var oldCurrPath string
|
||||
if curr, err := app.nav.currFile(); err == nil {
|
||||
@@ -425,9 +420,6 @@ func (app *app) loop() {
|
||||
if err == nil {
|
||||
if curr.path != oldCurrPath {
|
||||
app.ui.loadFile(app, true)
|
||||
if app.ui.msgIsStat {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
if d.path == curr.path {
|
||||
app.ui.dirPrev = d
|
||||
@@ -450,9 +442,7 @@ func (app *app) loop() {
|
||||
if err == nil {
|
||||
if r.path == curr.path {
|
||||
app.ui.regPrev = r
|
||||
if gOpts.sixel {
|
||||
app.ui.sxScreen.forceClear = true
|
||||
}
|
||||
app.ui.sxScreen.forceClear = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,10 +466,6 @@ func (app *app) loop() {
|
||||
}
|
||||
|
||||
app.ui.loadFile(app, false)
|
||||
if app.ui.msgIsStat {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
|
||||
onLoad(app, []string{f.path})
|
||||
app.ui.draw(app.nav)
|
||||
case path := <-app.nav.delChan:
|
||||
@@ -688,7 +674,7 @@ func (app *app) doComplete() (matches []compMatch) {
|
||||
}
|
||||
|
||||
app.ui.cmdAccLeft = []rune(result)
|
||||
app.ui.menu = listMatches(app.ui.screen, matches, -1)
|
||||
app.ui.menu, app.ui.menuSelect = listMatches(app.ui.screen, matches, -1)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -711,7 +697,7 @@ func (app *app) menuComplete(direction int) {
|
||||
app.menuCompTmp[len(app.menuCompTmp)-1] = app.menuComps[app.menuCompInd].result
|
||||
app.ui.cmdAccLeft = []rune(strings.Join(app.menuCompTmp, " "))
|
||||
}
|
||||
app.ui.menu = listMatches(app.ui.screen, app.menuComps, app.menuCompInd)
|
||||
app.ui.menu, app.ui.menuSelect = listMatches(app.ui.screen, app.menuComps, app.menuCompInd)
|
||||
}
|
||||
|
||||
func (app *app) watchDir(dir *dir) {
|
||||
|
||||
@@ -182,9 +182,17 @@ func remote(cmd string) error {
|
||||
v.CloseWrite()
|
||||
}
|
||||
|
||||
io.Copy(os.Stdout, c)
|
||||
|
||||
// The most straightforward way to write the reponse to stdout would be
|
||||
// to do "io.Copy(os.Stdout, c)". However, on Linux, if stdout is connected to
|
||||
// something like a pager that isn't immediately reading everything,
|
||||
// this runs into Go bug https://github.com/golang/go/issues/75304 and
|
||||
// busy-loops, eating a whole CPU.
|
||||
response, err := io.ReadAll(c)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading response from server: %w", err)
|
||||
}
|
||||
c.Close()
|
||||
os.Stdout.Write(response)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -88,14 +88,6 @@ func parseStyles() styleMap {
|
||||
return sm
|
||||
}
|
||||
|
||||
func parseEscapeSequence(s string) tcell.Style {
|
||||
s = strings.TrimPrefix(s, "\033[")
|
||||
if i := strings.IndexByte(s, 'm'); i >= 0 {
|
||||
s = s[:i]
|
||||
}
|
||||
return applyAnsiCodes(s, tcell.StyleDefault)
|
||||
}
|
||||
|
||||
func parseColor(toks []string) (tcell.Color, int, error) {
|
||||
if len(toks) == 0 {
|
||||
return tcell.ColorDefault, 0, fmt.Errorf("invalid args: %v", toks)
|
||||
|
||||
@@ -398,6 +398,8 @@ func completeCmd(acc []rune) (matches []compMatch, result string) {
|
||||
matches, result = matchList(f[2], []string{"mode", "timestamps"})
|
||||
case "selmode":
|
||||
matches, result = matchWord(f[2], []string{"all", "dir"})
|
||||
case "sizeunits":
|
||||
matches, result = matchWord(f[2], []string{"binary", "decimal"})
|
||||
case "sortby":
|
||||
matches, result = matchWord(f[2], []string{"atime", "btime", "ctime", "custom", "ext", "name", "natural", "size", "time"})
|
||||
default:
|
||||
|
||||
@@ -10,7 +10,7 @@ lf - terminal file manager
|
||||
[**-cpuprofile** *path*]
|
||||
[**-doc**]
|
||||
[**-last-dir-path** *path*]
|
||||
[**-log path**]
|
||||
[**-log** *path*]
|
||||
[**-memprofile** *path*]
|
||||
[**-print-last-dir**]
|
||||
[**-print-selection**]
|
||||
@@ -29,7 +29,7 @@ lf is a terminal file manager.
|
||||
The source code can be found in the repository at https://github.com/gokcehan/lf
|
||||
|
||||
This documentation can either be read from the terminal using `lf -doc` or online at https://github.com/gokcehan/lf/blob/master/doc.md
|
||||
You can also use the `doc` command (default `<f-1>`) inside lf to view the documentation in a pager.
|
||||
You can also use the `help` command (default `<f-1>`) inside lf to view the documentation in a pager.
|
||||
A man page with the same content is also available in the repository at https://github.com/gokcehan/lf/blob/master/lf.1
|
||||
|
||||
You can run `lf -help` to see descriptions of command line options.
|
||||
@@ -155,7 +155,6 @@ The following options can be used to customize the behavior of lf:
|
||||
cursorparentfmt string (default "\033[7m")
|
||||
cursorpreviewfmt string (default "\033[4m")
|
||||
cutfmt string (default "\033[7;31m")
|
||||
dircache bool (default true)
|
||||
dircounts bool (default false)
|
||||
dirfirst bool (default true)
|
||||
dironly bool (default false)
|
||||
@@ -178,7 +177,9 @@ The following options can be used to customize the behavior of lf:
|
||||
info []string (default '')
|
||||
infotimefmtnew string (default 'Jan _2 15:04')
|
||||
infotimefmtold string (default 'Jan _2 2006')
|
||||
locale string (default '')
|
||||
menufmt string (default "\033[0m")
|
||||
menuheaderfmt string (default "\033[1m")
|
||||
menuselectfmt string (default "\033[7m")
|
||||
mouse bool (default false)
|
||||
number bool (default false)
|
||||
numberfmt string (default "\033[33m")
|
||||
@@ -200,7 +201,7 @@ The following options can be used to customize the behavior of lf:
|
||||
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||
shellopts []string (default '')
|
||||
showbinds bool (default true)
|
||||
sixel bool (default false)
|
||||
sizeunits string (default 'binary')
|
||||
smartcase bool (default true)
|
||||
smartdia bool (default false)
|
||||
sortby string (default 'natural')
|
||||
@@ -265,8 +266,8 @@ The following commands/keybindings are provided by default:
|
||||
map e $$EDITOR "$f"
|
||||
map i $$PAGER "$f"
|
||||
map w $$SHELL
|
||||
cmd doc $$lf -doc | $PAGER
|
||||
map <f-1> doc
|
||||
cmd help $$lf -doc | $PAGER
|
||||
map <f-1> help
|
||||
cmd maps $lf -remote "query $id maps" | $PAGER
|
||||
cmd nmaps $lf -remote "query $id nmaps" | $PAGER
|
||||
cmd vmaps $lf -remote "query $id vmaps" | $PAGER
|
||||
@@ -278,14 +279,18 @@ The following commands/keybindings are provided by default:
|
||||
map e $%EDITOR% %f%
|
||||
map i !%PAGER% %f%
|
||||
map w $%SHELL%
|
||||
cmd doc !%lf% -doc | %PAGER%
|
||||
map <f-1> doc
|
||||
cmd help !%lf% -doc | %PAGER%
|
||||
map <f-1> help
|
||||
cmd maps !%lf% -remote "query %id% maps" | %PAGER%
|
||||
cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER%
|
||||
cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER%
|
||||
cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
|
||||
cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%
|
||||
|
||||
The defaults for Windows are using `cmd` syntax.
|
||||
A `PowerShell` compatible configuration file can be found at
|
||||
https://github.com/gokcehan/lf/blob/master/etc/lfrc.ps1.example
|
||||
|
||||
The following additional keybindings are provided by default:
|
||||
|
||||
map zh set hidden!
|
||||
@@ -310,7 +315,7 @@ If the `mouse` option is enabled, mouse buttons have the following default effec
|
||||
Click on a file or directory to select it.
|
||||
|
||||
Right mouse button
|
||||
Enter a directory or open a file. Also works on the preview window.
|
||||
Enter a directory or open a file. Also works on the preview pane.
|
||||
|
||||
Scroll wheel
|
||||
Move up or down. If Ctrl is pressed, scroll up or down.
|
||||
@@ -368,9 +373,11 @@ You can configure these locations with the following variables given with their
|
||||
|
||||
Windows
|
||||
%LF_CONFIG_HOME%
|
||||
%XDG_CONFIG_HOME%
|
||||
%APPDATA%
|
||||
|
||||
%LF_DATA_HOME%
|
||||
%XDG_DATA_HOME%
|
||||
%LOCALAPPDATA%
|
||||
|
||||
A sample configuration file can be found at
|
||||
@@ -496,7 +503,7 @@ Read a shell command to execute piping its standard I/O to the bottom statline.
|
||||
|
||||
## shell-wait (modal) (default `!`)
|
||||
|
||||
Read a shell command to execute and wait for a key press in the end.
|
||||
Read a shell command to execute and wait for a key press at the end.
|
||||
|
||||
## shell-async (modal) (default `&`)
|
||||
|
||||
@@ -504,11 +511,11 @@ Read a shell command to execute asynchronously without standard I/O.
|
||||
|
||||
## find (modal) (default `f`), find-back (modal) (default `F`), find-next (default `;`), find-prev (default `,`)
|
||||
|
||||
Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match.
|
||||
Read key(s) to find the appropriate filename match in the forward/backward direction and jump to the next/previous match.
|
||||
|
||||
## search (default `/`), search-back (default `?`), search-next (default `n`), search-prev (default `N`)
|
||||
|
||||
Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match.
|
||||
Read a pattern to search for a filename match in the forward/backward direction and jump to the next/previous match.
|
||||
|
||||
## filter (modal), setfilter
|
||||
|
||||
@@ -536,7 +543,7 @@ You can define a new tag-clearing command by combining `tag` with `tag-toggle` (
|
||||
|
||||
## 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.
|
||||
Tag a file with `*` or a single-width character given in the argument if the file is untagged, otherwise remove the tag.
|
||||
|
||||
## echo
|
||||
|
||||
@@ -622,7 +629,7 @@ When the cursor is at the first character in `:` mode, pressing one of the keys
|
||||
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.
|
||||
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
|
||||
|
||||
@@ -682,7 +689,7 @@ Delete everything up to the beginning/end of the line.
|
||||
|
||||
## cmd-delete-unix-word (default `<c-w>`)
|
||||
|
||||
Delete the previous unix word.
|
||||
Delete the previous Unix word.
|
||||
|
||||
## cmd-yank (default `<c-y>`)
|
||||
|
||||
@@ -715,7 +722,7 @@ Character `:` is used as the separator for list options `[]int` and `[]string`.
|
||||
|
||||
## anchorfind (bool) (default true)
|
||||
|
||||
When this option is enabled, the find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
|
||||
When this option is enabled, the find command starts matching patterns from the beginning of filenames, otherwise, it can match at an arbitrary position.
|
||||
|
||||
## autoquit (bool) (default true)
|
||||
|
||||
@@ -730,14 +737,14 @@ Format string of the box drawing characters enabled by the `drawbox` option.
|
||||
Set the path of a cleaner file.
|
||||
The file should be executable.
|
||||
This file is called if previewing is enabled, the previewer is set, and the previously selected file has its preview cache disabled.
|
||||
The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next file name to be previewed respectively.
|
||||
The following arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next filename to be previewed respectively.
|
||||
Preview cleaning is disabled when the value of this option is left empty.
|
||||
|
||||
## copyfmt (string) (default `\033[7;33m`)
|
||||
|
||||
Format string of the indicator for files to be copied.
|
||||
|
||||
## cursoractivefmt (string) (default `\033[7m`), cursorparentfmt string (default `\033[7m`), cursorpreviewfmt string (default `\033[4m`)
|
||||
## cursoractivefmt (string) (default `\033[7m`), cursorparentfmt (string) (default `\033[7m`), cursorpreviewfmt (string) (default `\033[4m`)
|
||||
|
||||
Format strings for highlighting the cursor.
|
||||
`cursoractivefmt` applies in the current directory pane,
|
||||
@@ -755,10 +762,6 @@ For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`.
|
||||
|
||||
Format string of the indicator for files to be cut.
|
||||
|
||||
## dircache (bool) (default true)
|
||||
|
||||
Cache directory contents.
|
||||
|
||||
## dircounts (bool) (default false)
|
||||
|
||||
When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using `calcdirsize`.
|
||||
@@ -786,8 +789,8 @@ Draw boxes around panes with box drawing characters.
|
||||
|
||||
## dupfilefmt (string) (default `%f.~%n~`)
|
||||
|
||||
Format string of file name when creating duplicate files. With the default format, copying a file `abc.txt` to the same directory will result in a duplicate file called `abc.txt.~1~`.
|
||||
Special expansions are provided, `%f` as the file name, `%b` for the basename (file name without extension), `%e` as the extension (including the dot) and `%n` as the number of duplicates.
|
||||
Format string of filename when creating duplicate files. With the default format, copying a file `abc.txt` to the same directory will result in a duplicate file called `abc.txt.~1~`.
|
||||
Special expansions are provided, `%f` as the file name, `%b` for the base name (file name without extension), `%e` as the extension (including the dot) and `%n` as the number of duplicates.
|
||||
|
||||
## errorfmt (string) (default `\033[7;31;47m`)
|
||||
|
||||
@@ -803,7 +806,7 @@ File separator used in environment variables `fs`, `fv` and `fx`.
|
||||
## filtermethod (string) (default `text`)
|
||||
|
||||
How filter command patterns are treated.
|
||||
Currently supported methods are `text` (i.e. string literals), `glob` (i.e shell globs) and `regex` (i.e. regular expressions).
|
||||
Currently supported methods are `text` (i.e. string literals), `glob` (i.e. shell globs) and `regex` (i.e. regular expressions).
|
||||
See `SEARCHING FILES` for more details.
|
||||
|
||||
## findlen (int) (default 1)
|
||||
@@ -860,8 +863,19 @@ Jump to the first match after each keystroke during searching.
|
||||
## info ([]string) (default ``)
|
||||
|
||||
A list of information that is shown for directory items at the right side of the pane.
|
||||
Currently supported information types are `size`, `time`, `atime`, `btime`, `ctime`, `perm`, `user`, `group` and `custom`.
|
||||
The `custom` type is empty by default and can be updated using the `addcustominfo` command.
|
||||
|
||||
The following information types are supported:
|
||||
|
||||
perm file permission
|
||||
user user name
|
||||
group group name
|
||||
size file size
|
||||
time time of last data modification
|
||||
atime time of last access
|
||||
btime time of file birth
|
||||
ctime time of last status (inode) change
|
||||
custom property defined via `addcustominfo` (empty by default)
|
||||
|
||||
Information is only shown when the pane width is more than twice the width of information.
|
||||
|
||||
## infotimefmtnew (string) (default `Jan _2 15:04`)
|
||||
@@ -872,11 +886,17 @@ Format string of the file time shown in the info column when it matches this yea
|
||||
|
||||
Format string of the file time shown in the info column when it doesn't match this year.
|
||||
|
||||
## locale (string) (default ``)
|
||||
## menufmt (string) (default `\033[0m`)
|
||||
|
||||
An IETF BCP 47 language tag (e.g. `zh-CN`) for specifying the locale used when using sort type `natural` and `name`.
|
||||
An empty string means disable locale ordering, and the special value `*` is used to indicate reading the locale setting from the system environment.
|
||||
This feature is currently experimental.
|
||||
Format string of the menu.
|
||||
|
||||
## menuheaderfmt (string) (default `\033[1m`)
|
||||
|
||||
Format string of the header row in the menu.
|
||||
|
||||
## menuselectfmt (string) (default `\033[7m`)
|
||||
|
||||
Format string of the currently selected item in the menu.
|
||||
|
||||
## mouse (bool) (default false)
|
||||
|
||||
@@ -915,7 +935,7 @@ Files containing the null character (U+0000) in the read portion are considered
|
||||
|
||||
Set the path of a previewer file to filter the content of regular files for previewing.
|
||||
The file should be executable.
|
||||
The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
|
||||
The following arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
|
||||
SIGPIPE signal is sent when enough lines are read.
|
||||
If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled.
|
||||
This means that if the file is selected in the future, the previewer is called once again.
|
||||
@@ -924,7 +944,17 @@ Preview filtering is disabled and files are displayed as they are when the value
|
||||
## promptfmt (string) (default `\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m`)
|
||||
|
||||
Format string of the prompt shown in the top line.
|
||||
Special expansions are provided, `%u` as the user name, `%h` as the hostname, `%w` as the working directory, `%d` as the working directory with a trailing path separator, `%f` as the file name, and `%F` as the current filter. `%S` may be used once and will provide a spacer so that the following parts are right aligned on the screen.
|
||||
|
||||
The following special expansions are supported:
|
||||
|
||||
%f file name
|
||||
%h host name
|
||||
%u user name
|
||||
%w working directory
|
||||
%d working directory (with trailing path separator)
|
||||
%F current filter
|
||||
%S spacer to right-align the following parts (can be used once)
|
||||
|
||||
The home folder is shown as `~` in the working directory expansion.
|
||||
Directory names are automatically shortened to a single character starting from the leftmost parent when the prompt does not fit the screen.
|
||||
|
||||
@@ -950,7 +980,22 @@ Draw rounded outer corners when the `drawbox` option is enabled.
|
||||
## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t`)
|
||||
|
||||
Format string of the ruler shown in the bottom right corner.
|
||||
Special expansions are provided, `%a` as the pressed keys, `%p` as the progress of file operations, `%m` as the number of files to be cut (moved), `%c` as the number of files to be copied, `%s` as the number of selected files, `%v` as the number of visually selected files, `%f` as the filter, `%i` as the position of the cursor, `%t` as the number of files shown in the current directory, `%h` as the number of files hidden in the current directory, `%P` as the scroll percentage, and `%d` as the amount of free disk space remaining.
|
||||
|
||||
The following special expansions are supported:
|
||||
|
||||
%a pressed keys
|
||||
%p progress of file operations
|
||||
%m number of files to be cut (moved)
|
||||
%c number of files to be copied
|
||||
%s number of selected files
|
||||
%v number of visually selected files
|
||||
%t number of shown files in the current directory
|
||||
%h number of hidden files in the current directory
|
||||
%f current filter
|
||||
%i cursor position
|
||||
%P scroll percentage
|
||||
%d amount of free disk space
|
||||
|
||||
Additional expansions are provided for environment variables exported by lf, in the form `%{lf_<name>}` (e.g. `%{lf_selmode}`). This is useful for displaying the current settings.
|
||||
Expansions are also provided for user-defined options, in the form `%{lf_user_<name>}` (e.g. `%{lf_user_foo}`).
|
||||
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
|
||||
@@ -958,13 +1003,13 @@ The `|` character splits the format string into sections. Any section containing
|
||||
## scrolloff (int) (default 0)
|
||||
|
||||
Minimum number of offset lines shown at all times at the top and bottom of the screen when scrolling.
|
||||
The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines.
|
||||
The current line is kept in the middle when this option is set to a large value that is bigger than half the number of lines.
|
||||
A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items.
|
||||
|
||||
## searchmethod (string) default `text`)
|
||||
## searchmethod (string) (default `text`)
|
||||
|
||||
How search command patterns are treated.
|
||||
Currently supported methods are `text` (i.e. string literals), `glob` (i.e shell globs) and `regex` (i.e. regular expressions).
|
||||
Currently supported methods are `text` (i.e. string literals), `glob` (i.e. shell globs) and `regex` (i.e. regular expressions).
|
||||
See `SEARCHING FILES` for more details.
|
||||
|
||||
## selectfmt (string) (default `\033[7;35m`)
|
||||
@@ -994,9 +1039,9 @@ List of shell options to pass to the shell executable.
|
||||
|
||||
Show bindings associated with pressed keys.
|
||||
|
||||
## sixel (bool) (default false)
|
||||
## sizeunits (string) (default `binary`)
|
||||
|
||||
Render sixel images in preview.
|
||||
Determines whether file sizes are displayed using binary units (`1K` is 1024 bytes) or decimal units (`1K` is 1000 bytes).
|
||||
|
||||
## smartcase (bool) (default true)
|
||||
|
||||
@@ -1011,29 +1056,38 @@ This option has no effect when `ignoredia` is disabled.
|
||||
## sortby (string) (default `natural`)
|
||||
|
||||
Sort type for directories.
|
||||
Currently supported sort types are `natural`, `name`, `size`, `time`, `atime`, `btime`, `ctime`, `ext` and `custom`.
|
||||
|
||||
Meaning of each sort type:
|
||||
The following sort types are supported:
|
||||
|
||||
natural file name (track_2.flac comes before track_10.flac)
|
||||
name file name (track_10.flac comes before track_2.flac)
|
||||
ext file extension
|
||||
size file size
|
||||
time time of last data modification
|
||||
atime time of last access
|
||||
btime time of file birth
|
||||
ctime time of last status (inode) change
|
||||
ext file extension
|
||||
custom property defined via `addcustominfo`
|
||||
custom property defined via `addcustominfo` (empty by default)
|
||||
|
||||
## statfmt (string) (default `\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l`)
|
||||
|
||||
Format string of the file info shown in the bottom left corner.
|
||||
Special expansions are provided, `%p` as the file permissions, `%c` as the link count, `%u` as the user, `%g` as the group, `%s` as the file size, `%S` as the file size but with a fixed width of five characters (left-padded with spaces), `%t` as the last modified time, `%l` as the link target, `%m` as the current mode and `%M` as the current mode but also shown in Normal mode (displaying `NORMAL` instead of a blank string).
|
||||
|
||||
The following special expansions are supported:
|
||||
|
||||
%p file permission
|
||||
%c link count
|
||||
%u user name
|
||||
%g group name
|
||||
%s file size
|
||||
%S file size (left-padded with spaces to a fixed width of 5 characters)
|
||||
%t time of last data modification
|
||||
%l link target
|
||||
%m current mode
|
||||
%M current mode (displaying `NORMAL` instead of a blank string in Normal mode)
|
||||
|
||||
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
|
||||
|
||||
File size is formatted using first letter of IEC 80000-13:2025 prefixes for binary multiples (i.e. 1024 bytes is `1.0K`).
|
||||
|
||||
## tabstop (int) (default 8)
|
||||
|
||||
Number of space characters to show for horizontal tabulation (U+0009) character.
|
||||
@@ -1057,7 +1111,7 @@ Format string of the file modification time shown in the bottom line.
|
||||
|
||||
## truncatechar (string) (default `~`)
|
||||
|
||||
The truncate character that is shown at the end when the file name does not fit into the pane.
|
||||
The truncate character that is shown at the end when the filename does not fit into the pane.
|
||||
|
||||
## truncatepct (int) (default 100)
|
||||
|
||||
@@ -1144,7 +1198,7 @@ For example, with POSIX shells, you can use `[ -n "$LF_LEVEL" ] && PS1="$PS1""(l
|
||||
|
||||
## OPENER
|
||||
|
||||
If this variable is set in the environment, use the same value. Otherwise, this is set to `start` in Windows, `open` in MacOS, `xdg-open` in others.
|
||||
If this variable is set in the environment, use the same value. Otherwise, this is set to `start` in Windows, `open` in macOS, `xdg-open` in others.
|
||||
|
||||
## EDITOR
|
||||
|
||||
@@ -1249,7 +1303,7 @@ This shell command can be defined to be executed before quitting.
|
||||
|
||||
The following command prefixes are used by lf:
|
||||
|
||||
: read (default) builtin/custom command
|
||||
: read (default) built-in/custom command
|
||||
$ shell shell command
|
||||
% shell-pipe shell command running with the UI
|
||||
! shell-wait shell command waiting for a key press
|
||||
@@ -1277,12 +1331,12 @@ Command `set` is used to set an option which can be a boolean, integer, or strin
|
||||
set hidden false # boolean disable
|
||||
set hidden! # boolean toggle
|
||||
set scrolloff 10 # integer value
|
||||
set sortby time # string value w/o quotes
|
||||
set sortby 'time' # string value with single quotes (whitespaces)
|
||||
set sortby time # string value without quotes
|
||||
set sortby 'time' # string value with single quotes (whitespace)
|
||||
set sortby "time" # string value with double quotes (backslash escapes)
|
||||
|
||||
Command `setlocal` is used to set a local option for a directory which can be a boolean or string.
|
||||
Currently supported local options are `dircounts`, `dirfirst`, `dironly`, `hidden`, `info`, `locale`, `reverse` and `sortby`.
|
||||
Currently supported local options are `dircounts`, `dirfirst`, `dironly`, `hidden`, `info`, `reverse` and `sortby`.
|
||||
Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets the option for the given directory along with its subdirectories:
|
||||
|
||||
setlocal /foo/bar hidden # boolean enable
|
||||
@@ -1290,15 +1344,15 @@ Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets th
|
||||
setlocal /foo/bar nohidden # boolean disable
|
||||
setlocal /foo/bar hidden false # boolean disable
|
||||
setlocal /foo/bar hidden! # boolean toggle
|
||||
setlocal /foo/bar sortby time # string value w/o quotes
|
||||
setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces)
|
||||
setlocal /foo/bar sortby time # string value without quotes
|
||||
setlocal /foo/bar sortby 'time' # string value with single quotes (whitespace)
|
||||
setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes)
|
||||
setlocal /foo/bar hidden # for only '/foo/bar' directory
|
||||
setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz')
|
||||
|
||||
Command `map` is used to bind a key in Normal and Visual mode to a command which can be a builtin command, custom command, or shell command:
|
||||
Command `map` is used to bind a key in Normal and Visual mode to a command which can be a built-in command, custom command, or shell command:
|
||||
|
||||
map gh cd ~ # builtin command
|
||||
map gh cd ~ # built-in command
|
||||
map D trash # custom command
|
||||
map i $less $f # shell command
|
||||
map U !du -csh * # waiting shell command
|
||||
@@ -1355,7 +1409,7 @@ Regular keys are assigned to a command with the usual syntax:
|
||||
|
||||
map a down
|
||||
|
||||
Keys combined with the shift key simply use the uppercase letter:
|
||||
Keys combined with the Shift key simply use the uppercase letter:
|
||||
|
||||
map A down
|
||||
|
||||
@@ -1372,19 +1426,19 @@ Function keys are prefixed with `f` character:
|
||||
|
||||
map <f-1> down
|
||||
|
||||
Keys combined with the control key are prefixed with a `c` character:
|
||||
Keys combined with the Ctrl key are prefixed with a `c` character:
|
||||
|
||||
map <c-a> down
|
||||
|
||||
Keys combined with the alt key are assigned in two different ways depending on the behavior of your terminal.
|
||||
Older terminals (e.g. xterm) may set the 8th bit of a character when the alt key is pressed.
|
||||
Keys combined with the Alt key are assigned in two different ways depending on the behavior of your terminal.
|
||||
Older terminals (e.g. xterm) may set the 8th bit of a character when the Alt key is pressed.
|
||||
On these terminals, you can use the corresponding byte for the mapping:
|
||||
|
||||
map á down
|
||||
|
||||
Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key when the alt key is pressed.
|
||||
lf uses the escape delaying mechanism to recognize alt keys in these terminals (delay is 100ms).
|
||||
On these terminals, keys combined with the alt key are prefixed with an `a` character:
|
||||
Newer terminals (e.g. gnome-terminal) may prefix the key with an escape character when the Alt key is pressed.
|
||||
lf uses the escape delaying mechanism to recognize Alt keys in these terminals (delay is 100ms).
|
||||
On these terminals, keys combined with the Alt key are prefixed with an `a` character:
|
||||
|
||||
map <a-a> down
|
||||
|
||||
@@ -1484,18 +1538,18 @@ However, use of this option is highly recommended and it is assumed in the rest
|
||||
# PIPING SHELL COMMANDS
|
||||
|
||||
Regular shell commands have some limitations in some cases.
|
||||
When an output or error message is given and the command exits afterwards, the ui is immediately resumed and there is no way to see the message without dropping to shell again.
|
||||
When an output or error message is given and the command exits afterwards, the UI is immediately resumed and there is no way to see the message without dropping to shell again.
|
||||
Also, even when there is no output or error, the UI still needs to be paused while the command is running.
|
||||
This can cause flickering on the screen for short commands and similar distractions for longer commands.
|
||||
|
||||
Instead of pausing the UI, piping shell commands connect stdin, stdout, and stderr of the command to the statline at the bottom of the UI.
|
||||
This can be useful for programs following the Unix philosophy to give no output in the success case, and brief error messages or prompts in other cases.
|
||||
|
||||
For example, following rename command prompts for overwrite in the statline if there is an existing file with the given name:
|
||||
For example, the following rename command prompts for overwrite in the statline if there is an existing file with the given name:
|
||||
|
||||
cmd rename %mv -i $f $1
|
||||
|
||||
You can also output error messages in the command and it will show up in the statline.
|
||||
You can also output error messages in the command and they will show up in the statline.
|
||||
For example, an alternative rename command may look like this:
|
||||
|
||||
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
||||
@@ -1537,7 +1591,7 @@ You can optionally give it an ID number to send a command to a single client:
|
||||
|
||||
lf -remote 'send 1234 echo hello world'
|
||||
|
||||
All clients have a unique id number but you may not be aware of the id number when you are writing a command.
|
||||
All clients have a unique ID number but you may not be aware of the ID number when you are writing a command.
|
||||
For this purpose, an `$id` variable is exported to the environment for shell commands.
|
||||
The value of this variable is set to the process ID of the client.
|
||||
You can use it to send a remote command from a client to the server which in return sends a command back to itself.
|
||||
@@ -1558,7 +1612,7 @@ For example, you can configure the number of columns in the UI with respect to t
|
||||
fi
|
||||
}}
|
||||
|
||||
In addition, the `query` command can be used to obtain information about a specific lf instance by providing its id:
|
||||
In addition, the `query` command can be used to obtain information about a specific lf instance by providing its ID:
|
||||
|
||||
lf -remote "query $id maps"
|
||||
|
||||
@@ -1611,7 +1665,7 @@ Only file modes and (some) timestamps can be preserved (see `preserve` option),
|
||||
Special files such as character and block devices, named pipes, and sockets are skipped and links are not followed.
|
||||
Moving is performed using the rename operation of the underlying OS.
|
||||
For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors.
|
||||
Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation.
|
||||
Operation errors are shown in the message line as well as the log file and they do not prematurely terminate the corresponding file operation.
|
||||
|
||||
File operations can be performed on the currently selected file or on multiple files by selecting them first.
|
||||
When you `copy` a file, lf doesn't actually copy the file on the disk, but only records its name to a file.
|
||||
@@ -1666,10 +1720,10 @@ You can set the number of keys to match using `findlen` option.
|
||||
If you set this value to zero, then the keys are read until there is only a single match.
|
||||
The default values of these two options are set to jump to the first file with the given initial.
|
||||
|
||||
Some options effect both searching and finding.
|
||||
Some options affect both searching and finding.
|
||||
You can disable `wrapscan` option to prevent searches from being wrapped around at the end of the file list.
|
||||
You can disable `ignorecase` option to match cases in the pattern and the filename.
|
||||
This option is already automatically overridden if the pattern contains upper-case characters.
|
||||
This option is already automatically overridden if the pattern contains uppercase characters.
|
||||
You can disable `smartcase` option to disable this behavior.
|
||||
Two similar options `ignoredia` and `smartdia` are provided to control matching diacritics in Latin letters.
|
||||
|
||||
@@ -1685,7 +1739,7 @@ It is possible to use different command types:
|
||||
|
||||
cmd open &xdg-open $f
|
||||
|
||||
You may want to use either file extensions or mime types from `file` command:
|
||||
You may want to use either file extensions or MIME types from `file` command:
|
||||
|
||||
cmd open ${{
|
||||
case $(file --mime-type -Lb $f) in
|
||||
@@ -1719,11 +1773,11 @@ Possible options are `libfile-mimeinfo-perl` (executable name is `mimeopen`), `r
|
||||
|
||||
lf previews files on the preview pane by printing the file until the end or until the preview pane is filled.
|
||||
This output can be enhanced by providing a custom preview script for filtering.
|
||||
This can be used to highlight source codes, list contents of archive files or view PDF or image files to name a few.
|
||||
This can be used to highlight source code, list contents of archive files or view PDF or image files to name a few.
|
||||
For coloring lf recognizes ANSI escape codes.
|
||||
|
||||
To use this feature, you need to set the value of `previewer` option to the path of an executable file.
|
||||
Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
|
||||
Five arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
|
||||
The output of the execution is printed in the preview pane.
|
||||
You may also want to use the same script in your pager mapping as well:
|
||||
|
||||
@@ -1736,7 +1790,7 @@ For `less` pager, you may instead utilize `LESSOPEN` mechanism so that useful in
|
||||
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
||||
|
||||
Since this script is called for each file selection change it needs to be as efficient as possible and this responsibility is left to the user.
|
||||
You may use file extensions to determine the type of file more efficiently compared to obtaining mime types from `file` command.
|
||||
You may use file extensions to determine the type of file more efficiently compared to obtaining MIME types from `file` command.
|
||||
Extensions can then be used to match cleanly within a conditional:
|
||||
|
||||
#!/bin/sh
|
||||
@@ -1870,7 +1924,7 @@ It starts with a default color scheme and updates colors using values of existin
|
||||
Colors are set in the following order:
|
||||
|
||||
1. default
|
||||
2. LSCOLORS (Mac/BSD ls)
|
||||
2. LSCOLORS (macOS/BSD ls)
|
||||
3. LS_COLORS (GNU ls)
|
||||
4. LF_COLORS (lf specific)
|
||||
5. colors file (lf specific)
|
||||
@@ -1979,7 +2033,7 @@ You may instead divide it into multiple lines in between double quotes by escapi
|
||||
ex=01;32:\
|
||||
"
|
||||
|
||||
The `ln` entry supports the special value `target`, which will use the link target to select a style. File name rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
|
||||
The `ln` entry supports the special value `target`, which will use the link target to select a style. Filename rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
|
||||
Having such a long variable definition in a shell configuration file might be undesirable.
|
||||
You may instead use the colors file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) for configuration.
|
||||
A sample colors file can be found at
|
||||
@@ -1991,12 +2045,12 @@ https://en.wikipedia.org/wiki/ANSI_escape_code
|
||||
|
||||
Icons are configured using `LF_ICONS` environment variable or an icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)).
|
||||
The variable uses the same syntax as `LS_COLORS/LF_COLORS`.
|
||||
Instead of colors, you should put a single characters as values of entries.
|
||||
The `ln` entry supports the special value `target`, which will use the link target to select a icon. File name rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
|
||||
Instead of colors, you should use single characters or symbols as values.
|
||||
The `ln` entry supports the special value `target`, which will use the link target to select a icon. Filename rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
|
||||
The icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) should consist of whitespace-separated arrays with a `#` character to start comments until the end of the line.
|
||||
Each line should contain 1-3 columns, first column is filetype or filename pattern, second column is the icon, third column is an optional icon color. If there is only one column, means to disable rule for this filetype or pattern.
|
||||
Each line should contain 1-3 columns: a file type or file name pattern, the icon, and an optional icon color. Using only one column disables all rules for that type or name.
|
||||
Do not forget to add `set icons true` to your `lfrc` to see the icons.
|
||||
Default values are as follows given with their matching order in lf:
|
||||
Default values are listed below in the order lf matches them:
|
||||
|
||||
ln l
|
||||
or l
|
||||
|
||||
@@ -18,7 +18,7 @@ https://github.com/gokcehan/lf
|
||||
|
||||
This documentation can either be read from the terminal using lf -doc or
|
||||
online at https://github.com/gokcehan/lf/blob/master/doc.md You can also
|
||||
use the doc command (default <f-1>) inside lf to view the documentation
|
||||
use the help command (default <f-1>) inside lf to view the documentation
|
||||
in a pager. A man page with the same content is also available in the
|
||||
repository at https://github.com/gokcehan/lf/blob/master/lf.1
|
||||
|
||||
@@ -145,7 +145,6 @@ The following options can be used to customize the behavior of lf:
|
||||
cursorparentfmt string (default "\033[7m")
|
||||
cursorpreviewfmt string (default "\033[4m")
|
||||
cutfmt string (default "\033[7;31m")
|
||||
dircache bool (default true)
|
||||
dircounts bool (default false)
|
||||
dirfirst bool (default true)
|
||||
dironly bool (default false)
|
||||
@@ -168,7 +167,9 @@ The following options can be used to customize the behavior of lf:
|
||||
info []string (default '')
|
||||
infotimefmtnew string (default 'Jan _2 15:04')
|
||||
infotimefmtold string (default 'Jan _2 2006')
|
||||
locale string (default '')
|
||||
menufmt string (default "\033[0m")
|
||||
menuheaderfmt string (default "\033[1m")
|
||||
menuselectfmt string (default "\033[7m")
|
||||
mouse bool (default false)
|
||||
number bool (default false)
|
||||
numberfmt string (default "\033[33m")
|
||||
@@ -190,7 +191,7 @@ The following options can be used to customize the behavior of lf:
|
||||
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||
shellopts []string (default '')
|
||||
showbinds bool (default true)
|
||||
sixel bool (default false)
|
||||
sizeunits string (default 'binary')
|
||||
smartcase bool (default true)
|
||||
smartdia bool (default false)
|
||||
sortby string (default 'natural')
|
||||
@@ -256,8 +257,8 @@ The following commands/keybindings are provided by default:
|
||||
map e $$EDITOR "$f"
|
||||
map i $$PAGER "$f"
|
||||
map w $$SHELL
|
||||
cmd doc $$lf -doc | $PAGER
|
||||
map <f-1> doc
|
||||
cmd help $$lf -doc | $PAGER
|
||||
map <f-1> help
|
||||
cmd maps $lf -remote "query $id maps" | $PAGER
|
||||
cmd nmaps $lf -remote "query $id nmaps" | $PAGER
|
||||
cmd vmaps $lf -remote "query $id vmaps" | $PAGER
|
||||
@@ -269,14 +270,18 @@ The following commands/keybindings are provided by default:
|
||||
map e $%EDITOR% %f%
|
||||
map i !%PAGER% %f%
|
||||
map w $%SHELL%
|
||||
cmd doc !%lf% -doc | %PAGER%
|
||||
map <f-1> doc
|
||||
cmd help !%lf% -doc | %PAGER%
|
||||
map <f-1> help
|
||||
cmd maps !%lf% -remote "query %id% maps" | %PAGER%
|
||||
cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER%
|
||||
cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER%
|
||||
cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
|
||||
cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%
|
||||
|
||||
The defaults for Windows are using cmd syntax. A PowerShell compatible
|
||||
configuration file can be found at
|
||||
https://github.com/gokcehan/lf/blob/master/etc/lfrc.ps1.example
|
||||
|
||||
The following additional keybindings are provided by default:
|
||||
|
||||
map zh set hidden!
|
||||
@@ -302,7 +307,7 @@ effects:
|
||||
Click on a file or directory to select it.
|
||||
|
||||
Right mouse button
|
||||
Enter a directory or open a file. Also works on the preview window.
|
||||
Enter a directory or open a file. Also works on the preview pane.
|
||||
|
||||
Scroll wheel
|
||||
Move up or down. If Ctrl is pressed, scroll up or down.
|
||||
@@ -361,9 +366,11 @@ with their order of precedences and their default values:
|
||||
|
||||
Windows
|
||||
%LF_CONFIG_HOME%
|
||||
%XDG_CONFIG_HOME%
|
||||
%APPDATA%
|
||||
|
||||
%LF_DATA_HOME%
|
||||
%XDG_DATA_HOME%
|
||||
%LOCALAPPDATA%
|
||||
|
||||
A sample configuration file can be found at
|
||||
@@ -500,7 +507,7 @@ statline.
|
||||
|
||||
shell-wait (modal) (default !)
|
||||
|
||||
Read a shell command to execute and wait for a key press in the end.
|
||||
Read a shell command to execute and wait for a key press at the end.
|
||||
|
||||
shell-async (modal) (default &)
|
||||
|
||||
@@ -508,12 +515,12 @@ Read a shell command to execute asynchronously without standard I/O.
|
||||
|
||||
find (modal) (default f), find-back (modal) (default F), find-next (default ;), find-prev (default ,)
|
||||
|
||||
Read key(s) to find the appropriate file name match in the
|
||||
Read key(s) to find the appropriate filename match in the
|
||||
forward/backward direction and jump to the next/previous match.
|
||||
|
||||
search (default /), search-back (default ?), search-next (default n), search-prev (default N)
|
||||
|
||||
Read a pattern to search for a file name match in the forward/backward
|
||||
Read a pattern to search for a filename match in the forward/backward
|
||||
direction and jump to the next/previous match.
|
||||
|
||||
filter (modal), setfilter
|
||||
@@ -545,7 +552,7 @@ can define a new tag-clearing command by combining tag with tag-toggle
|
||||
|
||||
tag-toggle (default t)
|
||||
|
||||
Tag a file with * or a single width character given in the argument if
|
||||
Tag a file with * or a single-width character given in the argument if
|
||||
the file is untagged, otherwise remove the tag.
|
||||
|
||||
echo
|
||||
@@ -644,7 +651,7 @@ 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
|
||||
of letters and digits, and a Unix word consists of any non-blank
|
||||
characters.
|
||||
|
||||
cmd-insert
|
||||
@@ -708,7 +715,7 @@ Delete everything up to the beginning/end of the line.
|
||||
|
||||
cmd-delete-unix-word (default <c-w>)
|
||||
|
||||
Delete the previous unix word.
|
||||
Delete the previous Unix word.
|
||||
|
||||
cmd-yank (default <c-y>)
|
||||
|
||||
@@ -744,8 +751,8 @@ Character : is used as the separator for list options []int and
|
||||
anchorfind (bool) (default true)
|
||||
|
||||
When this option is enabled, the find command starts matching patterns
|
||||
from the beginning of file names, otherwise, it can match at an
|
||||
arbitrary position.
|
||||
from the beginning of filenames, otherwise, it can match at an arbitrary
|
||||
position.
|
||||
|
||||
autoquit (bool) (default true)
|
||||
|
||||
@@ -761,16 +768,16 @@ cleaner (string) (default ``) (not called if empty)
|
||||
Set the path of a cleaner file. The file should be executable. This file
|
||||
is called if previewing is enabled, the previewer is set, and the
|
||||
previously selected file has its preview cache disabled. The following
|
||||
arguments are passed to the file, (1) current file name, (2) width, (3)
|
||||
arguments are passed to the file, (1) current filename, (2) width, (3)
|
||||
height, (4) horizontal position, (5) vertical position of preview pane
|
||||
and (6) next file name to be previewed respectively. Preview cleaning is
|
||||
and (6) next filename to be previewed respectively. Preview cleaning is
|
||||
disabled when the value of this option is left empty.
|
||||
|
||||
copyfmt (string) (default \033[7;33m)
|
||||
|
||||
Format string of the indicator for files to be copied.
|
||||
|
||||
cursoractivefmt (string) (default \033[7m), cursorparentfmt string (default \033[7m), cursorpreviewfmt string (default \033[4m)
|
||||
cursoractivefmt (string) (default \033[7m), cursorparentfmt (string) (default \033[7m), cursorpreviewfmt (string) (default \033[4m)
|
||||
|
||||
Format strings for highlighting the cursor. cursoractivefmt applies in
|
||||
the current directory pane, cursorparentfmt applies in panes that show
|
||||
@@ -794,10 +801,6 @@ cutfmt (string) (default \033[7;31m)
|
||||
|
||||
Format string of the indicator for files to be cut.
|
||||
|
||||
dircache (bool) (default true)
|
||||
|
||||
Cache directory contents.
|
||||
|
||||
dircounts (bool) (default false)
|
||||
|
||||
When this option is enabled, directory sizes show the number of items
|
||||
@@ -830,10 +833,10 @@ Draw boxes around panes with box drawing characters.
|
||||
|
||||
dupfilefmt (string) (default %f.~%n~)
|
||||
|
||||
Format string of file name when creating duplicate files. With the
|
||||
Format string of filename when creating duplicate files. With the
|
||||
default format, copying a file abc.txt to the same directory will result
|
||||
in a duplicate file called abc.txt.~1~. Special expansions are provided,
|
||||
%f as the file name, %b for the basename (file name without extension),
|
||||
%f as the file name, %b for the base name (file name without extension),
|
||||
%e as the extension (including the dot) and %n as the number of
|
||||
duplicates.
|
||||
|
||||
@@ -853,7 +856,7 @@ File separator used in environment variables fs, fv and fx.
|
||||
filtermethod (string) (default text)
|
||||
|
||||
How filter command patterns are treated. Currently supported methods are
|
||||
text (i.e. string literals), glob (i.e shell globs) and regex (i.e.
|
||||
text (i.e. string literals), glob (i.e. shell globs) and regex (i.e.
|
||||
regular expressions). See SEARCHING FILES for more details.
|
||||
|
||||
findlen (int) (default 1)
|
||||
@@ -912,9 +915,20 @@ Jump to the first match after each keystroke during searching.
|
||||
info ([]string) (default ``)
|
||||
|
||||
A list of information that is shown for directory items at the right
|
||||
side of the pane. Currently supported information types are size, time,
|
||||
atime, btime, ctime, perm, user, group and custom. The custom type is
|
||||
empty by default and can be updated using the addcustominfo command.
|
||||
side of the pane.
|
||||
|
||||
The following information types are supported:
|
||||
|
||||
perm file permission
|
||||
user user name
|
||||
group group name
|
||||
size file size
|
||||
time time of last data modification
|
||||
atime time of last access
|
||||
btime time of file birth
|
||||
ctime time of last status (inode) change
|
||||
custom property defined via `addcustominfo` (empty by default)
|
||||
|
||||
Information is only shown when the pane width is more than twice the
|
||||
width of information.
|
||||
|
||||
@@ -928,13 +942,17 @@ infotimefmtold (string) (default Jan _2 2006)
|
||||
Format string of the file time shown in the info column when it doesn't
|
||||
match this year.
|
||||
|
||||
locale (string) (default ``)
|
||||
menufmt (string) (default \033[0m)
|
||||
|
||||
An IETF BCP 47 language tag (e.g. zh-CN) for specifying the locale used
|
||||
when using sort type natural and name. An empty string means disable
|
||||
locale ordering, and the special value * is used to indicate reading the
|
||||
locale setting from the system environment. This feature is currently
|
||||
experimental.
|
||||
Format string of the menu.
|
||||
|
||||
menuheaderfmt (string) (default \033[1m)
|
||||
|
||||
Format string of the header row in the menu.
|
||||
|
||||
menuselectfmt (string) (default \033[7m)
|
||||
|
||||
Format string of the currently selected item in the menu.
|
||||
|
||||
mouse (bool) (default false)
|
||||
|
||||
@@ -979,8 +997,8 @@ previewer (string) (default ``) (not filtered if empty)
|
||||
|
||||
Set the path of a previewer file to filter the content of regular files
|
||||
for previewing. The file should be executable. The following arguments
|
||||
are passed to the file, (1) current file name, (2) width, (3) height,
|
||||
(4) horizontal position, and (5) vertical position of preview pane
|
||||
are passed to the file, (1) current filename, (2) width, (3) height, (4)
|
||||
horizontal position, and (5) vertical position of preview pane
|
||||
respectively. SIGPIPE signal is sent when enough lines are read. If the
|
||||
previewer returns a non-zero exit code, then the preview cache for the
|
||||
given file is disabled. This means that if the file is selected in the
|
||||
@@ -990,15 +1008,22 @@ option is left empty.
|
||||
|
||||
promptfmt (string) (default \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m)
|
||||
|
||||
Format string of the prompt shown in the top line. Special expansions
|
||||
are provided, %u as the user name, %h as the hostname, %w as the working
|
||||
directory, %d as the working directory with a trailing path separator,
|
||||
%f as the file name, and %F as the current filter. %S may be used once
|
||||
and will provide a spacer so that the following parts are right aligned
|
||||
on the screen. The home folder is shown as ~ in the working directory
|
||||
expansion. Directory names are automatically shortened to a single
|
||||
character starting from the leftmost parent when the prompt does not fit
|
||||
the screen.
|
||||
Format string of the prompt shown in the top line.
|
||||
|
||||
The following special expansions are supported:
|
||||
|
||||
%f file name
|
||||
%h host name
|
||||
%u user name
|
||||
%w working directory
|
||||
%d working directory (with trailing path separator)
|
||||
%F current filter
|
||||
%S spacer to right-align the following parts (can be used once)
|
||||
|
||||
The home folder is shown as ~ in the working directory expansion.
|
||||
Directory names are automatically shortened to a single character
|
||||
starting from the leftmost parent when the prompt does not fit the
|
||||
screen.
|
||||
|
||||
ratios ([]int) (default 1:2:3)
|
||||
|
||||
@@ -1022,18 +1047,27 @@ Draw rounded outer corners when the drawbox option is enabled.
|
||||
|
||||
rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t)
|
||||
|
||||
Format string of the ruler shown in the bottom right corner. Special
|
||||
expansions are provided, %a as the pressed keys, %p as the progress of
|
||||
file operations, %m as the number of files to be cut (moved), %c as the
|
||||
number of files to be copied, %s as the number of selected files, %v as
|
||||
the number of visually selected files, %f as the filter, %i as the
|
||||
position of the cursor, %t as the number of files shown in the current
|
||||
directory, %h as the number of files hidden in the current directory, %P
|
||||
as the scroll percentage, and %d as the amount of free disk space
|
||||
remaining. Additional expansions are provided for environment variables
|
||||
exported by lf, in the form %{lf_<name>} (e.g. %{lf_selmode}). This is
|
||||
useful for displaying the current settings. Expansions are also provided
|
||||
for user-defined options, in the form %{lf_user_<name>} (e.g.
|
||||
Format string of the ruler shown in the bottom right corner.
|
||||
|
||||
The following special expansions are supported:
|
||||
|
||||
%a pressed keys
|
||||
%p progress of file operations
|
||||
%m number of files to be cut (moved)
|
||||
%c number of files to be copied
|
||||
%s number of selected files
|
||||
%v number of visually selected files
|
||||
%t number of shown files in the current directory
|
||||
%h number of hidden files in the current directory
|
||||
%f current filter
|
||||
%i cursor position
|
||||
%P scroll percentage
|
||||
%d amount of free disk space
|
||||
|
||||
Additional expansions are provided for environment variables exported by
|
||||
lf, in the form %{lf_<name>} (e.g. %{lf_selmode}). This is useful for
|
||||
displaying the current settings. Expansions are also provided for
|
||||
user-defined options, in the form %{lf_user_<name>} (e.g.
|
||||
%{lf_user_foo}). The | character splits the format string into sections.
|
||||
Any section containing a failed expansion (result is a blank string) is
|
||||
discarded and not shown.
|
||||
@@ -1042,15 +1076,15 @@ scrolloff (int) (default 0)
|
||||
|
||||
Minimum number of offset lines shown at all times at the top and bottom
|
||||
of the screen when scrolling. The current line is kept in the middle
|
||||
when this option is set to a large value that is bigger than the half of
|
||||
when this option is set to a large value that is bigger than half the
|
||||
number of lines. A smaller offset can be used when the current file is
|
||||
close to the beginning or end of the list to show the maximum number of
|
||||
items.
|
||||
|
||||
searchmethod (string) default text)
|
||||
searchmethod (string) (default text)
|
||||
|
||||
How search command patterns are treated. Currently supported methods are
|
||||
text (i.e. string literals), glob (i.e shell globs) and regex (i.e.
|
||||
text (i.e. string literals), glob (i.e. shell globs) and regex (i.e.
|
||||
regular expressions). See SEARCHING FILES for more details.
|
||||
|
||||
selectfmt (string) (default \033[7;35m)
|
||||
@@ -1080,9 +1114,10 @@ showbinds (bool) (default true)
|
||||
|
||||
Show bindings associated with pressed keys.
|
||||
|
||||
sixel (bool) (default false)
|
||||
sizeunits (string) (default binary)
|
||||
|
||||
Render sixel images in preview.
|
||||
Determines whether file sizes are displayed using binary units (1K is
|
||||
1024 bytes) or decimal units (1K is 1000 bytes).
|
||||
|
||||
smartcase (bool) (default true)
|
||||
|
||||
@@ -1096,38 +1131,41 @@ diacritic. This option has no effect when ignoredia is disabled.
|
||||
|
||||
sortby (string) (default natural)
|
||||
|
||||
Sort type for directories. Currently supported sort types are natural,
|
||||
name, size, time, atime, btime, ctime, ext and custom.
|
||||
Sort type for directories.
|
||||
|
||||
Meaning of each sort type:
|
||||
The following sort types are supported:
|
||||
|
||||
natural file name (track_2.flac comes before track_10.flac)
|
||||
name file name (track_10.flac comes before track_2.flac)
|
||||
ext file extension
|
||||
size file size
|
||||
time time of last data modification
|
||||
atime time of last access
|
||||
btime time of file birth
|
||||
ctime time of last status (inode) change
|
||||
ext file extension
|
||||
custom property defined via `addcustominfo`
|
||||
custom property defined via `addcustominfo` (empty by default)
|
||||
|
||||
statfmt (string) (default \033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l)
|
||||
|
||||
Format string of the file info shown in the bottom left corner. Special
|
||||
expansions are provided, %p as the file permissions, %c as the link
|
||||
count, %u as the user, %g as the group, %s as the file size, %S as the
|
||||
file size but with a fixed width of five characters (left-padded with
|
||||
spaces), %t as the last modified time, %l as the link target, %m as the
|
||||
current mode and %M as the current mode but also shown in Normal mode
|
||||
(displaying NORMAL instead of a blank string).
|
||||
Format string of the file info shown in the bottom left corner.
|
||||
|
||||
The following special expansions are supported:
|
||||
|
||||
%p file permission
|
||||
%c link count
|
||||
%u user name
|
||||
%g group name
|
||||
%s file size
|
||||
%S file size (left-padded with spaces to a fixed width of 5 characters)
|
||||
%t time of last data modification
|
||||
%l link target
|
||||
%m current mode
|
||||
%M current mode (displaying `NORMAL` instead of a blank string in Normal mode)
|
||||
|
||||
The | character splits the format string into sections. Any section
|
||||
containing a failed expansion (result is a blank string) is discarded
|
||||
and not shown.
|
||||
|
||||
File size is formatted using first letter of IEC 80000-13:2025 prefixes
|
||||
for binary multiples (i.e. 1024 bytes is 1.0K).
|
||||
|
||||
tabstop (int) (default 8)
|
||||
|
||||
Number of space characters to show for horizontal tabulation (U+0009)
|
||||
@@ -1155,7 +1193,7 @@ Format string of the file modification time shown in the bottom line.
|
||||
|
||||
truncatechar (string) (default ~)
|
||||
|
||||
The truncate character that is shown at the end when the file name does
|
||||
The truncate character that is shown at the end when the filename does
|
||||
not fit into the pane.
|
||||
|
||||
truncatepct (int) (default 100)
|
||||
@@ -1254,7 +1292,7 @@ configuration file (e.g. ~/.bashrc).
|
||||
OPENER
|
||||
|
||||
If this variable is set in the environment, use the same value.
|
||||
Otherwise, this is set to start in Windows, open in MacOS, xdg-open in
|
||||
Otherwise, this is set to start in Windows, open in macOS, xdg-open in
|
||||
others.
|
||||
|
||||
EDITOR
|
||||
@@ -1376,7 +1414,7 @@ PREFIXES
|
||||
|
||||
The following command prefixes are used by lf:
|
||||
|
||||
: read (default) builtin/custom command
|
||||
: read (default) built-in/custom command
|
||||
$ shell shell command
|
||||
% shell-pipe shell command running with the UI
|
||||
! shell-wait shell command waiting for a key press
|
||||
@@ -1407,31 +1445,31 @@ string:
|
||||
set hidden false # boolean disable
|
||||
set hidden! # boolean toggle
|
||||
set scrolloff 10 # integer value
|
||||
set sortby time # string value w/o quotes
|
||||
set sortby 'time' # string value with single quotes (whitespaces)
|
||||
set sortby time # string value without quotes
|
||||
set sortby 'time' # string value with single quotes (whitespace)
|
||||
set sortby "time" # string value with double quotes (backslash escapes)
|
||||
|
||||
Command setlocal is used to set a local option for a directory which can
|
||||
be a boolean or string. Currently supported local options are dircounts,
|
||||
dirfirst, dironly, hidden, info, locale, reverse and sortby. Adding a
|
||||
trailing path separator (i.e. / for Unix and \ for Windows) sets the
|
||||
option for the given directory along with its subdirectories:
|
||||
dirfirst, dironly, hidden, info, reverse and sortby. Adding a trailing
|
||||
path separator (i.e. / for Unix and \ for Windows) sets the option for
|
||||
the given directory along with its subdirectories:
|
||||
|
||||
setlocal /foo/bar hidden # boolean enable
|
||||
setlocal /foo/bar hidden true # boolean enable
|
||||
setlocal /foo/bar nohidden # boolean disable
|
||||
setlocal /foo/bar hidden false # boolean disable
|
||||
setlocal /foo/bar hidden! # boolean toggle
|
||||
setlocal /foo/bar sortby time # string value w/o quotes
|
||||
setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces)
|
||||
setlocal /foo/bar sortby time # string value without quotes
|
||||
setlocal /foo/bar sortby 'time' # string value with single quotes (whitespace)
|
||||
setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes)
|
||||
setlocal /foo/bar hidden # for only '/foo/bar' directory
|
||||
setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz')
|
||||
|
||||
Command map is used to bind a key in Normal and Visual mode to a command
|
||||
which can be a builtin command, custom command, or shell command:
|
||||
which can be a built-in command, custom command, or shell command:
|
||||
|
||||
map gh cd ~ # builtin command
|
||||
map gh cd ~ # built-in command
|
||||
map D trash # custom command
|
||||
map i $less $f # shell command
|
||||
map U !du -csh * # waiting shell command
|
||||
@@ -1491,7 +1529,7 @@ Regular keys are assigned to a command with the usual syntax:
|
||||
|
||||
map a down
|
||||
|
||||
Keys combined with the shift key simply use the uppercase letter:
|
||||
Keys combined with the Shift key simply use the uppercase letter:
|
||||
|
||||
map A down
|
||||
|
||||
@@ -1509,21 +1547,21 @@ Function keys are prefixed with f character:
|
||||
|
||||
map <f-1> down
|
||||
|
||||
Keys combined with the control key are prefixed with a c character:
|
||||
Keys combined with the Ctrl key are prefixed with a c character:
|
||||
|
||||
map <c-a> down
|
||||
|
||||
Keys combined with the alt key are assigned in two different ways
|
||||
Keys combined with the Alt key are assigned in two different ways
|
||||
depending on the behavior of your terminal. Older terminals (e.g. xterm)
|
||||
may set the 8th bit of a character when the alt key is pressed. On these
|
||||
may set the 8th bit of a character when the Alt key is pressed. On these
|
||||
terminals, you can use the corresponding byte for the mapping:
|
||||
|
||||
map á down
|
||||
|
||||
Newer terminals (e.g. gnome-terminal) may prefix the key with an escape
|
||||
key when the alt key is pressed. lf uses the escape delaying mechanism
|
||||
to recognize alt keys in these terminals (delay is 100ms). On these
|
||||
terminals, keys combined with the alt key are prefixed with an a
|
||||
character when the Alt key is pressed. lf uses the escape delaying
|
||||
mechanism to recognize Alt keys in these terminals (delay is 100ms). On
|
||||
these terminals, keys combined with the Alt key are prefixed with an a
|
||||
character:
|
||||
|
||||
map <a-a> down
|
||||
@@ -1635,7 +1673,7 @@ PIPING SHELL COMMANDS
|
||||
|
||||
Regular shell commands have some limitations in some cases. When an
|
||||
output or error message is given and the command exits afterwards, the
|
||||
ui is immediately resumed and there is no way to see the message without
|
||||
UI is immediately resumed and there is no way to see the message without
|
||||
dropping to shell again. Also, even when there is no output or error,
|
||||
the UI still needs to be paused while the command is running. This can
|
||||
cause flickering on the screen for short commands and similar
|
||||
@@ -1647,14 +1685,14 @@ can be useful for programs following the Unix philosophy to give no
|
||||
output in the success case, and brief error messages or prompts in other
|
||||
cases.
|
||||
|
||||
For example, following rename command prompts for overwrite in the
|
||||
For example, the following rename command prompts for overwrite in the
|
||||
statline if there is an existing file with the given name:
|
||||
|
||||
cmd rename %mv -i $f $1
|
||||
|
||||
You can also output error messages in the command and it will show up in
|
||||
the statline. For example, an alternative rename command may look like
|
||||
this:
|
||||
You can also output error messages in the command and they will show up
|
||||
in the statline. For example, an alternative rename command may look
|
||||
like this:
|
||||
|
||||
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
||||
|
||||
@@ -1703,7 +1741,7 @@ send a command to a single client:
|
||||
|
||||
lf -remote 'send 1234 echo hello world'
|
||||
|
||||
All clients have a unique id number but you may not be aware of the id
|
||||
All clients have a unique ID number but you may not be aware of the ID
|
||||
number when you are writing a command. For this purpose, an $id variable
|
||||
is exported to the environment for shell commands. The value of this
|
||||
variable is set to the process ID of the client. You can use it to send
|
||||
@@ -1728,7 +1766,7 @@ UI with respect to the terminal width as follows:
|
||||
}}
|
||||
|
||||
In addition, the query command can be used to obtain information about a
|
||||
specific lf instance by providing its id:
|
||||
specific lf instance by providing its ID:
|
||||
|
||||
lf -remote "query $id maps"
|
||||
|
||||
@@ -1787,8 +1825,8 @@ named pipes, and sockets are skipped and links are not followed. Moving
|
||||
is performed using the rename operation of the underlying OS. For
|
||||
cross-device moving, lf falls back to copying and then deletes the
|
||||
original files if there are no errors. Operation errors are shown in the
|
||||
message line as well as the log file and they do not preemptively finish
|
||||
the corresponding file operation.
|
||||
message line as well as the log file and they do not prematurely
|
||||
terminate the corresponding file operation.
|
||||
|
||||
File operations can be performed on the currently selected file or on
|
||||
multiple files by selecting them first. When you copy a file, lf doesn't
|
||||
@@ -1859,14 +1897,14 @@ zero, then the keys are read until there is only a single match. The
|
||||
default values of these two options are set to jump to the first file
|
||||
with the given initial.
|
||||
|
||||
Some options effect both searching and finding. You can disable wrapscan
|
||||
Some options affect both searching and finding. You can disable wrapscan
|
||||
option to prevent searches from being wrapped around at the end of the
|
||||
file list. You can disable ignorecase option to match cases in the
|
||||
pattern and the filename. This option is already automatically
|
||||
overridden if the pattern contains upper-case characters. You can
|
||||
disable smartcase option to disable this behavior. Two similar options
|
||||
ignoredia and smartdia are provided to control matching diacritics in
|
||||
Latin letters.
|
||||
overridden if the pattern contains uppercase characters. You can disable
|
||||
smartcase option to disable this behavior. Two similar options ignoredia
|
||||
and smartdia are provided to control matching diacritics in Latin
|
||||
letters.
|
||||
|
||||
OPENING FILES
|
||||
|
||||
@@ -1881,7 +1919,7 @@ It is possible to use different command types:
|
||||
|
||||
cmd open &xdg-open $f
|
||||
|
||||
You may want to use either file extensions or mime types from file
|
||||
You may want to use either file extensions or MIME types from file
|
||||
command:
|
||||
|
||||
cmd open ${{
|
||||
@@ -1923,12 +1961,12 @@ PREVIEWING FILES
|
||||
lf previews files on the preview pane by printing the file until the end
|
||||
or until the preview pane is filled. This output can be enhanced by
|
||||
providing a custom preview script for filtering. This can be used to
|
||||
highlight source codes, list contents of archive files or view PDF or
|
||||
highlight source code, list contents of archive files or view PDF or
|
||||
image files to name a few. For coloring lf recognizes ANSI escape codes.
|
||||
|
||||
To use this feature, you need to set the value of previewer option to
|
||||
the path of an executable file. Five arguments are passed to the file,
|
||||
(1) current file name, (2) width, (3) height, (4) horizontal position,
|
||||
(1) current filename, (2) width, (3) height, (4) horizontal position,
|
||||
and (5) vertical position of preview pane respectively. The output of
|
||||
the execution is printed in the preview pane. You may also want to use
|
||||
the same script in your pager mapping as well:
|
||||
@@ -1946,7 +1984,7 @@ still be displayed in the statusline below:
|
||||
Since this script is called for each file selection change it needs to
|
||||
be as efficient as possible and this responsibility is left to the user.
|
||||
You may use file extensions to determine the type of file more
|
||||
efficiently compared to obtaining mime types from file command.
|
||||
efficiently compared to obtaining MIME types from file command.
|
||||
Extensions can then be used to match cleanly within a conditional:
|
||||
|
||||
#!/bin/sh
|
||||
@@ -2094,7 +2132,7 @@ environment variables possibly by overwriting its previous values.
|
||||
Colors are set in the following order:
|
||||
|
||||
1. default
|
||||
2. LSCOLORS (Mac/BSD ls)
|
||||
2. LSCOLORS (macOS/BSD ls)
|
||||
3. LS_COLORS (GNU ls)
|
||||
4. LF_COLORS (lf specific)
|
||||
5. colors file (lf specific)
|
||||
@@ -2226,7 +2264,7 @@ escaping newlines with backslashes as follows:
|
||||
"
|
||||
|
||||
The ln entry supports the special value target, which will use the link
|
||||
target to select a style. File name rules will still apply based on the
|
||||
target to select a style. Filename rules will still apply based on the
|
||||
link's name -- this mirrors GNU's ls and dircolors behavior. Having such
|
||||
a long variable definition in a shell configuration file might be
|
||||
undesirable. You may instead use the colors file (refer to the
|
||||
@@ -2239,19 +2277,17 @@ ICONS
|
||||
|
||||
Icons are configured using LF_ICONS environment variable or an icons
|
||||
file (refer to the CONFIGURATION section). The variable uses the same
|
||||
syntax as LS_COLORS/LF_COLORS. Instead of colors, you should put a
|
||||
single characters as values of entries. The ln entry supports the
|
||||
special value target, which will use the link target to select a icon.
|
||||
File name rules will still apply based on the link's name -- this
|
||||
mirrors GNU's ls and dircolors behavior. The icons file (refer to the
|
||||
CONFIGURATION section) should consist of whitespace-separated arrays
|
||||
with a # character to start comments until the end of the line. Each
|
||||
line should contain 1-3 columns, first column is filetype or filename
|
||||
pattern, second column is the icon, third column is an optional icon
|
||||
color. If there is only one column, means to disable rule for this
|
||||
filetype or pattern. Do not forget to add set icons true to your lfrc to
|
||||
see the icons. Default values are as follows given with their matching
|
||||
order in lf:
|
||||
syntax as LS_COLORS/LF_COLORS. Instead of colors, you should use single
|
||||
characters or symbols as values. The ln entry supports the special value
|
||||
target, which will use the link target to select a icon. Filename rules
|
||||
will still apply based on the link's name -- this mirrors GNU's ls and
|
||||
dircolors behavior. The icons file (refer to the CONFIGURATION section)
|
||||
should consist of whitespace-separated arrays with a # character to
|
||||
start comments until the end of the line. Each line should contain 1-3
|
||||
columns: a file type or file name pattern, the icon, and an optional
|
||||
icon color. Using only one column disables all rules for that type or
|
||||
name. Do not forget to add set icons true to your lfrc to see the icons.
|
||||
Default values are listed below in the order lf matches them:
|
||||
|
||||
ln l
|
||||
or l
|
||||
|
||||
@@ -22,8 +22,8 @@ map i $less %f%
|
||||
# change the shell used in default shell keybinding
|
||||
map w $powershell
|
||||
|
||||
# change 'doc' command to use a different pager
|
||||
cmd doc $lf -doc | less
|
||||
# change 'help' command to use a different pager
|
||||
cmd help $lf -doc | less
|
||||
|
||||
# leave some space at the top and the bottom of the screen
|
||||
set scrolloff 10
|
||||
|
||||
@@ -21,8 +21,7 @@ cmd open &&$Env:OPENER.Trim('"', ' ') "$Env:f"
|
||||
map e $&$Env:EDITOR "$Env:f"
|
||||
map i !&$Env:PAGER "$Env:f"
|
||||
map w $&$Env:SHELL
|
||||
cmd doc !&$Env:lf -doc | &$Env:PAGER
|
||||
map <f-1> doc
|
||||
cmd help !&$Env:lf -doc | &$Env:PAGER
|
||||
cmd maps !&$Env:lf -remote "query $Env:id maps" | &$Env:PAGER
|
||||
cmd nmaps !&$Env:lf -remote "query $Env:id nmaps" | &$Env:PAGER
|
||||
cmd vmaps !&$Env:lf -remote "query $Env:id vmaps" | &$Env:PAGER
|
||||
|
||||
@@ -64,8 +64,6 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
err = applyBoolOpt(&gOpts.anchorfind, e)
|
||||
case "autoquit", "noautoquit", "autoquit!":
|
||||
err = applyBoolOpt(&gOpts.autoquit, e)
|
||||
case "dircache", "nodircache", "dircache!":
|
||||
err = applyBoolOpt(&gOpts.dircache, e)
|
||||
case "dircounts", "nodircounts", "dircounts!":
|
||||
err = applyBoolOpt(&gOpts.dircounts, e)
|
||||
if err == nil {
|
||||
@@ -92,18 +90,9 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
err = applyBoolOpt(&gOpts.drawbox, e)
|
||||
if err == nil {
|
||||
app.ui.renew()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
app.nav.height = app.ui.wins[0].h
|
||||
clear(app.nav.regCache)
|
||||
}
|
||||
clear(app.nav.regCache)
|
||||
app.ui.loadFile(app, true)
|
||||
}
|
||||
// DEPRECATED: remove after r37 is released
|
||||
case "globfilter", "noglobfilter", "globfilter!":
|
||||
app.ui.echoerr("option 'globfilter' is deprecated, use 'filtermethod' instead")
|
||||
// DEPRECATED: remove after r37 is released
|
||||
case "globsearch", "noglobsearch", "globsearch!":
|
||||
app.ui.echoerr("option 'globsearch' is deprecated, use 'searchmethod' instead")
|
||||
case "hidden", "nohidden", "hidden!":
|
||||
err = applyBoolOpt(&gOpts.hidden, e)
|
||||
if err == nil {
|
||||
@@ -154,10 +143,8 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
err = errors.New("preview: 'ratios' should consist of at least two numbers before enabling 'preview'")
|
||||
}
|
||||
if err == nil {
|
||||
if gOpts.sixel {
|
||||
app.ui.sxScreen.forceClear = true
|
||||
}
|
||||
gOpts.preview = preview
|
||||
app.ui.sxScreen.forceClear = true
|
||||
app.ui.loadFile(app, true)
|
||||
}
|
||||
case "relativenumber", "norelativenumber", "relativenumber!":
|
||||
@@ -172,11 +159,9 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
err = applyBoolOpt(&gOpts.roundbox, e)
|
||||
case "showbinds", "noshowbinds", "showbinds!":
|
||||
err = applyBoolOpt(&gOpts.showbinds, e)
|
||||
// DEPRECATED: remove after r38 is released
|
||||
case "sixel", "nosixel", "sixel!":
|
||||
err = applyBoolOpt(&gOpts.sixel, e)
|
||||
clear(app.nav.regCache)
|
||||
app.ui.sxScreen.forceClear = true
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.echoerr("option 'sixel' has been removed as it is now enabled by default")
|
||||
case "smartcase", "nosmartcase", "smartcase!":
|
||||
err = applyBoolOpt(&gOpts.smartcase, e)
|
||||
if err == nil {
|
||||
@@ -291,17 +276,12 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
gOpts.infotimefmtnew = e.val
|
||||
case "infotimefmtold":
|
||||
gOpts.infotimefmtold = e.val
|
||||
case "locale":
|
||||
localeStr := e.val
|
||||
if localeStr != localeStrDisable {
|
||||
if _, err = getLocaleTag(localeStr); err != nil {
|
||||
app.ui.echoerrf("locale: %s", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
gOpts.locale = localeStr
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
case "menufmt":
|
||||
gOpts.menufmt = e.val
|
||||
case "menuheaderfmt":
|
||||
gOpts.menuheaderfmt = e.val
|
||||
case "menuselectfmt":
|
||||
gOpts.menuselectfmt = e.val
|
||||
case "numberfmt":
|
||||
gOpts.numberfmt = e.val
|
||||
case "period":
|
||||
@@ -361,9 +341,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
}
|
||||
gOpts.ratios = rats
|
||||
app.ui.wins = getWins(app.ui.screen)
|
||||
if gOpts.sixel {
|
||||
clear(app.nav.regCache)
|
||||
}
|
||||
clear(app.nav.regCache)
|
||||
app.ui.loadFile(app, true)
|
||||
case "rulerfmt":
|
||||
gOpts.rulerfmt = e.val
|
||||
@@ -406,6 +384,14 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
gOpts.shellopts = strings.Split(e.val, ":")
|
||||
case "sizeunits":
|
||||
switch e.val {
|
||||
case "binary", "decimal":
|
||||
gOpts.sizeunits = e.val
|
||||
default:
|
||||
app.ui.echoerr("sizeunits: value should either be 'binary' or 'decimal'")
|
||||
return
|
||||
}
|
||||
case "sortby":
|
||||
method := sortMethod(e.val)
|
||||
if !isValidSortMethod(method) {
|
||||
@@ -474,7 +460,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.ui.echo("")
|
||||
}
|
||||
|
||||
func (e *setLocalExpr) eval(app *app, args []string) {
|
||||
@@ -540,17 +526,6 @@ func (e *setLocalExpr) eval(app *app, args []string) {
|
||||
gLocalOpts.sortby[e.path] = method
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
case "locale":
|
||||
localeStr := e.val
|
||||
if localeStr != localeStrDisable {
|
||||
if _, err = getLocaleTag(localeStr); err != nil {
|
||||
app.ui.echoerrf("locale: %s", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
gLocalOpts.locale[e.path] = localeStr
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
default:
|
||||
err = fmt.Errorf("unknown option: %s", e.opt)
|
||||
}
|
||||
@@ -560,7 +535,7 @@ func (e *setLocalExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.ui.echo("")
|
||||
}
|
||||
|
||||
func (e *mapExpr) eval(app *app, args []string) {
|
||||
@@ -571,7 +546,7 @@ func (e *mapExpr) eval(app *app, args []string) {
|
||||
gOpts.nkeys[e.keys] = e.expr
|
||||
gOpts.vkeys[e.keys] = e.expr
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.ui.echo("")
|
||||
}
|
||||
|
||||
func (e *nmapExpr) eval(app *app, args []string) {
|
||||
@@ -580,7 +555,7 @@ func (e *nmapExpr) eval(app *app, args []string) {
|
||||
} else {
|
||||
gOpts.nkeys[e.keys] = e.expr
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.ui.echo("")
|
||||
}
|
||||
|
||||
func (e *vmapExpr) eval(app *app, args []string) {
|
||||
@@ -589,7 +564,7 @@ func (e *vmapExpr) eval(app *app, args []string) {
|
||||
} else {
|
||||
gOpts.vkeys[e.keys] = e.expr
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.ui.echo("")
|
||||
}
|
||||
|
||||
func (e *cmapExpr) eval(app *app, args []string) {
|
||||
@@ -598,7 +573,7 @@ func (e *cmapExpr) eval(app *app, args []string) {
|
||||
} else {
|
||||
gOpts.cmdkeys[e.key] = e.expr
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.ui.echo("")
|
||||
}
|
||||
|
||||
func (e *cmdExpr) eval(app *app, args []string) {
|
||||
@@ -619,7 +594,7 @@ func (e *cmdExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.ui.echo("")
|
||||
}
|
||||
|
||||
func preChdir(app *app) {
|
||||
@@ -636,11 +611,6 @@ func onChdir(app *app) {
|
||||
}
|
||||
|
||||
func onLoad(app *app, files []string) {
|
||||
// prevent infinite loops
|
||||
if !gOpts.dircache {
|
||||
return
|
||||
}
|
||||
|
||||
if cmd, ok := gOpts.cmds["on-load"]; ok {
|
||||
cmd.eval(app, files)
|
||||
}
|
||||
@@ -703,6 +673,7 @@ func splitKeys(s string) (keys []string) {
|
||||
|
||||
func update(app *app) {
|
||||
app.ui.menu = ""
|
||||
app.ui.menuSelect = nil
|
||||
app.menuCompActive = false
|
||||
|
||||
switch {
|
||||
@@ -721,7 +692,6 @@ func update(app *app) {
|
||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||
} else if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case gOpts.incsearch && app.ui.cmdPrefix == "?":
|
||||
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||
@@ -738,7 +708,6 @@ func update(app *app) {
|
||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||
} else if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case gOpts.incfilter && app.ui.cmdPrefix == "filter: ":
|
||||
filter := string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||
@@ -749,7 +718,6 @@ func update(app *app) {
|
||||
app.ui.echoerrf("filter: %s", err)
|
||||
} else if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -774,7 +742,6 @@ func resetIncCmd(app *app) {
|
||||
if dir.ind != app.nav.searchInd {
|
||||
dir.ind = app.nav.searchInd
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
} else if gOpts.incfilter && app.ui.cmdPrefix == "filter: " {
|
||||
dir := app.nav.currDir()
|
||||
@@ -782,7 +749,6 @@ func resetIncCmd(app *app) {
|
||||
app.nav.setFilter(app.nav.prevFilter)
|
||||
if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -791,23 +757,14 @@ func normal(app *app) {
|
||||
resetIncCmd(app)
|
||||
|
||||
app.cmdHistoryInd = 0
|
||||
app.menuCompActive = false
|
||||
|
||||
app.ui.menu = ""
|
||||
app.ui.menuSelect = nil
|
||||
app.menuCompActive = false
|
||||
|
||||
app.ui.cmdAccLeft = nil
|
||||
app.ui.cmdAccRight = nil
|
||||
app.ui.cmdPrefix = ""
|
||||
|
||||
// ensure the mode indicator in `statfmt` is updated properly
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
|
||||
func visual(app *app) {
|
||||
dir := app.nav.currDir()
|
||||
dir.visualAnchor = dir.ind
|
||||
dir.visualWrap = 0
|
||||
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
|
||||
func insert(app *app, arg string) {
|
||||
@@ -827,7 +784,6 @@ func insert(app *app, arg string) {
|
||||
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
|
||||
case 1:
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
default:
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
||||
return
|
||||
@@ -842,7 +798,6 @@ func insert(app *app, arg string) {
|
||||
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
|
||||
} else if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,7 +811,6 @@ func insert(app *app, arg string) {
|
||||
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
|
||||
case 1:
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
default:
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
||||
return
|
||||
@@ -871,7 +825,6 @@ func insert(app *app, arg string) {
|
||||
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
|
||||
} else if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,7 +839,6 @@ func insert(app *app, arg string) {
|
||||
}
|
||||
app.nav.unselect()
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case strings.HasPrefix(app.ui.cmdPrefix, "replace"):
|
||||
normal(app)
|
||||
@@ -906,7 +858,6 @@ func insert(app *app, arg string) {
|
||||
}
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case strings.HasPrefix(app.ui.cmdPrefix, "create"):
|
||||
normal(app)
|
||||
@@ -930,7 +881,6 @@ func insert(app *app, arg string) {
|
||||
}
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case app.ui.cmdPrefix == "mark-save: ":
|
||||
normal(app)
|
||||
@@ -951,7 +901,6 @@ func insert(app *app, arg string) {
|
||||
return
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case app.ui.cmdPrefix == "mark-load: ":
|
||||
normal(app)
|
||||
|
||||
@@ -976,7 +925,6 @@ func insert(app *app, arg string) {
|
||||
return
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
|
||||
if wd != path {
|
||||
app.nav.marks["'"] = wd
|
||||
@@ -1004,7 +952,6 @@ func insert(app *app, arg string) {
|
||||
return
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case app.ui.cmdPrefix == ":" && len(app.ui.cmdAccLeft) == 0:
|
||||
switch arg {
|
||||
case "!", "$", "%", "&":
|
||||
@@ -1014,6 +961,7 @@ func insert(app *app, arg string) {
|
||||
fallthrough
|
||||
default:
|
||||
app.ui.menu = ""
|
||||
app.ui.menuSelect = nil
|
||||
app.menuCompActive = false
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
||||
}
|
||||
@@ -1031,7 +979,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.up(e.count) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "half-up":
|
||||
if !app.nav.init {
|
||||
@@ -1039,7 +986,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.up(e.count * app.nav.height / 2) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "page-up":
|
||||
if !app.nav.init {
|
||||
@@ -1047,7 +993,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.up(e.count * app.nav.height) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "scroll-up":
|
||||
if !app.nav.init {
|
||||
@@ -1055,7 +1000,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.scrollUp(e.count) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "down":
|
||||
if !app.nav.init {
|
||||
@@ -1063,7 +1007,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.down(e.count) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "half-down":
|
||||
if !app.nav.init {
|
||||
@@ -1071,7 +1014,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.down(e.count * app.nav.height / 2) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "page-down":
|
||||
if !app.nav.init {
|
||||
@@ -1079,7 +1021,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.down(e.count * app.nav.height) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "scroll-down":
|
||||
if !app.nav.init {
|
||||
@@ -1087,7 +1028,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.scrollDown(e.count) {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "updir":
|
||||
if !app.nav.init {
|
||||
@@ -1102,7 +1042,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
case "open":
|
||||
@@ -1124,22 +1063,18 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if gSelectionPath != "" || gPrintSelection {
|
||||
app.selectionOut, _ = app.nav.currFileOrSelections()
|
||||
app.quitChan <- struct{}{}
|
||||
return
|
||||
}
|
||||
|
||||
if gSelectionPath != "" || gPrintSelection {
|
||||
app.selectionOut, _ = app.nav.currFileOrSelections()
|
||||
app.quitChan <- struct{}{}
|
||||
return
|
||||
}
|
||||
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
|
||||
if cmd, ok := gOpts.cmds["open"]; ok {
|
||||
cmd.eval(app, e.args)
|
||||
if cmd, ok := gOpts.cmds["open"]; ok {
|
||||
cmd.eval(app, e.args)
|
||||
}
|
||||
}
|
||||
case "jump-next":
|
||||
resetIncCmd(app)
|
||||
@@ -1148,7 +1083,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.cdJumpListNext()
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
case "jump-prev":
|
||||
@@ -1158,7 +1092,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.cdJumpListPrev()
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
case "top":
|
||||
@@ -1173,7 +1106,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "bottom":
|
||||
if !app.nav.init {
|
||||
@@ -1189,7 +1121,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "high":
|
||||
if !app.nav.init {
|
||||
@@ -1197,7 +1128,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.high() {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "middle":
|
||||
if !app.nav.init {
|
||||
@@ -1205,7 +1135,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.middle() {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "low":
|
||||
if !app.nav.init {
|
||||
@@ -1213,7 +1142,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if app.nav.low() {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "toggle":
|
||||
if !app.nav.init {
|
||||
@@ -1287,7 +1215,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "cut":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1309,7 +1236,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "paste":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1322,7 +1248,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "clear":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1342,7 +1267,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "sync":
|
||||
if err := app.nav.sync(); err != nil {
|
||||
app.ui.echoerrf("sync: %s", err)
|
||||
@@ -1358,13 +1282,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
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.sxScreen.forceClear = true
|
||||
app.ui.loadFile(app, true)
|
||||
onRedraw(app)
|
||||
case "load":
|
||||
@@ -1381,7 +1302,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("reload: %s", err)
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "delete":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1416,7 +1336,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.cmdPrefix = "delete " + strconv.Itoa(len(list)) + " items? [y/N] "
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "rename":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1452,42 +1371,36 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.cmdAccRight = append(app.ui.cmdAccRight, []rune(extension)...)
|
||||
}
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "read":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = ":"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "shell":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "$"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "shell-pipe":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "%"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "shell-wait":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "!"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "shell-async":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "&"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "find":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
@@ -1495,7 +1408,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "find: "
|
||||
app.nav.findBack = false
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "find-back":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
@@ -1503,7 +1415,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "find-back: "
|
||||
app.nav.findBack = true
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "find-next":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1519,7 +1430,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "find-prev":
|
||||
if !app.nav.init {
|
||||
@@ -1536,7 +1446,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "search":
|
||||
if !app.nav.init {
|
||||
@@ -1551,7 +1460,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.searchInd = dir.ind
|
||||
app.nav.searchPos = dir.pos
|
||||
app.nav.searchBack = false
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "search-back":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1565,7 +1473,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.searchInd = dir.ind
|
||||
app.nav.searchPos = dir.pos
|
||||
app.nav.searchBack = true
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "search-next":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1576,14 +1483,12 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||
} else if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
} else {
|
||||
if moved, err := app.nav.searchNext(); err != nil {
|
||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||
} else if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1597,14 +1502,12 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||
} else if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
} else {
|
||||
if moved, err := app.nav.searchPrev(); err != nil {
|
||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||
} else if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1624,7 +1527,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
} else {
|
||||
app.ui.cmdAccLeft = []rune(strings.Join(e.args, " "))
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "setfilter":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1634,7 +1536,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("filter: %s", err)
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "mark-save":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
@@ -1740,7 +1641,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
|
||||
if wd != path {
|
||||
app.nav.marks["'"] = wd
|
||||
@@ -1780,7 +1680,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
|
||||
if wd != path {
|
||||
app.nav.marks["'"] = wd
|
||||
@@ -1793,7 +1692,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
app.readFile(replaceTilde(e.args[0]))
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "push":
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("push: requires an argument")
|
||||
@@ -1859,7 +1757,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("calcdirsize: %s", err)
|
||||
return
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
case "clearmaps":
|
||||
@@ -1885,7 +1782,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
visual(app)
|
||||
dir := app.nav.currDir()
|
||||
dir.visualAnchor = dir.ind
|
||||
dir.visualWrap = 0
|
||||
case "visual-accept":
|
||||
if !app.nav.init {
|
||||
return
|
||||
@@ -1949,6 +1848,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.menuComplete(-1)
|
||||
case "cmd-menu-accept":
|
||||
app.ui.menu = ""
|
||||
app.ui.menuSelect = nil
|
||||
app.menuCompActive = false
|
||||
case "cmd-enter":
|
||||
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
|
||||
@@ -1957,6 +1857,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
|
||||
app.ui.menu = ""
|
||||
app.ui.menuSelect = nil
|
||||
app.menuCompActive = false
|
||||
|
||||
app.ui.cmdAccLeft = nil
|
||||
@@ -2010,7 +1911,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||
} else if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "?":
|
||||
dir := app.nav.currDir()
|
||||
@@ -2026,7 +1926,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||
} else if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "filter: ":
|
||||
log.Printf("filter: %s", s)
|
||||
@@ -2035,14 +1934,12 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("filter: %s", err)
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "find: ":
|
||||
app.ui.cmdPrefix = ""
|
||||
if moved, found := app.nav.findNext(); !found {
|
||||
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
|
||||
} else if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "find-back: ":
|
||||
app.ui.cmdPrefix = ""
|
||||
@@ -2050,7 +1947,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
|
||||
} else if moved {
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "rename: ":
|
||||
app.ui.cmdPrefix = ""
|
||||
@@ -2107,7 +2003,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
default:
|
||||
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
||||
}
|
||||
@@ -2356,6 +2251,55 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
cmd.eval(app, e.args)
|
||||
}
|
||||
|
||||
// commands that run silently or write messages shouldn't clear existing messages
|
||||
keepMsgCmds := []string{
|
||||
"addcustominfo",
|
||||
"draw",
|
||||
"echo",
|
||||
"echoerr",
|
||||
"echomsg",
|
||||
"load",
|
||||
"push",
|
||||
"redraw",
|
||||
"sync",
|
||||
"tty-write",
|
||||
"cmd-insert",
|
||||
"cmd-escape",
|
||||
"cmd-complete",
|
||||
"cmd-menu-complete",
|
||||
"cmd-menu-complete-back",
|
||||
"cmd-menu-accept",
|
||||
"cmd-enter",
|
||||
"cmd-interrupt",
|
||||
"cmd-history-next",
|
||||
"cmd-history-prev",
|
||||
"cmd-left",
|
||||
"cmd-right",
|
||||
"cmd-home",
|
||||
"cmd-end",
|
||||
"cmd-delete",
|
||||
"cmd-delete-back",
|
||||
"cmd-delete-home",
|
||||
"cmd-delete-end",
|
||||
"cmd-delete-unix-word",
|
||||
"cmd-yank",
|
||||
"cmd-transpose",
|
||||
"cmd-transpose-word",
|
||||
"cmd-word",
|
||||
"cmd-word-back",
|
||||
"cmd-delete-word",
|
||||
"cmd-delete-word-back",
|
||||
"cmd-capitalize-word",
|
||||
"cmd-uppercase-word",
|
||||
"cmd-lowercase-word",
|
||||
"on-focus-gained",
|
||||
"on-focus-lost",
|
||||
"on-init",
|
||||
}
|
||||
if !slices.Contains(keepMsgCmds, e.name) {
|
||||
app.ui.echo("")
|
||||
}
|
||||
}
|
||||
|
||||
func (e *execExpr) eval(app *app, args []string) {
|
||||
|
||||
@@ -3,18 +3,17 @@ module github.com/gokcehan/lf
|
||||
go 1.23.0
|
||||
|
||||
require (
|
||||
github.com/Xuanwo/go-locale v1.1.3
|
||||
github.com/djherbis/times v1.6.0
|
||||
github.com/fsnotify/fsnotify v1.9.0
|
||||
github.com/gdamore/tcell/v2 v2.8.1
|
||||
github.com/gdamore/tcell/v2 v2.9.0
|
||||
github.com/mattn/go-runewidth v0.0.16
|
||||
golang.org/x/sys v0.35.0
|
||||
golang.org/x/term v0.34.0
|
||||
golang.org/x/text v0.28.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gdamore/encoding v1.0.1 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
golang.org/x/text v0.28.0 // indirect
|
||||
)
|
||||
@@ -1,48 +1,30 @@
|
||||
github.com/Xuanwo/go-locale v1.1.3 h1:EWZZJJt5rqPHHbqPRH1zFCn5D7xHjjebODctA4aUO3A=
|
||||
github.com/Xuanwo/go-locale v1.1.3/go.mod h1:REn+F/c+AtGSWYACBSYZgl23AP+0lfQC+SEFPN+hj30=
|
||||
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
|
||||
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
|
||||
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
|
||||
github.com/gdamore/tcell/v2 v2.8.1 h1:KPNxyqclpWpWQlPLx6Xui1pMk8S+7+R37h3g07997NU=
|
||||
github.com/gdamore/tcell/v2 v2.8.1/go.mod h1:bj8ori1BG3OYMjmb3IklZVWfZUJ1UBQt9JXrOCOhGWw=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/gdamore/tcell/v2 v2.9.0 h1:N6t+eqK7/xwtRPwxzs1PXeRWnm0H9l02CrgJ7DLn1ys=
|
||||
github.com/gdamore/tcell/v2 v2.9.0/go.mod h1:8/ZoqM9rxzYphT9tH/9LnunhV9oPBqwS8WHGYm5nrmo=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -50,39 +32,22 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
|
||||
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -1,13 +1,13 @@
|
||||
.\" Automatically generated by Pandoc 3.7.0.2
|
||||
.\"
|
||||
.TH "LF" "1" "2025\-08\-25" "r37" "DOCUMENTATION"
|
||||
.TH "LF" "1" "2025\-09\-19" "r38" "DOCUMENTATION"
|
||||
.SH NAME
|
||||
lf \- terminal file manager
|
||||
.SH SYNOPSIS
|
||||
\f[B]lf\f[R] [\f[B]\-command\f[R] \f[I]command\f[R]] [\f[B]\-config\f[R]
|
||||
\f[I]path\f[R]] [\f[B]\-cpuprofile\f[R] \f[I]path\f[R]]
|
||||
[\f[B]\-doc\f[R]] [\f[B]\-last\-dir\-path\f[R] \f[I]path\f[R]]
|
||||
[\f[B]\-log path\f[R]] [\f[B]\-memprofile\f[R] \f[I]path\f[R]]
|
||||
[\f[B]\-log\f[R] \f[I]path\f[R]] [\f[B]\-memprofile\f[R] \f[I]path\f[R]]
|
||||
[\f[B]\-print\-last\-dir\f[R]] [\f[B]\-print\-selection\f[R]]
|
||||
[\f[B]\-remote\f[R] \f[I]command\f[R]] [\f[B]\-selection\-path\f[R]
|
||||
\f[I]path\f[R]] [\f[B]\-server\f[R]] [\f[B]\-single\f[R]]
|
||||
@@ -24,7 +24,7 @@ This documentation can either be read from the terminal using
|
||||
\f[CR]lf \-doc\f[R] or online at \c
|
||||
.UR https://github.com/gokcehan/lf/blob/master/doc.md
|
||||
.UE \c
|
||||
\ You can also use the \f[CR]doc\f[R] command (default
|
||||
\ You can also use the \f[CR]help\f[R] command (default
|
||||
\f[CR]<f\-1>\f[R]) inside lf to view the documentation in a pager.
|
||||
A man page with the same content is also available in the repository at
|
||||
\c
|
||||
@@ -160,7 +160,6 @@ cursoractivefmt string (default \(dq\(rs033[7m\(dq)
|
||||
cursorparentfmt string (default \(dq\(rs033[7m\(dq)
|
||||
cursorpreviewfmt string (default \(dq\(rs033[4m\(dq)
|
||||
cutfmt string (default \(dq\(rs033[7;31m\(dq)
|
||||
dircache bool (default true)
|
||||
dircounts bool (default false)
|
||||
dirfirst bool (default true)
|
||||
dironly bool (default false)
|
||||
@@ -183,7 +182,9 @@ incsearch bool (default false)
|
||||
info []string (default \(aq\(aq)
|
||||
infotimefmtnew string (default \(aqJan _2 15:04\(aq)
|
||||
infotimefmtold string (default \(aqJan _2 2006\(aq)
|
||||
locale string (default \(aq\(aq)
|
||||
menufmt string (default \(dq\(rs033[0m\(dq)
|
||||
menuheaderfmt string (default \(dq\(rs033[1m\(dq)
|
||||
menuselectfmt string (default \(dq\(rs033[7m\(dq)
|
||||
mouse bool (default false)
|
||||
number bool (default false)
|
||||
numberfmt string (default \(dq\(rs033[33m\(dq)
|
||||
@@ -205,7 +206,7 @@ shell string (default \(aqsh\(aq for Unix and \(aqcmd\(aq for Win
|
||||
shellflag string (default \(aq\-c\(aq for Unix and \(aq/c\(aq for Windows)
|
||||
shellopts []string (default \(aq\(aq)
|
||||
showbinds bool (default true)
|
||||
sixel bool (default false)
|
||||
sizeunits string (default \(aqbinary\(aq)
|
||||
smartcase bool (default true)
|
||||
smartdia bool (default false)
|
||||
sortby string (default \(aqnatural\(aq)
|
||||
@@ -277,8 +278,8 @@ cmd open &$OPENER \(dq$f\(dq
|
||||
map e $$EDITOR \(dq$f\(dq
|
||||
map i $$PAGER \(dq$f\(dq
|
||||
map w $$SHELL
|
||||
cmd doc $$lf \-doc | $PAGER
|
||||
map <f\-1> doc
|
||||
cmd help $$lf \-doc | $PAGER
|
||||
map <f\-1> help
|
||||
cmd maps $lf \-remote \(dqquery $id maps\(dq | $PAGER
|
||||
cmd nmaps $lf \-remote \(dqquery $id nmaps\(dq | $PAGER
|
||||
cmd vmaps $lf \-remote \(dqquery $id vmaps\(dq | $PAGER
|
||||
@@ -290,8 +291,8 @@ cmd open &%OPENER% %f%
|
||||
map e $%EDITOR% %f%
|
||||
map i !%PAGER% %f%
|
||||
map w $%SHELL%
|
||||
cmd doc !%lf% \-doc | %PAGER%
|
||||
map <f\-1> doc
|
||||
cmd help !%lf% \-doc | %PAGER%
|
||||
map <f\-1> help
|
||||
cmd maps !%lf% \-remote \(dqquery %id% maps\(dq | %PAGER%
|
||||
cmd nmaps !%lf% \-remote \(dqquery %id% nmaps\(dq | %PAGER%
|
||||
cmd vmaps !%lf% \-remote \(dqquery %id% vmaps\(dq | %PAGER%
|
||||
@@ -299,6 +300,11 @@ cmd cmaps !%lf% \-remote \(dqquery %id% cmaps\(dq | %PAGER%
|
||||
cmd cmds !%lf% \-remote \(dqquery %id% cmds\(dq | %PAGER%
|
||||
.EE
|
||||
.PP
|
||||
The defaults for Windows are using \f[CR]cmd\f[R] syntax.
|
||||
A \f[CR]PowerShell\f[R] compatible configuration file can be found at \c
|
||||
.UR https://github.com/gokcehan/lf/blob/master/etc/lfrc.ps1.example
|
||||
.UE \c
|
||||
.PP
|
||||
The following additional keybindings are provided by default:
|
||||
.IP
|
||||
.EX
|
||||
@@ -327,7 +333,7 @@ Left mouse button
|
||||
Click on a file or directory to select it.
|
||||
|
||||
Right mouse button
|
||||
Enter a directory or open a file. Also works on the preview window.
|
||||
Enter a directory or open a file. Also works on the preview pane.
|
||||
|
||||
Scroll wheel
|
||||
Move up or down. If Ctrl is pressed, scroll up or down.
|
||||
@@ -400,9 +406,11 @@ Unix
|
||||
|
||||
Windows
|
||||
%LF_CONFIG_HOME%
|
||||
%XDG_CONFIG_HOME%
|
||||
%APPDATA%
|
||||
|
||||
%LF_DATA_HOME%
|
||||
%XDG_DATA_HOME%
|
||||
%LOCALAPPDATA%
|
||||
.EE
|
||||
.PP
|
||||
@@ -493,14 +501,14 @@ Read a shell command to execute.
|
||||
Read a shell command to execute piping its standard I/O to the bottom
|
||||
statline.
|
||||
.SS shell\-wait (modal) (default \f[CR]!\f[R])
|
||||
Read a shell command to execute and wait for a key press in the end.
|
||||
Read a shell command to execute and wait for a key press at the end.
|
||||
.SS shell\-async (modal) (default \f[CR]&\f[R])
|
||||
Read a shell command to execute asynchronously without standard I/O.
|
||||
.SS find (modal) (default \f[CR]f\f[R]), find\-back (modal) (default \f[CR]F\f[R]), find\-next (default \f[CR];\f[R]), find\-prev (default \f[CR],\f[R])
|
||||
Read key(s) to find the appropriate file name match in the
|
||||
Read key(s) to find the appropriate filename match in the
|
||||
forward/backward direction and jump to the next/previous match.
|
||||
.SS search (default \f[CR]/\f[R]), search\-back (default \f[CR]?\f[R]), search\-next (default \f[CR]n\f[R]), search\-prev (default \f[CR]N\f[R])
|
||||
Read a pattern to search for a file name match in the forward/backward
|
||||
Read a pattern to search for a filename match in the forward/backward
|
||||
direction and jump to the next/previous match.
|
||||
.SS filter (modal), setfilter
|
||||
Command \f[CR]filter\f[R] reads a pattern to filter out and only view
|
||||
@@ -524,7 +532,7 @@ You can define a new tag\-clearing command by combining \f[CR]tag\f[R]
|
||||
with \f[CR]tag\-toggle\f[R] (i.e.
|
||||
\f[CR]cmd tag\-clear :tag; tag\-toggle\f[R]).
|
||||
.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
|
||||
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.
|
||||
@@ -601,7 +609,7 @@ You can go back with \f[CR]cmd\-delete\-back\f[R]
|
||||
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.
|
||||
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.
|
||||
@@ -637,7 +645,7 @@ When at the beginning of a prompt, returns either to Normal mode or to
|
||||
.SS cmd\-delete\-home (default \f[CR]<c\-u>\f[R]), cmd\-delete\-end (default \f[CR]<c\-k>\f[R])
|
||||
Delete everything up to the beginning/end of the line.
|
||||
.SS cmd\-delete\-unix\-word (default \f[CR]<c\-w>\f[R])
|
||||
Delete the previous unix word.
|
||||
Delete the previous Unix word.
|
||||
.SS cmd\-yank (default \f[CR]<c\-y>\f[R])
|
||||
Paste the buffer content containing the last deleted item.
|
||||
.SS cmd\-transpose (default \f[CR]<c\-t>\f[R]), cmd\-transpose\-word (default \f[CR]<a\-t>\f[R])
|
||||
@@ -657,8 +665,8 @@ Character \f[CR]:\f[R] is used as the separator for list options
|
||||
\f[CR][]int\f[R] and \f[CR][]string\f[R].
|
||||
.SS anchorfind (bool) (default true)
|
||||
When this option is enabled, the find command starts matching patterns
|
||||
from the beginning of file names, otherwise, it can match at an
|
||||
arbitrary position.
|
||||
from the beginning of filenames, otherwise, it can match at an arbitrary
|
||||
position.
|
||||
.SS autoquit (bool) (default true)
|
||||
Automatically quit the server when there are no clients left connected.
|
||||
.SS borderfmt (string) (default \f[CR]\(rs033[0m\f[R])
|
||||
@@ -669,14 +677,14 @@ Set the path of a cleaner file.
|
||||
The file should be executable.
|
||||
This file is called if previewing is enabled, the previewer is set, and
|
||||
the previously selected file has its preview cache disabled.
|
||||
The following arguments are passed to the file, (1) current file name,
|
||||
The following arguments are passed to the file, (1) current filename,
|
||||
(2) width, (3) height, (4) horizontal position, (5) vertical position of
|
||||
preview pane and (6) next file name to be previewed respectively.
|
||||
preview pane and (6) next filename to be previewed respectively.
|
||||
Preview cleaning is disabled when the value of this option is left
|
||||
empty.
|
||||
.SS copyfmt (string) (default \f[CR]\(rs033[7;33m\f[R])
|
||||
Format string of the indicator for files to be copied.
|
||||
.SS cursoractivefmt (string) (default \f[CR]\(rs033[7m\f[R]), cursorparentfmt string (default \f[CR]\(rs033[7m\f[R]), cursorpreviewfmt string (default \f[CR]\(rs033[4m\f[R])
|
||||
.SS cursoractivefmt (string) (default \f[CR]\(rs033[7m\f[R]), cursorparentfmt (string) (default \f[CR]\(rs033[7m\f[R]), cursorpreviewfmt (string) (default \f[CR]\(rs033[4m\f[R])
|
||||
Format strings for highlighting the cursor.
|
||||
\f[CR]cursoractivefmt\f[R] applies in the current directory pane,
|
||||
\f[CR]cursorparentfmt\f[R] applies in panes that show parents of the
|
||||
@@ -699,8 +707,6 @@ For example, \f[CR]\(rs033[4m%s\(rs033[0m\f[R] has the same effect as
|
||||
\f[CR]\(rs033[4m\f[R].
|
||||
.SS cutfmt (string) (default \f[CR]\(rs033[7;31m\f[R])
|
||||
Format string of the indicator for files to be cut.
|
||||
.SS dircache (bool) (default true)
|
||||
Cache directory contents.
|
||||
.SS dircounts (bool) (default false)
|
||||
When this option is enabled, directory sizes show the number of items
|
||||
inside instead of the total size of the directory, which needs to be
|
||||
@@ -725,12 +731,12 @@ This allows custom previews for directories.
|
||||
.SS drawbox (bool) (default false)
|
||||
Draw boxes around panes with box drawing characters.
|
||||
.SS dupfilefmt (string) (default \f[CR]%f.\(ti%n\(ti\f[R])
|
||||
Format string of file name when creating duplicate files.
|
||||
Format string of filename when creating duplicate files.
|
||||
With the default format, copying a file \f[CR]abc.txt\f[R] to the same
|
||||
directory will result in a duplicate file called
|
||||
\f[CR]abc.txt.\(ti1\(ti\f[R].
|
||||
Special expansions are provided, \f[CR]%f\f[R] as the file name,
|
||||
\f[CR]%b\f[R] for the basename (file name without extension),
|
||||
\f[CR]%b\f[R] for the base name (file name without extension),
|
||||
\f[CR]%e\f[R] as the extension (including the dot) and \f[CR]%n\f[R] as
|
||||
the number of duplicates.
|
||||
.SS errorfmt (string) (default \f[CR]\(rs033[7;31;47m\f[R])
|
||||
@@ -747,8 +753,8 @@ File separator used in environment variables \f[CR]fs\f[R],
|
||||
.SS filtermethod (string) (default \f[CR]text\f[R])
|
||||
How filter command patterns are treated.
|
||||
Currently supported methods are \f[CR]text\f[R] (i.e.
|
||||
string literals), \f[CR]glob\f[R] (i.e shell globs) and \f[CR]regex\f[R]
|
||||
(i.e.
|
||||
string literals), \f[CR]glob\f[R] (i.e.
|
||||
shell globs) and \f[CR]regex\f[R] (i.e.
|
||||
regular expressions).
|
||||
See \f[CR]SEARCHING FILES\f[R] for more details.
|
||||
.SS findlen (int) (default 1)
|
||||
@@ -796,12 +802,21 @@ Jump to the first match after each keystroke during searching.
|
||||
.SS info ([]string) (default \(ga\(ga)
|
||||
A list of information that is shown for directory items at the right
|
||||
side of the pane.
|
||||
Currently supported information types are \f[CR]size\f[R],
|
||||
\f[CR]time\f[R], \f[CR]atime\f[R], \f[CR]btime\f[R], \f[CR]ctime\f[R],
|
||||
\f[CR]perm\f[R], \f[CR]user\f[R], \f[CR]group\f[R] and
|
||||
\f[CR]custom\f[R].
|
||||
The \f[CR]custom\f[R] type is empty by default and can be updated using
|
||||
the \f[CR]addcustominfo\f[R] command.
|
||||
.PP
|
||||
The following information types are supported:
|
||||
.IP
|
||||
.EX
|
||||
perm file permission
|
||||
user user name
|
||||
group group name
|
||||
size file size
|
||||
time time of last data modification
|
||||
atime time of last access
|
||||
btime time of file birth
|
||||
ctime time of last status (inode) change
|
||||
custom property defined via \(gaaddcustominfo\(ga (empty by default)
|
||||
.EE
|
||||
.PP
|
||||
Information is only shown when the pane width is more than twice the
|
||||
width of information.
|
||||
.SS infotimefmtnew (string) (default \f[CR]Jan _2 15:04\f[R])
|
||||
@@ -810,14 +825,12 @@ this year.
|
||||
.SS infotimefmtold (string) (default \f[CR]Jan _2 2006\f[R])
|
||||
Format string of the file time shown in the info column when it
|
||||
doesn\(aqt match this year.
|
||||
.SS locale (string) (default \(ga\(ga)
|
||||
An IETF BCP 47 language tag (e.g.
|
||||
\f[CR]zh\-CN\f[R]) for specifying the locale used when using sort type
|
||||
\f[CR]natural\f[R] and \f[CR]name\f[R].
|
||||
An empty string means disable locale ordering, and the special value
|
||||
\f[CR]*\f[R] is used to indicate reading the locale setting from the
|
||||
system environment.
|
||||
This feature is currently experimental.
|
||||
.SS menufmt (string) (default \f[CR]\(rs033[0m\f[R])
|
||||
Format string of the menu.
|
||||
.SS menuheaderfmt (string) (default \f[CR]\(rs033[1m\f[R])
|
||||
Format string of the header row in the menu.
|
||||
.SS menuselectfmt (string) (default \f[CR]\(rs033[7m\f[R])
|
||||
Format string of the currently selected item in the menu.
|
||||
.SS mouse (bool) (default false)
|
||||
Send mouse events as input.
|
||||
.SS number (bool) (default false)
|
||||
@@ -853,7 +866,7 @@ considered binary files and displayed as \f[CR]binary\f[R].
|
||||
Set the path of a previewer file to filter the content of regular files
|
||||
for previewing.
|
||||
The file should be executable.
|
||||
The following arguments are passed to the file, (1) current file name,
|
||||
The following arguments are passed to the file, (1) current filename,
|
||||
(2) width, (3) height, (4) horizontal position, and (5) vertical
|
||||
position of preview pane respectively.
|
||||
SIGPIPE signal is sent when enough lines are read.
|
||||
@@ -865,12 +878,19 @@ Preview filtering is disabled and files are displayed as they are when
|
||||
the value of this option is left empty.
|
||||
.SS promptfmt (string) (default \f[CR]\(rs033[32;1m%u\(at%h\(rs033[0m:\(rs033[34;1m%d\(rs033[0m\(rs033[1m%f\(rs033[0m\f[R])
|
||||
Format string of the prompt shown in the top line.
|
||||
Special expansions are provided, \f[CR]%u\f[R] as the user name,
|
||||
\f[CR]%h\f[R] as the hostname, \f[CR]%w\f[R] as the working directory,
|
||||
\f[CR]%d\f[R] as the working directory with a trailing path separator,
|
||||
\f[CR]%f\f[R] as the file name, and \f[CR]%F\f[R] as the current filter.
|
||||
\f[CR]%S\f[R] may be used once and will provide a spacer so that the
|
||||
following parts are right aligned on the screen.
|
||||
.PP
|
||||
The following special expansions are supported:
|
||||
.IP
|
||||
.EX
|
||||
%f file name
|
||||
%h host name
|
||||
%u user name
|
||||
%w working directory
|
||||
%d working directory (with trailing path separator)
|
||||
%F current filter
|
||||
%S spacer to right\-align the following parts (can be used once)
|
||||
.EE
|
||||
.PP
|
||||
The home folder is shown as \f[CR]\(ti\f[R] in the working directory
|
||||
expansion.
|
||||
Directory names are automatically shortened to a single character
|
||||
@@ -892,16 +912,24 @@ Draw rounded outer corners when the \f[CR]drawbox\f[R] option is
|
||||
enabled.
|
||||
.SS rulerfmt (string) (default \f[CR] %a| %p| \(rs033[7;31m %m \(rs033[0m| \(rs033[7;33m %c \(rs033[0m| \(rs033[7;35m %s \(rs033[0m| \(rs033[7;36m %v \(rs033[0m| \(rs033[7;34m %f \(rs033[0m| %i/%t\f[R])
|
||||
Format string of the ruler shown in the bottom right corner.
|
||||
Special expansions are provided, \f[CR]%a\f[R] as the pressed keys,
|
||||
\f[CR]%p\f[R] as the progress of file operations, \f[CR]%m\f[R] as the
|
||||
number of files to be cut (moved), \f[CR]%c\f[R] as the number of files
|
||||
to be copied, \f[CR]%s\f[R] as the number of selected files,
|
||||
\f[CR]%v\f[R] as the number of visually selected files, \f[CR]%f\f[R] as
|
||||
the filter, \f[CR]%i\f[R] as the position of the cursor, \f[CR]%t\f[R]
|
||||
as the number of files shown in the current directory, \f[CR]%h\f[R] as
|
||||
the number of files hidden in the current directory, \f[CR]%P\f[R] as
|
||||
the scroll percentage, and \f[CR]%d\f[R] as the amount of free disk
|
||||
space remaining.
|
||||
.PP
|
||||
The following special expansions are supported:
|
||||
.IP
|
||||
.EX
|
||||
%a pressed keys
|
||||
%p progress of file operations
|
||||
%m number of files to be cut (moved)
|
||||
%c number of files to be copied
|
||||
%s number of selected files
|
||||
%v number of visually selected files
|
||||
%t number of shown files in the current directory
|
||||
%h number of hidden files in the current directory
|
||||
%f current filter
|
||||
%i cursor position
|
||||
%P scroll percentage
|
||||
%d amount of free disk space
|
||||
.EE
|
||||
.PP
|
||||
Additional expansions are provided for environment variables exported by
|
||||
lf, in the form \f[CR]%{lf_<name>}\f[R] (e.g.
|
||||
\f[CR]%{lf_selmode}\f[R]).
|
||||
@@ -916,14 +944,14 @@ discarded and not shown.
|
||||
Minimum number of offset lines shown at all times at the top and bottom
|
||||
of the screen when scrolling.
|
||||
The current line is kept in the middle when this option is set to a
|
||||
large value that is bigger than the half of number of lines.
|
||||
large value that is bigger than half the number of lines.
|
||||
A smaller offset can be used when the current file is close to the
|
||||
beginning or end of the list to show the maximum number of items.
|
||||
.SS searchmethod (string) default \f[CR]text\f[R])
|
||||
.SS searchmethod (string) (default \f[CR]text\f[R])
|
||||
How search command patterns are treated.
|
||||
Currently supported methods are \f[CR]text\f[R] (i.e.
|
||||
string literals), \f[CR]glob\f[R] (i.e shell globs) and \f[CR]regex\f[R]
|
||||
(i.e.
|
||||
string literals), \f[CR]glob\f[R] (i.e.
|
||||
shell globs) and \f[CR]regex\f[R] (i.e.
|
||||
regular expressions).
|
||||
See \f[CR]SEARCHING FILES\f[R] for more details.
|
||||
.SS selectfmt (string) (default \f[CR]\(rs033[7;35m\f[R])
|
||||
@@ -944,8 +972,10 @@ Command line flag used to pass shell commands.
|
||||
List of shell options to pass to the shell executable.
|
||||
.SS showbinds (bool) (default true)
|
||||
Show bindings associated with pressed keys.
|
||||
.SS sixel (bool) (default false)
|
||||
Render sixel images in preview.
|
||||
.SS sizeunits (string) (default \f[CR]binary\f[R])
|
||||
Determines whether file sizes are displayed using binary units
|
||||
(\f[CR]1K\f[R] is 1024 bytes) or decimal units (\f[CR]1K\f[R] is 1000
|
||||
bytes).
|
||||
.SS smartcase (bool) (default true)
|
||||
Override \f[CR]ignorecase\f[R] option when the pattern contains an
|
||||
uppercase character.
|
||||
@@ -956,41 +986,41 @@ character with diacritic.
|
||||
This option has no effect when \f[CR]ignoredia\f[R] is disabled.
|
||||
.SS sortby (string) (default \f[CR]natural\f[R])
|
||||
Sort type for directories.
|
||||
Currently supported sort types are \f[CR]natural\f[R], \f[CR]name\f[R],
|
||||
\f[CR]size\f[R], \f[CR]time\f[R], \f[CR]atime\f[R], \f[CR]btime\f[R],
|
||||
\f[CR]ctime\f[R], \f[CR]ext\f[R] and \f[CR]custom\f[R].
|
||||
.PP
|
||||
Meaning of each sort type:
|
||||
The following sort types are supported:
|
||||
.IP
|
||||
.EX
|
||||
natural file name (track_2.flac comes before track_10.flac)
|
||||
name file name (track_10.flac comes before track_2.flac)
|
||||
ext file extension
|
||||
size file size
|
||||
time time of last data modification
|
||||
atime time of last access
|
||||
btime time of file birth
|
||||
ctime time of last status (inode) change
|
||||
ext file extension
|
||||
custom property defined via \(gaaddcustominfo\(ga
|
||||
custom property defined via \(gaaddcustominfo\(ga (empty by default)
|
||||
.EE
|
||||
.SS statfmt (string) (default \f[CR]\(rs033[36m%p\(rs033[0m| %c| %u| %g| %S| %t| \-> %l\f[R])
|
||||
Format string of the file info shown in the bottom left corner.
|
||||
Special expansions are provided, \f[CR]%p\f[R] as the file permissions,
|
||||
\f[CR]%c\f[R] as the link count, \f[CR]%u\f[R] as the user,
|
||||
\f[CR]%g\f[R] as the group, \f[CR]%s\f[R] as the file size,
|
||||
\f[CR]%S\f[R] as the file size but with a fixed width of five characters
|
||||
(left\-padded with spaces), \f[CR]%t\f[R] as the last modified time,
|
||||
\f[CR]%l\f[R] as the link target, \f[CR]%m\f[R] as the current mode and
|
||||
\f[CR]%M\f[R] as the current mode but also shown in Normal mode
|
||||
(displaying \f[CR]NORMAL\f[R] instead of a blank string).
|
||||
.PP
|
||||
The following special expansions are supported:
|
||||
.IP
|
||||
.EX
|
||||
%p file permission
|
||||
%c link count
|
||||
%u user name
|
||||
%g group name
|
||||
%s file size
|
||||
%S file size (left\-padded with spaces to a fixed width of 5 characters)
|
||||
%t time of last data modification
|
||||
%l link target
|
||||
%m current mode
|
||||
%M current mode (displaying \(gaNORMAL\(ga instead of a blank string in Normal mode)
|
||||
.EE
|
||||
.PP
|
||||
The \f[CR]|\f[R] character splits the format string into sections.
|
||||
Any section containing a failed expansion (result is a blank string) is
|
||||
discarded and not shown.
|
||||
.PP
|
||||
File size is formatted using first letter of IEC 80000\-13:2025 prefixes
|
||||
for binary multiples (i.e.
|
||||
1024 bytes is \f[CR]1.0K\f[R]).
|
||||
.SS tabstop (int) (default 8)
|
||||
Number of space characters to show for horizontal tabulation (U+0009)
|
||||
character.
|
||||
@@ -1013,7 +1043,7 @@ temporary and it does not need to be specified.
|
||||
.SS timefmt (string) (default \f[CR]Mon Jan _2 15:04:05 2006\f[R])
|
||||
Format string of the file modification time shown in the bottom line.
|
||||
.SS truncatechar (string) (default \f[CR]\(ti\f[R])
|
||||
The truncate character that is shown at the end when the file name does
|
||||
The truncate character that is shown at the end when the filename does
|
||||
not fit into the pane.
|
||||
.SS truncatepct (int) (default 100)
|
||||
When a filename is too long to be shown completely, the available space
|
||||
@@ -1090,7 +1120,7 @@ in your shell configuration file (e.g.
|
||||
.SS OPENER
|
||||
If this variable is set in the environment, use the same value.
|
||||
Otherwise, this is set to \f[CR]start\f[R] in Windows, \f[CR]open\f[R]
|
||||
in MacOS, \f[CR]xdg\-open\f[R] in others.
|
||||
in macOS, \f[CR]xdg\-open\f[R] in others.
|
||||
.SS EDITOR
|
||||
If VISUAL is set in the environment, use its value.
|
||||
Otherwise, use the value of the environment variable EDITOR.
|
||||
@@ -1171,7 +1201,7 @@ This shell command can be defined to be executed before quitting.
|
||||
The following command prefixes are used by lf:
|
||||
.IP
|
||||
.EX
|
||||
: read (default) builtin/custom command
|
||||
: read (default) built\-in/custom command
|
||||
$ shell shell command
|
||||
% shell\-pipe shell command running with the UI
|
||||
! shell\-wait shell command waiting for a key press
|
||||
@@ -1206,8 +1236,8 @@ set nohidden # boolean disable
|
||||
set hidden false # boolean disable
|
||||
set hidden! # boolean toggle
|
||||
set scrolloff 10 # integer value
|
||||
set sortby time # string value w/o quotes
|
||||
set sortby \(aqtime\(aq # string value with single quotes (whitespaces)
|
||||
set sortby time # string value without quotes
|
||||
set sortby \(aqtime\(aq # string value with single quotes (whitespace)
|
||||
set sortby \(dqtime\(dq # string value with double quotes (backslash escapes)
|
||||
.EE
|
||||
.PP
|
||||
@@ -1215,8 +1245,7 @@ Command \f[CR]setlocal\f[R] is used to set a local option for a
|
||||
directory which can be a boolean or string.
|
||||
Currently supported local options are \f[CR]dircounts\f[R],
|
||||
\f[CR]dirfirst\f[R], \f[CR]dironly\f[R], \f[CR]hidden\f[R],
|
||||
\f[CR]info\f[R], \f[CR]locale\f[R], \f[CR]reverse\f[R] and
|
||||
\f[CR]sortby\f[R].
|
||||
\f[CR]info\f[R], \f[CR]reverse\f[R] and \f[CR]sortby\f[R].
|
||||
Adding a trailing path separator (i.e.
|
||||
\f[CR]/\f[R] for Unix and \f[CR]\(rs\f[R] for Windows) sets the option
|
||||
for the given directory along with its subdirectories:
|
||||
@@ -1227,19 +1256,19 @@ setlocal /foo/bar hidden true # boolean enable
|
||||
setlocal /foo/bar nohidden # boolean disable
|
||||
setlocal /foo/bar hidden false # boolean disable
|
||||
setlocal /foo/bar hidden! # boolean toggle
|
||||
setlocal /foo/bar sortby time # string value w/o quotes
|
||||
setlocal /foo/bar sortby \(aqtime\(aq # string value with single quotes (whitespaces)
|
||||
setlocal /foo/bar sortby time # string value without quotes
|
||||
setlocal /foo/bar sortby \(aqtime\(aq # string value with single quotes (whitespace)
|
||||
setlocal /foo/bar sortby \(dqtime\(dq # string value with double quotes (backslash escapes)
|
||||
setlocal /foo/bar hidden # for only \(aq/foo/bar\(aq directory
|
||||
setlocal /foo/bar/ hidden # for \(aq/foo/bar\(aq and its subdirectories (e.g. \(aq/foo/bar/baz\(aq)
|
||||
.EE
|
||||
.PP
|
||||
Command \f[CR]map\f[R] is used to bind a key in Normal and Visual mode
|
||||
to a command which can be a builtin command, custom command, or shell
|
||||
to a command which can be a built\-in command, custom command, or shell
|
||||
command:
|
||||
.IP
|
||||
.EX
|
||||
map gh cd \(ti # builtin command
|
||||
map gh cd \(ti # built\-in command
|
||||
map D trash # custom command
|
||||
map i $less $f # shell command
|
||||
map U !du \-csh * # waiting shell command
|
||||
@@ -1317,7 +1346,7 @@ Regular keys are assigned to a command with the usual syntax:
|
||||
map a down
|
||||
.EE
|
||||
.PP
|
||||
Keys combined with the shift key simply use the uppercase letter:
|
||||
Keys combined with the Shift key simply use the uppercase letter:
|
||||
.IP
|
||||
.EX
|
||||
map A down
|
||||
@@ -1343,17 +1372,17 @@ Function keys are prefixed with \f[CR]f\f[R] character:
|
||||
map <f\-1> down
|
||||
.EE
|
||||
.PP
|
||||
Keys combined with the control key are prefixed with a \f[CR]c\f[R]
|
||||
Keys combined with the Ctrl key are prefixed with a \f[CR]c\f[R]
|
||||
character:
|
||||
.IP
|
||||
.EX
|
||||
map <c\-a> down
|
||||
.EE
|
||||
.PP
|
||||
Keys combined with the alt key are assigned in two different ways
|
||||
Keys combined with the Alt key are assigned in two different ways
|
||||
depending on the behavior of your terminal.
|
||||
Older terminals (e.g.
|
||||
xterm) may set the 8th bit of a character when the alt key is pressed.
|
||||
xterm) may set the 8th bit of a character when the Alt key is pressed.
|
||||
On these terminals, you can use the corresponding byte for the mapping:
|
||||
.IP
|
||||
.EX
|
||||
@@ -1361,11 +1390,11 @@ map á down
|
||||
.EE
|
||||
.PP
|
||||
Newer terminals (e.g.
|
||||
gnome\-terminal) may prefix the key with an escape key when the alt key
|
||||
is pressed.
|
||||
lf uses the escape delaying mechanism to recognize alt keys in these
|
||||
gnome\-terminal) may prefix the key with an escape character when the
|
||||
Alt key is pressed.
|
||||
lf uses the escape delaying mechanism to recognize Alt keys in these
|
||||
terminals (delay is 100ms).
|
||||
On these terminals, keys combined with the alt key are prefixed with an
|
||||
On these terminals, keys combined with the Alt key are prefixed with an
|
||||
\f[CR]a\f[R] character:
|
||||
.IP
|
||||
.EX
|
||||
@@ -1505,7 +1534,7 @@ the rest of the documentation.
|
||||
.SH PIPING SHELL COMMANDS
|
||||
Regular shell commands have some limitations in some cases.
|
||||
When an output or error message is given and the command exits
|
||||
afterwards, the ui is immediately resumed and there is no way to see the
|
||||
afterwards, the UI is immediately resumed and there is no way to see the
|
||||
message without dropping to shell again.
|
||||
Also, even when there is no output or error, the UI still needs to be
|
||||
paused while the command is running.
|
||||
@@ -1518,15 +1547,15 @@ This can be useful for programs following the Unix philosophy to give no
|
||||
output in the success case, and brief error messages or prompts in other
|
||||
cases.
|
||||
.PP
|
||||
For example, following rename command prompts for overwrite in the
|
||||
For example, the following rename command prompts for overwrite in the
|
||||
statline if there is an existing file with the given name:
|
||||
.IP
|
||||
.EX
|
||||
cmd rename %mv \-i $f $1
|
||||
.EE
|
||||
.PP
|
||||
You can also output error messages in the command and it will show up in
|
||||
the statline.
|
||||
You can also output error messages in the command and they will show up
|
||||
in the statline.
|
||||
For example, an alternative rename command may look like this:
|
||||
.IP
|
||||
.EX
|
||||
@@ -1585,7 +1614,7 @@ client:
|
||||
lf \-remote \(aqsend 1234 echo hello world\(aq
|
||||
.EE
|
||||
.PP
|
||||
All clients have a unique id number but you may not be aware of the id
|
||||
All clients have a unique ID number but you may not be aware of the ID
|
||||
number when you are writing a command.
|
||||
For this purpose, an \f[CR]$id\f[R] variable is exported to the
|
||||
environment for shell commands.
|
||||
@@ -1617,7 +1646,7 @@ cmd recol %{{
|
||||
.EE
|
||||
.PP
|
||||
In addition, the \f[CR]query\f[R] command can be used to obtain
|
||||
information about a specific lf instance by providing its id:
|
||||
information about a specific lf instance by providing its ID:
|
||||
.IP
|
||||
.EX
|
||||
lf \-remote \(dqquery $id maps\(dq
|
||||
@@ -1690,7 +1719,7 @@ Moving is performed using the rename operation of the underlying OS.
|
||||
For cross\-device moving, lf falls back to copying and then deletes the
|
||||
original files if there are no errors.
|
||||
Operation errors are shown in the message line as well as the log file
|
||||
and they do not preemptively finish the corresponding file operation.
|
||||
and they do not prematurely terminate the corresponding file operation.
|
||||
.PP
|
||||
File operations can be performed on the currently selected file or on
|
||||
multiple files by selecting them first.
|
||||
@@ -1785,13 +1814,13 @@ only a single match.
|
||||
The default values of these two options are set to jump to the first
|
||||
file with the given initial.
|
||||
.PP
|
||||
Some options effect both searching and finding.
|
||||
Some options affect both searching and finding.
|
||||
You can disable \f[CR]wrapscan\f[R] option to prevent searches from
|
||||
being wrapped around at the end of the file list.
|
||||
You can disable \f[CR]ignorecase\f[R] option to match cases in the
|
||||
pattern and the filename.
|
||||
This option is already automatically overridden if the pattern contains
|
||||
upper\-case characters.
|
||||
uppercase characters.
|
||||
You can disable \f[CR]smartcase\f[R] option to disable this behavior.
|
||||
Two similar options \f[CR]ignoredia\f[R] and \f[CR]smartdia\f[R] are
|
||||
provided to control matching diacritics in Latin letters.
|
||||
@@ -1812,7 +1841,7 @@ It is possible to use different command types:
|
||||
cmd open &xdg\-open $f
|
||||
.EE
|
||||
.PP
|
||||
You may want to use either file extensions or mime types from
|
||||
You may want to use either file extensions or MIME types from
|
||||
\f[CR]file\f[R] command:
|
||||
.IP
|
||||
.EX
|
||||
@@ -1862,13 +1891,13 @@ lf previews files on the preview pane by printing the file until the end
|
||||
or until the preview pane is filled.
|
||||
This output can be enhanced by providing a custom preview script for
|
||||
filtering.
|
||||
This can be used to highlight source codes, list contents of archive
|
||||
This can be used to highlight source code, list contents of archive
|
||||
files or view PDF or image files to name a few.
|
||||
For coloring lf recognizes ANSI escape codes.
|
||||
.PP
|
||||
To use this feature, you need to set the value of \f[CR]previewer\f[R]
|
||||
option to the path of an executable file.
|
||||
Five arguments are passed to the file, (1) current file name, (2) width,
|
||||
Five arguments are passed to the file, (1) current filename, (2) width,
|
||||
(3) height, (4) horizontal position, and (5) vertical position of
|
||||
preview pane respectively.
|
||||
The output of the execution is printed in the preview pane.
|
||||
@@ -1891,7 +1920,7 @@ map i $LESSOPEN=\(aq| \(ti/.config/lf/pv.sh %s\(aq less \-R $f
|
||||
Since this script is called for each file selection change it needs to
|
||||
be as efficient as possible and this responsibility is left to the user.
|
||||
You may use file extensions to determine the type of file more
|
||||
efficiently compared to obtaining mime types from \f[CR]file\f[R]
|
||||
efficiently compared to obtaining MIME types from \f[CR]file\f[R]
|
||||
command.
|
||||
Extensions can then be used to match cleanly within a conditional:
|
||||
.IP
|
||||
@@ -2059,7 +2088,7 @@ Colors are set in the following order:
|
||||
.IP "1." 3
|
||||
default
|
||||
.IP "2." 3
|
||||
LSCOLORS (Mac/BSD ls)
|
||||
LSCOLORS (macOS/BSD ls)
|
||||
.IP "3." 3
|
||||
LS_COLORS (GNU ls)
|
||||
.IP "4." 3
|
||||
@@ -2242,7 +2271,7 @@ ex=01;32:\(rs
|
||||
.PP
|
||||
The \f[CR]ln\f[R] entry supports the special value \f[CR]target\f[R],
|
||||
which will use the link target to select a style.
|
||||
File name rules will still apply based on the link\(aqs name \-\- this
|
||||
Filename rules will still apply based on the link\(aqs name \-\- this
|
||||
mirrors GNU\(aqs \f[CR]ls\f[R] and \f[CR]dircolors\f[R] behavior.
|
||||
Having such a long variable definition in a shell configuration file
|
||||
might be undesirable.
|
||||
@@ -2265,11 +2294,11 @@ CONFIGURATION section
|
||||
.UE \c
|
||||
).
|
||||
The variable uses the same syntax as \f[CR]LS_COLORS/LF_COLORS\f[R].
|
||||
Instead of colors, you should put a single characters as values of
|
||||
entries.
|
||||
Instead of colors, you should use single characters or symbols as
|
||||
values.
|
||||
The \f[CR]ln\f[R] entry supports the special value \f[CR]target\f[R],
|
||||
which will use the link target to select a icon.
|
||||
File name rules will still apply based on the link\(aqs name \-\- this
|
||||
Filename rules will still apply based on the link\(aqs name \-\- this
|
||||
mirrors GNU\(aqs \f[CR]ls\f[R] and \f[CR]dircolors\f[R] behavior.
|
||||
The icons file (refer to the \c
|
||||
.UR https://github.com/gokcehan/lf/blob/master/doc.md#configuration
|
||||
@@ -2277,14 +2306,12 @@ CONFIGURATION section
|
||||
.UE \c
|
||||
) should consist of whitespace\-separated arrays with a \f[CR]#\f[R]
|
||||
character to start comments until the end of the line.
|
||||
Each line should contain 1\-3 columns, first column is filetype or
|
||||
filename pattern, second column is the icon, third column is an optional
|
||||
icon color.
|
||||
If there is only one column, means to disable rule for this filetype or
|
||||
pattern.
|
||||
Each line should contain 1\-3 columns: a file type or file name pattern,
|
||||
the icon, and an optional icon color.
|
||||
Using only one column disables all rules for that type or name.
|
||||
Do not forget to add \f[CR]set icons true\f[R] to your \f[CR]lfrc\f[R]
|
||||
to see the icons.
|
||||
Default values are as follows given with their matching order in lf:
|
||||
Default values are listed below in the order lf matches them:
|
||||
.IP
|
||||
.EX
|
||||
ln l
|
||||
|
||||
@@ -267,41 +267,41 @@ func main() {
|
||||
remoteCmd := flag.String(
|
||||
"remote",
|
||||
"",
|
||||
"send remote command to server")
|
||||
"send remote `command` to server")
|
||||
|
||||
cpuprofile := flag.String(
|
||||
"cpuprofile",
|
||||
"",
|
||||
"path to the file to write the CPU profile")
|
||||
"`path` to the file to write the CPU profile")
|
||||
|
||||
memprofile := flag.String(
|
||||
"memprofile",
|
||||
"",
|
||||
"path to the file to write the memory profile")
|
||||
"`path` to the file to write the memory profile")
|
||||
|
||||
flag.StringVar(&gLastDirPath,
|
||||
"last-dir-path",
|
||||
"",
|
||||
"path to the file to write the last dir on exit (to use for cd)")
|
||||
"`path` to the file to write the last dir on exit (to use for cd)")
|
||||
|
||||
flag.StringVar(&gSelectionPath,
|
||||
"selection-path",
|
||||
"",
|
||||
"path to the file to write selected files on open (to use as open file dialog)")
|
||||
"`path` to the file to write selected files on open (to use as open file dialog)")
|
||||
|
||||
flag.StringVar(&gConfigPath,
|
||||
"config",
|
||||
"",
|
||||
"path to the config file (instead of the usual paths)")
|
||||
"`path` to the config file (instead of the usual paths)")
|
||||
|
||||
flag.Var(&gCommands,
|
||||
"command",
|
||||
"command to execute on client initialization")
|
||||
"`command` to execute on client initialization")
|
||||
|
||||
flag.StringVar(&gLogPath,
|
||||
"log",
|
||||
"",
|
||||
"path to the log file to write messages")
|
||||
"`path` to the log file to write messages")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"math/big"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -12,15 +14,20 @@ import (
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/Xuanwo/go-locale"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/mattn/go-runewidth"
|
||||
"golang.org/x/text/collate"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
const (
|
||||
localeStrDisable = "" // disable locale ordering for this locale value
|
||||
localeStrSys = "*" // replace this locale value with locale value read from environment
|
||||
var (
|
||||
reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
|
||||
reRulerSub = regexp.MustCompile(`%[apmcsvfithPd]|%\{[^}]+\}`)
|
||||
reSixelSize = regexp.MustCompile(`"1;1;(\d+);(\d+)`)
|
||||
)
|
||||
|
||||
var (
|
||||
reWord = regexp.MustCompile(`(\pL|\pN)+`)
|
||||
reWordBeg = regexp.MustCompile(`([^\pL\pN]|^)(\pL|\pN)`)
|
||||
reWordEnd = regexp.MustCompile(`(\pL|\pN)([^\pL\pN]|$)`)
|
||||
)
|
||||
|
||||
func isRoot(name string) bool { return filepath.Dir(name) == name }
|
||||
@@ -236,39 +243,48 @@ func readPairs(r io.Reader) ([][]string, error) {
|
||||
}
|
||||
|
||||
// This function converts a size in bytes to a human readable form using
|
||||
// prefixes for binary multiples (e.g., 1 KiB = 1024 B). The output should be
|
||||
// no more than 5 characters long.
|
||||
// prefixes for either binary (1 KiB = 1024 B) or decimal (1 KB = 1000 B)
|
||||
// multiples. The output should be no more than 5 characters long.
|
||||
func humanize(size uint64) string {
|
||||
if size < 1024 {
|
||||
var base uint64 = 1024
|
||||
if gOpts.sizeunits == "decimal" {
|
||||
base = 1000
|
||||
}
|
||||
|
||||
if size < base {
|
||||
return fmt.Sprintf("%dB", size)
|
||||
}
|
||||
|
||||
// Shortened (due to TUI space constraints) version of
|
||||
// IEC 80000-13:2025 prefixes for binary multiples.
|
||||
// *Note*: due to [`FileSize.Size()`](https://pkg.go.dev/io/fs#FileInfo)
|
||||
// being `int64`, maximum possible representable value would be 8 EiB.
|
||||
// being `int64`, the maximum possible representable value would be 8 EiB or
|
||||
// 9.2 EB.
|
||||
prefixes := []string{
|
||||
"K", // kibi (2^10)
|
||||
"M", // mebi (2^20)
|
||||
"G", // gibi (2^30)
|
||||
"T", // tebi (2^40)
|
||||
"P", // pebi (2^50)
|
||||
"E", // exbi (2^60)
|
||||
"Z", // zebi (2^70)
|
||||
"Y", // yobi (2^80)
|
||||
"R", // robi (2^90)
|
||||
"Q", // quebi (2^100)
|
||||
"K", // kibi (2^10) or kilo (10^3)
|
||||
"M", // mebi (2^20) or mega (10^6)
|
||||
"G", // gibi (2^30) or giga (10^9)
|
||||
"T", // tebi (2^40) or tera (10^2)
|
||||
"P", // pebi (2^50) or peta (10^15)
|
||||
"E", // exbi (2^60) or exa (10^18)
|
||||
"Z", // zebi (2^70) or zetta (10^21)
|
||||
"Y", // yobi (2^80) or yotta (10^24)
|
||||
"R", // robi (2^90) or ronna (10^27)
|
||||
"Q", // quebi (2^100) or quetta (10^30)
|
||||
}
|
||||
|
||||
curr := float64(size) / 1024
|
||||
curr := big.NewRat(int64(size), int64(base))
|
||||
|
||||
for _, prefix := range prefixes {
|
||||
if curr < 99.95 {
|
||||
return fmt.Sprintf("%.1f%s", curr, prefix)
|
||||
// if curr < 99.95 then round to 1 decimal place
|
||||
if curr.Cmp(big.NewRat(9995, 100)) < 0 {
|
||||
return fmt.Sprintf("%s%s", curr.FloatString(1), prefix)
|
||||
}
|
||||
if curr < 1023.5 {
|
||||
return fmt.Sprintf("%.0f%s", curr, prefix)
|
||||
|
||||
// if curr < base-0.5 then round to the nearest integer
|
||||
if curr.Cmp(new(big.Rat).Sub(big.NewRat(int64(base), 1), big.NewRat(1, 2))) < 0 {
|
||||
return fmt.Sprintf("%s%s", curr.FloatString(0), prefix)
|
||||
}
|
||||
curr /= 1024
|
||||
|
||||
curr.Quo(curr, big.NewRat(int64(base), 1))
|
||||
}
|
||||
|
||||
return fmt.Sprintf("+999%s", prefixes[len(prefixes)-1])
|
||||
@@ -331,52 +347,6 @@ func getFileExtension(file fs.FileInfo) string {
|
||||
return filepath.Ext(file.Name())
|
||||
}
|
||||
|
||||
var (
|
||||
reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
|
||||
reRulerSub = regexp.MustCompile(`%[apmcsvfithPd]|%\{[^}]+\}`)
|
||||
reSixelSize = regexp.MustCompile(`"1;1;(\d+);(\d+)`)
|
||||
)
|
||||
|
||||
var (
|
||||
reWord = regexp.MustCompile(`(\pL|\pN)+`)
|
||||
reWordBeg = regexp.MustCompile(`([^\pL\pN]|^)(\pL|\pN)`)
|
||||
reWordEnd = regexp.MustCompile(`(\pL|\pN)([^\pL\pN]|$)`)
|
||||
)
|
||||
|
||||
// This function parses given locale string into language tag value. Passing empty
|
||||
// string as locale means reading locale value from environment.
|
||||
func getLocaleTag(localeStr string) (language.Tag, error) {
|
||||
if localeStr == localeStrSys {
|
||||
// read environment locale
|
||||
return locale.Detect()
|
||||
}
|
||||
|
||||
localeTag, err := language.Parse(localeStr)
|
||||
if err != nil {
|
||||
return localeTag, fmt.Errorf("invalid locale %q: %s", localeStr, err)
|
||||
}
|
||||
|
||||
return localeTag, nil
|
||||
}
|
||||
|
||||
// This function creates new collator for given locale. Passing empty string as
|
||||
// as locale means reading locale value from environment.
|
||||
//
|
||||
// *Note*: this function returns error when given `localeStr` has value `localeStrDisable`
|
||||
// or is an invalid locale tag.
|
||||
func makeCollator(localeStr string, opts ...collate.Option) (*collate.Collator, error) {
|
||||
if localeStr == localeStrDisable {
|
||||
return nil, fmt.Errorf("locale is disabled")
|
||||
}
|
||||
|
||||
localeTag, err := getLocaleTag(localeStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return collate.New(localeTag, opts...), nil
|
||||
}
|
||||
|
||||
// This function deletes entries from a map if the key is either the given path
|
||||
// or a subpath of it.
|
||||
// This is useful for clearing cached data when a directory is moved or deleted.
|
||||
@@ -390,6 +360,26 @@ func deletePathRecursive[T any](m map[string]T, path string) {
|
||||
}
|
||||
}
|
||||
|
||||
// This function takes an escape sequence option (e.g. `\033[1m`) and outputs a
|
||||
// complete format string (e.g. `\033[1m%s\033[0m`).
|
||||
func optionToFmtstr(optstr string) string {
|
||||
if !strings.Contains(optstr, "%s") {
|
||||
return optstr + "%s\033[0m"
|
||||
} else {
|
||||
return optstr
|
||||
}
|
||||
}
|
||||
|
||||
// This function takes an escape sequence option (e.g. `\033[1m`) and converts
|
||||
// it to a `tcell.Style` object.
|
||||
func parseEscapeSequence(s string) tcell.Style {
|
||||
s = strings.TrimPrefix(s, "\033[")
|
||||
if i := strings.IndexByte(s, 'm'); i >= 0 {
|
||||
s = s[:i]
|
||||
}
|
||||
return applyAnsiCodes(s, tcell.StyleDefault)
|
||||
}
|
||||
|
||||
// This function is used to remove style-related ANSI escape sequences from
|
||||
// a given string.
|
||||
//
|
||||
@@ -421,6 +411,73 @@ func stripAnsi(s string) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// This function reads lines from a file to be displayed as a preview.
|
||||
// The number of lines to read is capped since files can be very large.
|
||||
// Lines are split on `\n` characters, and `\r` characters are discarded.
|
||||
// Sixel images are also detected and stored as separate lines.
|
||||
// The presence of a null byte outside a sixel image indicates a binary file.
|
||||
func readLines(reader io.ByteReader, maxLines int) (lines []string, binary bool, sixel bool) {
|
||||
var buf bytes.Buffer
|
||||
var last byte
|
||||
inSixel := false
|
||||
|
||||
for {
|
||||
b, err := reader.ReadByte()
|
||||
if err != nil {
|
||||
if buf.Len() > 0 {
|
||||
lines = append(lines, buf.String())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if inSixel {
|
||||
buf.WriteByte(b)
|
||||
if b == '\\' && last == '\033' {
|
||||
lines = append(lines, buf.String())
|
||||
buf.Reset()
|
||||
if len(lines) >= maxLines {
|
||||
return
|
||||
}
|
||||
inSixel = false
|
||||
}
|
||||
} else {
|
||||
switch {
|
||||
case b == 0:
|
||||
return nil, true, false
|
||||
case b == '\033':
|
||||
// withhold as it could be the start of a sixel image
|
||||
case b == 'P' && last == '\033':
|
||||
if buf.Len() > 0 {
|
||||
lines = append(lines, buf.String())
|
||||
buf.Reset()
|
||||
if len(lines) >= maxLines {
|
||||
return
|
||||
}
|
||||
}
|
||||
buf.WriteByte(last)
|
||||
buf.WriteByte(b)
|
||||
inSixel = true
|
||||
sixel = true
|
||||
case last == '\033':
|
||||
// not a sixel image
|
||||
buf.WriteByte(last)
|
||||
buf.WriteByte(b)
|
||||
case b == '\r':
|
||||
case b == '\n':
|
||||
lines = append(lines, buf.String())
|
||||
buf.Reset()
|
||||
if len(lines) >= maxLines {
|
||||
return
|
||||
}
|
||||
default:
|
||||
buf.WriteByte(b)
|
||||
}
|
||||
}
|
||||
|
||||
last = b
|
||||
}
|
||||
}
|
||||
|
||||
// We don't need no generic code
|
||||
// We don't need no type control
|
||||
// No dark templates in compiler
|
||||
|
||||
+125
-43
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/text/collate"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
|
||||
func TestIsRoot(t *testing.T) {
|
||||
@@ -289,12 +289,59 @@ func TestHumanize(t *testing.T) {
|
||||
{1319413953332, "1.2T"}, // 1.2 TiB
|
||||
{1463669878895412, "1.3P"}, // 1.3 PiB
|
||||
{7955158381787244544, "6.9E"}, // 6.9 EiB
|
||||
{math.MaxUint64, "16.0E"}, // 16 EiB
|
||||
{math.MaxInt64, "8.0E"}, // 8 EiB
|
||||
}
|
||||
|
||||
gOpts.sizeunits = "binary"
|
||||
for _, test := range tests {
|
||||
if got := humanize(test.size); got != test.expected {
|
||||
t.Errorf("at input '%d' expected '%s' but got '%s'", test.size, test.expected, got)
|
||||
t.Errorf("at input ('%d', '%s') expected '%s' but got '%s'", test.size, gOpts.sizeunits, test.expected, got)
|
||||
}
|
||||
}
|
||||
|
||||
tests = []struct {
|
||||
size uint64
|
||||
expected string
|
||||
}{
|
||||
{0, "0B"},
|
||||
{1, "1B"},
|
||||
{2, "2B"},
|
||||
{10, "10B"},
|
||||
{100, "100B"},
|
||||
{999, "999B"},
|
||||
{1000, "1.0K"},
|
||||
{1001, "1.0K"},
|
||||
{1049, "1.0K"},
|
||||
{1050, "1.1K"},
|
||||
{1051, "1.1K"},
|
||||
{9949, "9.9K"},
|
||||
{9950, "10.0K"},
|
||||
{9951, "10.0K"},
|
||||
{9999, "10.0K"},
|
||||
{10000, "10.0K"},
|
||||
{10001, "10.0K"},
|
||||
{99949, "99.9K"},
|
||||
{99950, "100K"},
|
||||
{99951, "100K"},
|
||||
{999499, "999K"},
|
||||
{999500, "1.0M"},
|
||||
{999501, "1.0M"},
|
||||
{999999, "1.0M"},
|
||||
{1000000, "1.0M"},
|
||||
{1000001, "1.0M"},
|
||||
{999499999, "999M"},
|
||||
{999500000, "1.0G"},
|
||||
{999500001, "1.0G"},
|
||||
{999999999, "1.0G"},
|
||||
{1000000000, "1.0G"},
|
||||
{1000000001, "1.0G"},
|
||||
{math.MaxInt64, "9.2E"},
|
||||
}
|
||||
|
||||
gOpts.sizeunits = "decimal"
|
||||
for _, test := range tests {
|
||||
if got := humanize(test.size); got != test.expected {
|
||||
t.Errorf("at input ('%d', '%s') expected '%s' but got '%s'", test.size, gOpts.sizeunits, test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,51 +410,34 @@ func TestGetFileExtension(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocaleNaturalLess(t *testing.T) {
|
||||
func TestOptionToFmtstr(t *testing.T) {
|
||||
tests := []struct {
|
||||
s1 string
|
||||
s2 string
|
||||
exp bool
|
||||
s string
|
||||
exp string
|
||||
}{
|
||||
// preserving behavior of `naturalLess`
|
||||
{"foo", "bar", false},
|
||||
{"bar", "baz", true},
|
||||
{"foo", "123", false},
|
||||
{"foo1", "foobar", true},
|
||||
{"foo1", "foo10", true},
|
||||
{"foo2", "foo10", true},
|
||||
{"foo1", "foo10bar", true},
|
||||
{"foo2", "foo10bar", true},
|
||||
{"foo1bar", "foo10bar", true},
|
||||
{"foo2bar", "foo10bar", true},
|
||||
{"foo1bar", "foo10", true},
|
||||
{"foo2bar", "foo10", true},
|
||||
|
||||
// locale sort
|
||||
{"你好", "他好", true}, // \u4F60\u597D, \u4ED6\u597D
|
||||
{"到这", "到那", false}, // \u5230\u8FD9, \u5230\u90A3
|
||||
{"你说", "什么", true}, // \u4f60\u8bf4, \u4ec0\u4e48
|
||||
{"你好", "World", false}, // \u4F60\u597D, \u57\u6f\u72\u6c\u64
|
||||
{"甲1", "甲乙", true},
|
||||
{"甲1", "甲10", true},
|
||||
{"甲2", "甲10", true},
|
||||
{"甲1", "甲10乙", true},
|
||||
{"甲2", "甲10乙", true},
|
||||
{"甲1乙", "甲10乙", true},
|
||||
{"甲2乙", "甲10乙", true},
|
||||
{"甲1乙", "甲10", true},
|
||||
{"甲2乙", "甲10", true},
|
||||
}
|
||||
|
||||
localeStr := "zh-CN"
|
||||
collator, err := makeCollator(localeStr, collate.Numeric)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create collator for %q: %s", localeStr, err)
|
||||
{"\033[1m", "\033[1m%s\033[0m"},
|
||||
{"\033[1;7;31;42m", "\033[1;7;31;42m%s\033[0m"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
if got := collator.CompareString(test.s1, test.s2) < 0; got != test.exp {
|
||||
t.Errorf("at input '%s' and '%s' expected '%t' but got '%t'", test.s1, test.s2, test.exp, got)
|
||||
if got := optionToFmtstr(test.s); got != test.exp {
|
||||
t.Errorf("at input %q expected %q but got %q", test.s, test.exp, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseEscapeSequence(t *testing.T) {
|
||||
tests := []struct {
|
||||
s string
|
||||
exp tcell.Style
|
||||
}{
|
||||
{"\033[1m", tcell.StyleDefault.Bold(true)},
|
||||
{"\033[1;7;31;42m", tcell.StyleDefault.Bold(true).Reverse(true).Foreground(tcell.ColorMaroon).Background(tcell.ColorGreen)},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
if got := parseEscapeSequence(test.s); got != test.exp {
|
||||
t.Errorf("at input %q expected '%v' but got '%v'", test.s, test.exp, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -443,3 +473,55 @@ func TestStripAnsi(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadLines(t *testing.T) {
|
||||
tests := []struct {
|
||||
s string
|
||||
maxLines int
|
||||
lines []string
|
||||
binary bool
|
||||
sixel bool
|
||||
}{
|
||||
{"", 10, nil, false, false},
|
||||
{"\r", 10, nil, false, false},
|
||||
{"\r\n", 10, []string{""}, false, false},
|
||||
{"\r\r\n", 10, []string{""}, false, false},
|
||||
{"\n\n", 10, []string{"", ""}, false, false},
|
||||
{"foo", 10, []string{"foo"}, false, false},
|
||||
{"foo\n", 10, []string{"foo"}, false, false},
|
||||
{"foo\r\n", 10, []string{"foo"}, false, false},
|
||||
{"foo\nbar", 10, []string{"foo", "bar"}, false, false},
|
||||
{"foo\nbar\n", 10, []string{"foo", "bar"}, false, false},
|
||||
{"foo\r\nbar", 10, []string{"foo", "bar"}, false, false},
|
||||
{"foo\r\nbar\r\n", 10, []string{"foo", "bar"}, false, false},
|
||||
{"\033[31mfoo\033[0m", 10, []string{"\033[31mfoo\033[0m"}, false, false},
|
||||
{"\000", 10, nil, true, false},
|
||||
{"foo\r\n\000\r\nbar\r\n", 10, nil, true, false},
|
||||
{"\033P\033\\", 10, []string{"\033P\033\\"}, false, true},
|
||||
{"\033Pq\"1;1;1;1#0@\033\\", 10, []string{"\033Pq\"1;1;1;1#0@\033\\"}, false, true},
|
||||
{"\033P\000\033\\", 10, []string{"\033P\000\033\\"}, false, true},
|
||||
{"\033P\n\033\\", 10, []string{"\033P\n\033\\"}, false, true},
|
||||
{"\033P\r\n\033\\", 10, []string{"\033P\r\n\033\\"}, false, true},
|
||||
{"\033P\033\\\033P\033\\", 10, []string{"\033P\033\\", "\033P\033\\"}, false, true},
|
||||
{"foo\033P\033\\bar", 10, []string{"foo", "\033P\033\\", "bar"}, false, true},
|
||||
{"foo\033P\033\\bar\033P\033\\baz", 10, []string{"foo", "\033P\033\\", "bar", "\033P\033\\", "baz"}, false, true},
|
||||
{"foo\nbar\nbaz", 2, []string{"foo", "bar"}, false, false},
|
||||
{"foo\nbar\nbaz\n", 2, []string{"foo", "bar"}, false, false},
|
||||
{"foo\nbar\033P\033\\", 2, []string{"foo", "bar"}, false, false},
|
||||
{"foo\nbar\nbaz", 3, []string{"foo", "bar", "baz"}, false, false},
|
||||
{"foo\nbar\nbaz\n", 3, []string{"foo", "bar", "baz"}, false, false},
|
||||
{"foo\nbar\033P\033\\", 3, []string{"foo", "bar", "\033P\033\\"}, false, true},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
lines, binary, sixel := readLines(strings.NewReader(test.s), test.maxLines)
|
||||
if !reflect.DeepEqual(lines, test.lines) || binary != test.binary || sixel != test.sixel {
|
||||
t.Errorf(
|
||||
"at input (%q, %v) expected (%#v, %v, %v) but got (%#v, %v, %v)",
|
||||
test.s, test.maxLines,
|
||||
test.lines, test.binary, test.sixel,
|
||||
lines, binary, sixel,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/djherbis/times"
|
||||
"golang.org/x/text/collate"
|
||||
)
|
||||
|
||||
type linkState byte
|
||||
@@ -189,7 +188,6 @@ type dir struct {
|
||||
filter []string // last filter for this directory
|
||||
ignorecase bool // ignorecase value from last sort
|
||||
ignoredia bool // ignoredia value from last sort
|
||||
locale string // locale value from last sort
|
||||
noPerm bool // whether lf has no permission to open the directory
|
||||
}
|
||||
|
||||
@@ -228,79 +226,67 @@ func (dir *dir) sort() {
|
||||
dir.dironly = getDirOnly(dir.path)
|
||||
dir.hidden = getHidden(dir.path)
|
||||
dir.reverse = getReverse(dir.path)
|
||||
dir.locale = getLocale(dir.path)
|
||||
dir.hiddenfiles = gOpts.hiddenfiles
|
||||
dir.ignorecase = gOpts.ignorecase
|
||||
dir.ignoredia = gOpts.ignoredia
|
||||
|
||||
dir.files = dir.allFiles
|
||||
|
||||
// When applying a filter, move all files not satisfying the predicate to
|
||||
// the beginning, then take the subslice starting from the first file that
|
||||
// does satisfy the predicate
|
||||
applyFilter := func(fn func(f *file) bool) {
|
||||
slices.SortStableFunc(dir.files, func(i, j *file) int {
|
||||
switch {
|
||||
case fn(i) == fn(j):
|
||||
return 0
|
||||
case !fn(i) && fn(j):
|
||||
return -1
|
||||
default:
|
||||
return 1
|
||||
}
|
||||
})
|
||||
|
||||
i := slices.IndexFunc(dir.files, fn)
|
||||
if i == -1 {
|
||||
i = len(dir.files)
|
||||
}
|
||||
dir.files = dir.files[i:]
|
||||
}
|
||||
|
||||
if dir.dironly {
|
||||
applyFilter(func(f *file) bool { return f.IsDir() })
|
||||
}
|
||||
|
||||
if !dir.hidden {
|
||||
applyFilter(func(f *file) bool { return !isHidden(f, dir.path, dir.hiddenfiles) })
|
||||
}
|
||||
|
||||
if len(dir.filter) != 0 {
|
||||
applyFilter(func(f *file) bool { return !isFiltered(f, dir.filter) })
|
||||
}
|
||||
|
||||
// reverse order cannot be applied after stable sorting, otherwise the order
|
||||
// of equivalent elements will be reversed
|
||||
applySort := func(fn func(i, j int) bool) {
|
||||
if !dir.reverse {
|
||||
sort.SliceStable(dir.files, fn)
|
||||
} else {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool { return fn(j, i) })
|
||||
}
|
||||
}
|
||||
|
||||
switch dir.sortby {
|
||||
case naturalSort:
|
||||
if collator, err := makeCollator(dir.locale, collate.Numeric); err == nil {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||
result := collator.CompareString(s1, s2)
|
||||
if !dir.reverse {
|
||||
return result < 0
|
||||
} else {
|
||||
return result > 0
|
||||
}
|
||||
})
|
||||
} else {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||
if !dir.reverse {
|
||||
return naturalLess(s1, s2)
|
||||
} else {
|
||||
return naturalLess(s2, s1)
|
||||
}
|
||||
})
|
||||
}
|
||||
case customSort:
|
||||
if collator, err := makeCollator(dir.locale, collate.Numeric); err == nil {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
s1, s2 := normalize(stripAnsi(dir.files[i].customInfo), stripAnsi(dir.files[j].customInfo), dir.ignorecase, dir.ignoredia)
|
||||
result := collator.CompareString(s1, s2)
|
||||
if !dir.reverse {
|
||||
return result < 0
|
||||
} else {
|
||||
return result > 0
|
||||
}
|
||||
})
|
||||
} else {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
s1, s2 := normalize(stripAnsi(dir.files[i].customInfo), stripAnsi(dir.files[j].customInfo), dir.ignorecase, dir.ignoredia)
|
||||
if !dir.reverse {
|
||||
return naturalLess(s1, s2)
|
||||
} else {
|
||||
return naturalLess(s2, s1)
|
||||
}
|
||||
})
|
||||
}
|
||||
applySort(func(i, j int) bool {
|
||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||
return naturalLess(s1, s2)
|
||||
})
|
||||
case nameSort:
|
||||
if collator, err := makeCollator(dir.locale); err == nil {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||
result := collator.CompareString(s1, s2)
|
||||
if !dir.reverse {
|
||||
return result < 0
|
||||
} else {
|
||||
return result > 0
|
||||
}
|
||||
})
|
||||
} else {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||
if !dir.reverse {
|
||||
return s1 < s2
|
||||
} else {
|
||||
return s2 < s1
|
||||
}
|
||||
})
|
||||
}
|
||||
applySort(func(i, j int) bool {
|
||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||
return s1 < s2
|
||||
})
|
||||
case sizeSort:
|
||||
sizeVal := func(f *file) int64 {
|
||||
if f.IsDir() && dir.dircounts {
|
||||
@@ -308,55 +294,36 @@ func (dir *dir) sort() {
|
||||
}
|
||||
return f.TotalSize()
|
||||
}
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
applySort(func(i, j int) bool {
|
||||
s1, s2 := sizeVal(dir.files[i]), sizeVal(dir.files[j])
|
||||
if !dir.reverse {
|
||||
return s1 < s2
|
||||
} else {
|
||||
return s2 < s1
|
||||
}
|
||||
return s1 < s2
|
||||
})
|
||||
case timeSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if !dir.reverse {
|
||||
return dir.files[i].ModTime().Before(dir.files[j].ModTime())
|
||||
} else {
|
||||
return dir.files[j].ModTime().Before(dir.files[i].ModTime())
|
||||
}
|
||||
applySort(func(i, j int) bool {
|
||||
return dir.files[i].ModTime().Before(dir.files[j].ModTime())
|
||||
})
|
||||
case atimeSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if !dir.reverse {
|
||||
return dir.files[i].accessTime.Before(dir.files[j].accessTime)
|
||||
} else {
|
||||
return dir.files[j].accessTime.Before(dir.files[i].accessTime)
|
||||
}
|
||||
applySort(func(i, j int) bool {
|
||||
return dir.files[i].accessTime.Before(dir.files[j].accessTime)
|
||||
})
|
||||
case btimeSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if !dir.reverse {
|
||||
return dir.files[i].birthTime.Before(dir.files[j].birthTime)
|
||||
} else {
|
||||
return dir.files[j].birthTime.Before(dir.files[i].birthTime)
|
||||
}
|
||||
applySort(func(i, j int) bool {
|
||||
return dir.files[i].birthTime.Before(dir.files[j].birthTime)
|
||||
})
|
||||
case ctimeSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if !dir.reverse {
|
||||
return dir.files[i].changeTime.Before(dir.files[j].changeTime)
|
||||
} else {
|
||||
return dir.files[j].changeTime.Before(dir.files[i].changeTime)
|
||||
}
|
||||
applySort(func(i, j int) bool {
|
||||
return dir.files[i].changeTime.Before(dir.files[j].changeTime)
|
||||
})
|
||||
case extSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
applySort(func(i, j int) bool {
|
||||
ext1, ext2 := normalize(dir.files[i].ext, dir.files[j].ext, dir.ignorecase, dir.ignoredia)
|
||||
name1, name2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||
if !dir.reverse {
|
||||
return ext1 < ext2 || ext1 == ext2 && name1 < name2
|
||||
} else {
|
||||
return ext2 < ext1 || ext2 == ext1 && name2 < name1
|
||||
}
|
||||
return ext1 < ext2 || ext1 == ext2 && name1 < name2
|
||||
})
|
||||
case customSort:
|
||||
applySort(func(i, j int) bool {
|
||||
s1, s2 := normalize(stripAnsi(dir.files[i].customInfo), stripAnsi(dir.files[j].customInfo), dir.ignorecase, dir.ignoredia)
|
||||
return naturalLess(s1, s2)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -371,65 +338,6 @@ func (dir *dir) sort() {
|
||||
})
|
||||
}
|
||||
|
||||
// when dironly option is enabled, we move files to the beginning of our file
|
||||
// list and then set the beginning of displayed files to the first directory
|
||||
// in the list
|
||||
if dir.dironly {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if !dir.files[i].IsDir() && !dir.files[j].IsDir() {
|
||||
return i < j
|
||||
}
|
||||
return !dir.files[i].IsDir()
|
||||
})
|
||||
dir.files = func() []*file {
|
||||
for i, f := range dir.files {
|
||||
if f.IsDir() {
|
||||
return dir.files[i:]
|
||||
}
|
||||
}
|
||||
return dir.files[len(dir.files):]
|
||||
}()
|
||||
}
|
||||
|
||||
// when hidden option is disabled, we move hidden files to the
|
||||
// beginning of our file list and then set the beginning of displayed
|
||||
// files to the first non-hidden file in the list
|
||||
if !dir.hidden {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if isHidden(dir.files[i], dir.path, dir.hiddenfiles) && isHidden(dir.files[j], dir.path, dir.hiddenfiles) {
|
||||
return i < j
|
||||
}
|
||||
return isHidden(dir.files[i], dir.path, dir.hiddenfiles)
|
||||
})
|
||||
for i, f := range dir.files {
|
||||
if !isHidden(f, dir.path, dir.hiddenfiles) {
|
||||
dir.files = dir.files[i:]
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(dir.files) > 0 && isHidden(dir.files[len(dir.files)-1], dir.path, dir.hiddenfiles) {
|
||||
dir.files = dir.files[len(dir.files):]
|
||||
}
|
||||
}
|
||||
|
||||
if len(dir.filter) != 0 {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if isFiltered(dir.files[i], dir.filter) && isFiltered(dir.files[j], dir.filter) {
|
||||
return i < j
|
||||
}
|
||||
return isFiltered(dir.files[i], dir.filter)
|
||||
})
|
||||
for i, f := range dir.files {
|
||||
if !isFiltered(f, dir.filter) {
|
||||
dir.files = dir.files[i:]
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(dir.files) > 0 && isFiltered(dir.files[len(dir.files)-1], dir.filter) {
|
||||
dir.files = dir.files[len(dir.files):]
|
||||
}
|
||||
}
|
||||
|
||||
dir.ind = max(dir.ind, 0)
|
||||
dir.ind = min(dir.ind, len(dir.files)-1)
|
||||
}
|
||||
@@ -538,7 +446,7 @@ type nav struct {
|
||||
deleteCount int
|
||||
deleteTotal int
|
||||
deleteUpdate int
|
||||
copyJobsChan chan struct{}
|
||||
copyJobsChan chan int
|
||||
copyBytesChan chan int64
|
||||
copyTotalChan chan int64
|
||||
moveCountChan chan int
|
||||
@@ -574,42 +482,33 @@ type nav struct {
|
||||
jumpListInd int
|
||||
}
|
||||
|
||||
func (nav *nav) loadDirInternal(path string) *dir {
|
||||
d := &dir{
|
||||
loading: true,
|
||||
path: path,
|
||||
sortby: getSortBy(path),
|
||||
dircounts: getDirCounts(path),
|
||||
dirfirst: getDirFirst(path),
|
||||
dironly: getDirOnly(path),
|
||||
hidden: getHidden(path),
|
||||
reverse: getReverse(path),
|
||||
locale: getLocale(path),
|
||||
visualAnchor: -1,
|
||||
hiddenfiles: gOpts.hiddenfiles,
|
||||
ignorecase: gOpts.ignorecase,
|
||||
ignoredia: gOpts.ignoredia,
|
||||
}
|
||||
go func() {
|
||||
nav.dirChan <- newDir(path)
|
||||
}()
|
||||
return d
|
||||
}
|
||||
|
||||
func (nav *nav) loadDir(path string) *dir {
|
||||
if gOpts.dircache {
|
||||
d, ok := nav.dirCache[path]
|
||||
if !ok {
|
||||
d = nav.loadDirInternal(path)
|
||||
nav.dirCache[path] = d
|
||||
return d
|
||||
d, ok := nav.dirCache[path]
|
||||
if !ok {
|
||||
go func() {
|
||||
nav.dirChan <- newDir(path)
|
||||
}()
|
||||
|
||||
d := &dir{
|
||||
loading: true,
|
||||
path: path,
|
||||
sortby: getSortBy(path),
|
||||
dircounts: getDirCounts(path),
|
||||
dirfirst: getDirFirst(path),
|
||||
dironly: getDirOnly(path),
|
||||
hidden: getHidden(path),
|
||||
reverse: getReverse(path),
|
||||
visualAnchor: -1,
|
||||
hiddenfiles: gOpts.hiddenfiles,
|
||||
ignorecase: gOpts.ignorecase,
|
||||
ignoredia: gOpts.ignoredia,
|
||||
}
|
||||
|
||||
nav.checkDir(d)
|
||||
|
||||
nav.dirCache[path] = d
|
||||
return d
|
||||
}
|
||||
return nav.loadDirInternal(path)
|
||||
|
||||
nav.checkDir(d)
|
||||
return d
|
||||
}
|
||||
|
||||
func (nav *nav) checkDir(dir *dir) {
|
||||
@@ -648,7 +547,6 @@ func (nav *nav) checkDir(dir *dir) {
|
||||
dir.dironly != getDirOnly(dir.path) ||
|
||||
dir.hidden != getHidden(dir.path) ||
|
||||
dir.reverse != getReverse(dir.path) ||
|
||||
dir.locale != getLocale(dir.path) ||
|
||||
!reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) ||
|
||||
dir.ignorecase != gOpts.ignorecase ||
|
||||
dir.ignoredia != gOpts.ignoredia:
|
||||
@@ -684,7 +582,7 @@ func (nav *nav) getDirs(wd string) {
|
||||
|
||||
func newNav(height int) *nav {
|
||||
nav := &nav{
|
||||
copyJobsChan: make(chan struct{}, 1024),
|
||||
copyJobsChan: make(chan int, 1024),
|
||||
copyBytesChan: make(chan int64, 1024),
|
||||
copyTotalChan: make(chan int64, 1024),
|
||||
moveCountChan: make(chan int, 1024),
|
||||
@@ -914,43 +812,12 @@ func (nav *nav) preview(path string, win *win) {
|
||||
reader = bufio.NewReader(f)
|
||||
}
|
||||
|
||||
if gOpts.sixel {
|
||||
prefix, err := reader.Peek(2)
|
||||
if err == nil && string(prefix) == gSixelBegin {
|
||||
b, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
log.Printf("loading sixel: %s", err)
|
||||
}
|
||||
str := string(b)
|
||||
reg.sixel = &str
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// bufio.Scanner can't handle files containing long lines if they exceed the
|
||||
// size of its internal buffer
|
||||
line := []byte{}
|
||||
for len(reg.lines) < win.h {
|
||||
bytes, isPrefix, err := reader.ReadLine()
|
||||
if err != nil {
|
||||
if len(line) > 0 {
|
||||
reg.lines = append(reg.lines, string(line))
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if slices.Contains(bytes, 0) {
|
||||
reg.lines = []string{"\033[7mbinary\033[0m"}
|
||||
return
|
||||
}
|
||||
|
||||
line = append(line, bytes...)
|
||||
|
||||
if !isPrefix {
|
||||
reg.lines = append(reg.lines, string(line))
|
||||
line = []byte{}
|
||||
}
|
||||
lines, binary, sixel := readLines(reader, win.h)
|
||||
if binary {
|
||||
lines = []string{"\033[7mbinary\033[0m"}
|
||||
}
|
||||
reg.lines = lines
|
||||
reg.sixel = sixel
|
||||
}
|
||||
|
||||
func (nav *nav) loadReg(path string, volatile bool) *reg {
|
||||
@@ -1357,15 +1224,15 @@ func (nav *nav) copyAsync(app *app, srcs []string, dstDir string) {
|
||||
return
|
||||
}
|
||||
|
||||
// indicate that a copy operation is in progress
|
||||
// using the total bytes to determine this instead will mean that it is
|
||||
// possible for copySize to take a while, but not be reflected in the UI
|
||||
// until it has finished
|
||||
nav.copyJobsChan <- struct{}{}
|
||||
// Indicate that a copy operation is in progress. Using the total bytes to
|
||||
// determine this instead will mean that it is possible for copySize to take
|
||||
// a while, but not be reflected in the UI until it has finished.
|
||||
nav.copyJobsChan <- 1
|
||||
|
||||
total, err := copySize(srcs)
|
||||
if err != nil {
|
||||
sendErr("%v", err)
|
||||
nav.copyJobsChan <- -1
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1386,6 +1253,7 @@ loop:
|
||||
}
|
||||
}
|
||||
|
||||
nav.copyJobsChan <- -1
|
||||
nav.copyTotalChan <- -total
|
||||
|
||||
if gSingleMode {
|
||||
@@ -1451,9 +1319,12 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
|
||||
|
||||
if err := os.Rename(src, dst); err != nil {
|
||||
if errCrossDevice(err) {
|
||||
nav.copyJobsChan <- 1
|
||||
|
||||
total, err := copySize([]string{src})
|
||||
if err != nil {
|
||||
sendErr("%v", err)
|
||||
nav.copyJobsChan <- -1
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1475,6 +1346,7 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
|
||||
}
|
||||
}
|
||||
|
||||
nav.copyJobsChan <- -1
|
||||
nav.copyTotalChan <- -total
|
||||
|
||||
if errCount == oldCount {
|
||||
|
||||
@@ -53,7 +53,6 @@ var gOpts struct {
|
||||
cursorparentfmt string
|
||||
cursorpreviewfmt string
|
||||
cutfmt string
|
||||
dircache bool
|
||||
dircounts bool
|
||||
dirfirst bool
|
||||
dironly bool
|
||||
@@ -76,7 +75,9 @@ var gOpts struct {
|
||||
info []string
|
||||
infotimefmtnew string
|
||||
infotimefmtold string
|
||||
locale string
|
||||
menufmt string
|
||||
menuheaderfmt string
|
||||
menuselectfmt string
|
||||
mouse bool
|
||||
number bool
|
||||
numberfmt string
|
||||
@@ -98,7 +99,7 @@ var gOpts struct {
|
||||
shellflag string
|
||||
shellopts []string
|
||||
showbinds bool
|
||||
sixel bool
|
||||
sizeunits string
|
||||
smartcase bool
|
||||
smartdia bool
|
||||
sortby sortMethod
|
||||
@@ -127,7 +128,6 @@ var gLocalOpts struct {
|
||||
dironly map[string]bool
|
||||
hidden map[string]bool
|
||||
info map[string][]string
|
||||
locale map[string]string
|
||||
reverse map[string]bool
|
||||
sortby map[string]sortMethod
|
||||
}
|
||||
@@ -185,15 +185,6 @@ func getInfo(path string) []string {
|
||||
return gOpts.info
|
||||
}
|
||||
|
||||
func getLocale(path string) string {
|
||||
for _, key := range localOptPaths(path) {
|
||||
if val, ok := gLocalOpts.locale[key]; ok {
|
||||
return val
|
||||
}
|
||||
}
|
||||
return gOpts.locale
|
||||
}
|
||||
|
||||
func getReverse(path string) bool {
|
||||
for _, key := range localOptPaths(path) {
|
||||
if val, ok := gLocalOpts.reverse[key]; ok {
|
||||
@@ -222,7 +213,6 @@ func init() {
|
||||
gOpts.cursorparentfmt = "\033[7m"
|
||||
gOpts.cursorpreviewfmt = "\033[4m"
|
||||
gOpts.cutfmt = "\033[7;31m"
|
||||
gOpts.dircache = true
|
||||
gOpts.dircounts = false
|
||||
gOpts.dirfirst = true
|
||||
gOpts.dironly = false
|
||||
@@ -245,7 +235,9 @@ func init() {
|
||||
gOpts.info = nil
|
||||
gOpts.infotimefmtnew = "Jan _2 15:04"
|
||||
gOpts.infotimefmtold = "Jan _2 2006"
|
||||
gOpts.locale = localeStrDisable
|
||||
gOpts.menufmt = "\033[0m"
|
||||
gOpts.menuheaderfmt = "\033[1m"
|
||||
gOpts.menuselectfmt = "\033[7m"
|
||||
gOpts.mouse = false
|
||||
gOpts.number = false
|
||||
gOpts.numberfmt = "\033[33m"
|
||||
@@ -267,7 +259,7 @@ func init() {
|
||||
gOpts.shellflag = gDefaultShellFlag
|
||||
gOpts.shellopts = nil
|
||||
gOpts.showbinds = true
|
||||
gOpts.sixel = false
|
||||
gOpts.sizeunits = "binary"
|
||||
gOpts.smartcase = true
|
||||
gOpts.smartdia = false
|
||||
gOpts.sortby = naturalSort
|
||||
@@ -421,7 +413,6 @@ func init() {
|
||||
gLocalOpts.dironly = make(map[string]bool)
|
||||
gLocalOpts.hidden = make(map[string]bool)
|
||||
gLocalOpts.info = make(map[string][]string)
|
||||
gLocalOpts.locale = make(map[string]string)
|
||||
gLocalOpts.reverse = make(map[string]bool)
|
||||
gLocalOpts.sortby = make(map[string]sortMethod)
|
||||
|
||||
|
||||
@@ -164,9 +164,9 @@ func setDefaults() {
|
||||
gOpts.nkeys["w"] = &execExpr{"$", "$SHELL"}
|
||||
gOpts.vkeys["w"] = &execExpr{"$", "$SHELL"}
|
||||
|
||||
gOpts.cmds["doc"] = &execExpr{"$", `"$lf" -doc | $PAGER`}
|
||||
gOpts.nkeys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||
gOpts.vkeys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||
gOpts.cmds["help"] = &execExpr{"$", `"$lf" -doc | $PAGER`}
|
||||
gOpts.nkeys["<f-1>"] = &callExpr{"help", nil, 1}
|
||||
gOpts.vkeys["<f-1>"] = &callExpr{"help", nil, 1}
|
||||
|
||||
gOpts.cmds["maps"] = &execExpr{"$", `"$lf" -remote "query $id maps" | $PAGER`}
|
||||
gOpts.cmds["nmaps"] = &execExpr{"$", `"$lf" -remote "query $id nmaps" | $PAGER`}
|
||||
|
||||
+13
-5
@@ -74,7 +74,11 @@ func init() {
|
||||
Username: username,
|
||||
}
|
||||
|
||||
config := cmp.Or(os.Getenv("LF_CONFIG_HOME"), os.Getenv("APPDATA"))
|
||||
config := cmp.Or(
|
||||
os.Getenv("LF_CONFIG_HOME"),
|
||||
os.Getenv("XDG_CONFIG_HOME"),
|
||||
os.Getenv("APPDATA"),
|
||||
)
|
||||
|
||||
gConfigPaths = []string{
|
||||
filepath.Join(os.Getenv("ProgramData"), "lf", "lfrc"),
|
||||
@@ -91,7 +95,11 @@ func init() {
|
||||
filepath.Join(config, "lf", "icons"),
|
||||
}
|
||||
|
||||
data := cmp.Or(os.Getenv("LF_DATA_HOME"), os.Getenv("LOCALAPPDATA"))
|
||||
data := cmp.Or(
|
||||
os.Getenv("LF_DATA_HOME"),
|
||||
os.Getenv("XDG_DATA_HOME"),
|
||||
os.Getenv("LOCALAPPDATA"),
|
||||
)
|
||||
|
||||
gFilesPath = filepath.Join(data, "lf", "files")
|
||||
gMarksPath = filepath.Join(data, "lf", "marks")
|
||||
@@ -152,9 +160,9 @@ func setDefaults() {
|
||||
gOpts.nkeys["w"] = &execExpr{"$", "%SHELL%"}
|
||||
gOpts.vkeys["w"] = &execExpr{"$", "%SHELL%"}
|
||||
|
||||
gOpts.cmds["doc"] = &execExpr{"!", "%lf% -doc | %PAGER%"}
|
||||
gOpts.nkeys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||
gOpts.vkeys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||
gOpts.cmds["help"] = &execExpr{"!", "%lf% -doc | %PAGER%"}
|
||||
gOpts.nkeys["<f-1>"] = &callExpr{"help", nil, 1}
|
||||
gOpts.vkeys["<f-1>"] = &callExpr{"help", nil, 1}
|
||||
|
||||
gOpts.cmds["maps"] = &execExpr{"!", `%lf% -remote "query %id% maps" | %PAGER%`}
|
||||
gOpts.cmds["nmaps"] = &execExpr{"!", `%lf% -remote "query %id% nmaps" | %PAGER%`}
|
||||
|
||||
@@ -6,12 +6,11 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
|
||||
const gSixelBegin = "\033P"
|
||||
|
||||
type sixelScreen struct {
|
||||
lastFile string
|
||||
lastWin win
|
||||
@@ -29,7 +28,7 @@ func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) {
|
||||
return
|
||||
}
|
||||
|
||||
if reg.sixel == nil {
|
||||
if !reg.sixel {
|
||||
sxs.lastFile = ""
|
||||
return
|
||||
}
|
||||
@@ -40,26 +39,56 @@ func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) {
|
||||
return
|
||||
}
|
||||
|
||||
matches := reSixelSize.FindStringSubmatch(*reg.sixel)
|
||||
if matches == nil {
|
||||
log.Printf("sixel: failed to get image size")
|
||||
return
|
||||
}
|
||||
iw, _ := strconv.Atoi(matches[1])
|
||||
ih, _ := strconv.Atoi(matches[2])
|
||||
y := win.y
|
||||
var b strings.Builder
|
||||
|
||||
if os.Getenv("TMUX") != "" {
|
||||
// tmux rounds the image height up to a multiple of 6, so we
|
||||
// need to do the same to avoid overwriting the image, as tmux
|
||||
// would remove the image if we touched it.
|
||||
ih = (ih + 5) / 6 * 6
|
||||
for _, line := range reg.lines {
|
||||
if !strings.HasPrefix(line, "\033P") {
|
||||
if y >= win.y+win.h {
|
||||
break
|
||||
}
|
||||
|
||||
screen.LockRegion(win.x, y, printLength(line), 1, true)
|
||||
fmt.Fprintf(&b, "\033[%d;%dH", y+1, win.x+1)
|
||||
b.WriteString(line)
|
||||
y += 1
|
||||
continue
|
||||
}
|
||||
|
||||
matches := reSixelSize.FindStringSubmatch(line)
|
||||
if matches == nil {
|
||||
log.Printf("sixel: failed to get image size")
|
||||
continue
|
||||
}
|
||||
|
||||
iw, _ := strconv.Atoi(matches[1])
|
||||
ih, _ := strconv.Atoi(matches[2])
|
||||
|
||||
if os.Getenv("TMUX") != "" {
|
||||
// tmux rounds the image height up to a multiple of 6, so we
|
||||
// need to do the same to avoid overwriting the image, as tmux
|
||||
// would remove the image if we touched it.
|
||||
ih = (ih + 5) / 6 * 6
|
||||
}
|
||||
|
||||
sw := (iw + cw - 1) / cw
|
||||
sh := (ih + ch - 1) / ch
|
||||
|
||||
if y+sh-1 >= win.y+win.h {
|
||||
break
|
||||
}
|
||||
|
||||
screen.LockRegion(win.x, y, sw, sh, true)
|
||||
fmt.Fprintf(&b, "\033[%d;%dH", y+1, win.x+1)
|
||||
b.WriteString(line)
|
||||
y += sh
|
||||
}
|
||||
|
||||
screen.LockRegion(win.x, win.y, (iw+cw-1)/cw, (ih+ch-1)/ch, true)
|
||||
fmt.Fprint(os.Stderr, "\0337") // Save cursor position
|
||||
fmt.Fprintf(os.Stderr, "\033[%d;%dH", win.y+1, win.x+1) // Move cursor to position
|
||||
fmt.Fprint(os.Stderr, *reg.sixel) // Print sixel
|
||||
fmt.Fprint(os.Stderr, "\0338") // Restore cursor position
|
||||
fmt.Fprint(os.Stderr, "\033[?2026h") // Begin synchronized update
|
||||
fmt.Fprint(os.Stderr, "\0337") // Save cursor position
|
||||
fmt.Fprint(os.Stderr, b.String()) // Write data
|
||||
fmt.Fprint(os.Stderr, "\0338") // Restore cursor position
|
||||
fmt.Fprint(os.Stderr, "\033[?2026l") // End synchronized update
|
||||
|
||||
sxs.lastFile = reg.path
|
||||
sxs.lastWin = *win
|
||||
|
||||
@@ -270,12 +270,14 @@ func (win *win) printReg(screen tcell.Screen, reg *reg, previewLoading bool, sxs
|
||||
return
|
||||
}
|
||||
|
||||
for i, l := range reg.lines {
|
||||
if i > win.h-1 {
|
||||
break
|
||||
}
|
||||
if !reg.sixel {
|
||||
for i, l := range reg.lines {
|
||||
if i > win.h-1 {
|
||||
break
|
||||
}
|
||||
|
||||
st = win.print(screen, 2, i, st, l)
|
||||
st = win.print(screen, 0, i, st, l)
|
||||
}
|
||||
}
|
||||
|
||||
sxs.printSixel(win, screen, reg)
|
||||
@@ -637,6 +639,11 @@ func getWins(screen tcell.Screen) []*win {
|
||||
return wins
|
||||
}
|
||||
|
||||
type menuSelect struct {
|
||||
x, y int
|
||||
s string
|
||||
}
|
||||
|
||||
type ui struct {
|
||||
screen tcell.Screen
|
||||
sxScreen sixelScreen
|
||||
@@ -646,7 +653,6 @@ type ui struct {
|
||||
msgWin *win
|
||||
menuWin *win
|
||||
msg string
|
||||
msgIsStat bool
|
||||
regPrev *reg
|
||||
dirPrev *dir
|
||||
exprChan chan expr
|
||||
@@ -654,6 +660,7 @@ type ui struct {
|
||||
tevChan chan tcell.Event
|
||||
evChan chan tcell.Event
|
||||
menu string
|
||||
menuSelect *menuSelect
|
||||
cmdPrefix string
|
||||
cmdAccLeft []rune
|
||||
cmdAccRight []rune
|
||||
@@ -676,7 +683,6 @@ func newUI(screen tcell.Screen) *ui {
|
||||
promptWin: newWin(wtot, 1, 0, 0),
|
||||
msgWin: newWin(wtot, 1, 0, htot-1),
|
||||
menuWin: newWin(wtot, 1, 0, htot-2),
|
||||
msgIsStat: true,
|
||||
exprChan: make(chan expr, 1000),
|
||||
keyChan: make(chan string, 1000),
|
||||
tevChan: make(chan tcell.Event, 1000),
|
||||
@@ -734,7 +740,6 @@ func (ui *ui) sort() {
|
||||
|
||||
func (ui *ui) echo(msg string) {
|
||||
ui.msg = msg
|
||||
ui.msgIsStat = false
|
||||
}
|
||||
|
||||
func (ui *ui) echomsg(msg string) {
|
||||
@@ -742,14 +747,6 @@ func (ui *ui) echomsg(msg string) {
|
||||
log.Print(msg)
|
||||
}
|
||||
|
||||
func optionToFmtstr(optstr string) string {
|
||||
if !strings.Contains(optstr, "%s") {
|
||||
return optstr + "%s\033[0m"
|
||||
} else {
|
||||
return optstr
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *ui) echoerr(msg string) {
|
||||
ui.echo(fmt.Sprintf(optionToFmtstr(gOpts.errorfmt), msg))
|
||||
log.Printf("error: %s", msg)
|
||||
@@ -768,7 +765,7 @@ type reg struct {
|
||||
loadTime time.Time
|
||||
path string
|
||||
lines []string
|
||||
sixel *string
|
||||
sixel bool
|
||||
}
|
||||
|
||||
func (ui *ui) loadFile(app *app, volatile bool) {
|
||||
@@ -801,57 +798,6 @@ func (ui *ui) loadFile(app *app, volatile bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *ui) loadFileInfo(nav *nav) {
|
||||
if !nav.init {
|
||||
return
|
||||
}
|
||||
|
||||
ui.msg = ""
|
||||
ui.msgIsStat = true
|
||||
|
||||
curr, err := nav.currFile()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if curr.err != nil {
|
||||
ui.echoerrf("stat: %s", curr.err)
|
||||
return
|
||||
}
|
||||
|
||||
statfmt := strings.ReplaceAll(gOpts.statfmt, "|", "\x1f")
|
||||
replace := func(s string, val string) {
|
||||
if val == "" {
|
||||
val = "\x00"
|
||||
}
|
||||
statfmt = strings.ReplaceAll(statfmt, s, val)
|
||||
}
|
||||
if nav.isVisualMode() {
|
||||
replace("%m", "VISUAL")
|
||||
replace("%M", "VISUAL")
|
||||
} else {
|
||||
replace("%m", "")
|
||||
replace("%M", "NORMAL")
|
||||
}
|
||||
replace("%p", curr.Mode().String())
|
||||
replace("%c", linkCount(curr))
|
||||
replace("%u", userName(curr))
|
||||
replace("%g", groupName(curr))
|
||||
replace("%s", humanize(uint64(curr.Size())))
|
||||
replace("%S", fmt.Sprintf("%5s", humanize(uint64(curr.Size()))))
|
||||
replace("%t", curr.ModTime().Format(gOpts.timefmt))
|
||||
replace("%l", curr.linkTarget)
|
||||
|
||||
var fileInfo strings.Builder
|
||||
for _, section := range strings.Split(statfmt, "\x1f") {
|
||||
if !strings.Contains(section, "\x00") {
|
||||
fileInfo.WriteString(section)
|
||||
}
|
||||
}
|
||||
|
||||
ui.msg = fileInfo.String()
|
||||
}
|
||||
|
||||
func (ui *ui) drawPromptLine(nav *nav) {
|
||||
st := tcell.StyleDefault
|
||||
|
||||
@@ -925,13 +871,61 @@ func formatRulerOpt(name string, val string) string {
|
||||
return val
|
||||
}
|
||||
|
||||
func (ui *ui) drawStat(nav *nav) {
|
||||
if ui.msg != "" {
|
||||
ui.msgWin.print(ui.screen, 0, 0, tcell.StyleDefault, ui.msg)
|
||||
return
|
||||
}
|
||||
|
||||
curr, err := nav.currFile()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if curr.err != nil {
|
||||
ui.echoerrf("stat: %s", curr.err)
|
||||
ui.msgWin.print(ui.screen, 0, 0, tcell.StyleDefault, ui.msg)
|
||||
return
|
||||
}
|
||||
|
||||
statfmt := strings.ReplaceAll(gOpts.statfmt, "|", "\x1f")
|
||||
replace := func(s string, val string) {
|
||||
if val == "" {
|
||||
val = "\x00"
|
||||
}
|
||||
statfmt = strings.ReplaceAll(statfmt, s, val)
|
||||
}
|
||||
if nav.isVisualMode() {
|
||||
replace("%m", "VISUAL")
|
||||
replace("%M", "VISUAL")
|
||||
} else {
|
||||
replace("%m", "")
|
||||
replace("%M", "NORMAL")
|
||||
}
|
||||
replace("%p", curr.Mode().String())
|
||||
replace("%c", linkCount(curr))
|
||||
replace("%u", userName(curr))
|
||||
replace("%g", groupName(curr))
|
||||
replace("%s", humanize(uint64(curr.Size())))
|
||||
replace("%S", fmt.Sprintf("%5s", humanize(uint64(curr.Size()))))
|
||||
replace("%t", curr.ModTime().Format(gOpts.timefmt))
|
||||
replace("%l", curr.linkTarget)
|
||||
|
||||
var fileInfo strings.Builder
|
||||
for _, section := range strings.Split(statfmt, "\x1f") {
|
||||
if !strings.Contains(section, "\x00") {
|
||||
fileInfo.WriteString(section)
|
||||
}
|
||||
}
|
||||
|
||||
ui.msgWin.print(ui.screen, 0, 0, tcell.StyleDefault, fileInfo.String())
|
||||
}
|
||||
|
||||
func (ui *ui) drawRuler(nav *nav) {
|
||||
st := tcell.StyleDefault
|
||||
|
||||
dir := nav.currDir()
|
||||
|
||||
ui.msgWin.print(ui.screen, 0, 0, st, ui.msg)
|
||||
|
||||
tot := len(dir.files)
|
||||
ind := min(dir.ind+1, tot)
|
||||
hid := len(dir.allFiles) - tot
|
||||
@@ -1067,6 +1061,38 @@ func (ui *ui) drawBox() {
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *ui) drawMenu() {
|
||||
if ui.menu == "" {
|
||||
return
|
||||
}
|
||||
|
||||
lines := strings.Split(ui.menu, "\n")
|
||||
lines = lines[:len(lines)-1]
|
||||
|
||||
ui.menuWin.h = len(lines)
|
||||
ui.menuWin.y = ui.msgWin.y - ui.menuWin.h
|
||||
|
||||
// clear sixel image if it overlaps with the menu
|
||||
ui.screen.LockRegion(ui.menuWin.x, ui.menuWin.y, ui.menuWin.w, ui.menuWin.h, false)
|
||||
ui.sxScreen.forceClear = true
|
||||
|
||||
for i, line := range lines {
|
||||
var st tcell.Style
|
||||
if i == 0 {
|
||||
st = parseEscapeSequence(gOpts.menuheaderfmt)
|
||||
} else {
|
||||
st = parseEscapeSequence(gOpts.menufmt)
|
||||
}
|
||||
|
||||
ui.menuWin.printLine(ui.screen, 0, i, st, line)
|
||||
}
|
||||
|
||||
if ui.menuSelect != nil {
|
||||
st := parseEscapeSequence(gOpts.menuselectfmt)
|
||||
ui.menuWin.print(ui.screen, ui.menuSelect.x, ui.menuSelect.y, st, ui.menuSelect.s)
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *ui) dirOfWin(nav *nav, wind int) *dir {
|
||||
wins := len(ui.wins)
|
||||
if gOpts.preview {
|
||||
@@ -1104,6 +1130,7 @@ func (ui *ui) draw(nav *nav) {
|
||||
|
||||
switch ui.cmdPrefix {
|
||||
case "":
|
||||
ui.drawStat(nav)
|
||||
ui.drawRuler(nav)
|
||||
ui.screen.HideCursor()
|
||||
case ">":
|
||||
@@ -1140,25 +1167,7 @@ func (ui *ui) draw(nav *nav) {
|
||||
ui.drawBox()
|
||||
}
|
||||
|
||||
if ui.menu != "" {
|
||||
lines := strings.Split(ui.menu, "\n")
|
||||
|
||||
lines = lines[:len(lines)-1]
|
||||
|
||||
ui.menuWin.h = len(lines) - 1
|
||||
ui.menuWin.y = ui.wins[0].h - ui.menuWin.h
|
||||
|
||||
if gOpts.drawbox {
|
||||
ui.menuWin.y += 2
|
||||
}
|
||||
|
||||
ui.menuWin.printLine(ui.screen, 0, 0, st.Bold(true), lines[0])
|
||||
|
||||
for i, line := range lines[1:] {
|
||||
ui.menuWin.printLine(ui.screen, 0, i+1, st, "")
|
||||
ui.menuWin.print(ui.screen, 0, i+1, st, line)
|
||||
}
|
||||
}
|
||||
ui.drawMenu()
|
||||
|
||||
ui.screen.Show()
|
||||
}
|
||||
@@ -1572,6 +1581,7 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
||||
return &callExpr{"cd", []string{dir.path}, 1}
|
||||
}
|
||||
case *tcell.EventResize:
|
||||
clear(nav.regCache)
|
||||
return &callExpr{"redraw", nil, 1}
|
||||
case *tcell.EventError:
|
||||
log.Printf("Got EventError: '%s' at %s", tev.Error(), tev.When())
|
||||
@@ -1669,14 +1679,11 @@ func anyKey() {
|
||||
os.Stdin.Read(b)
|
||||
}
|
||||
|
||||
func listMatches(screen tcell.Screen, matches []compMatch, selectedInd int) string {
|
||||
mlen := len(matches)
|
||||
if mlen < 2 {
|
||||
return ""
|
||||
func listMatches(screen tcell.Screen, matches []compMatch, selectedInd int) (string, *menuSelect) {
|
||||
if len(matches) < 2 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
var b strings.Builder
|
||||
|
||||
wtot, _ := screen.Size()
|
||||
wcol := 0
|
||||
for _, m := range matches {
|
||||
@@ -1685,21 +1692,23 @@ func listMatches(screen tcell.Screen, matches []compMatch, selectedInd int) stri
|
||||
wcol += gOpts.tabstop - wcol%gOpts.tabstop
|
||||
ncol := max(wtot/wcol, 1)
|
||||
|
||||
b.WriteString("possible matches\n")
|
||||
var b strings.Builder
|
||||
b.WriteString("possible matches")
|
||||
|
||||
for i := 0; i < mlen; {
|
||||
for j := 0; j < ncol && i < mlen; i, j = i+1, j+1 {
|
||||
name := matches[i].name
|
||||
w := runeSliceWidth([]rune(name))
|
||||
|
||||
if i == selectedInd {
|
||||
fmt.Fprintf(&b, "\033[7m%s\033[0m%*s", name, wcol-w, "")
|
||||
} else {
|
||||
fmt.Fprintf(&b, "%s%*s", name, wcol-w, "")
|
||||
}
|
||||
for i, match := range matches {
|
||||
if i%ncol == 0 {
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
b.WriteByte('\n')
|
||||
w := runeSliceWidth([]rune(match.name))
|
||||
fmt.Fprintf(&b, "%s%*s", match.name, wcol-w, "")
|
||||
}
|
||||
|
||||
return b.String()
|
||||
b.WriteByte('\n')
|
||||
|
||||
var selection *menuSelect
|
||||
if selectedInd != -1 {
|
||||
selection = &menuSelect{selectedInd % ncol * wcol, selectedInd/ncol + 1, matches[selectedInd].name}
|
||||
}
|
||||
|
||||
return b.String(), selection
|
||||
}
|
||||
Reference in new issue
Block a user