* Export a `$lf` environment variable with path to lf binary
If Go fails to find a path to the lf binary, `$lf` is set to the string `lf` so
that running `$lf` in scripts gives a reasonable error message.
* Make the `:doc` command work even if lf is not in the PATH
Previously, `:doc` executed `lf -doc`. Now, it executed `$lf -doc` or `%lf%
-doc`.
Before this change, `:doc` did not work if `lf` is not in the PATH. This is
likely to happen to new users who are trying out `lf` and need docs the most.
Moreover, if you made some changes to the docs and ran `lf` with `go run .`,
`:doc` would return the docs for the version of `lf` in the PATH instead of
what is expected.
This command inverts the selection for the current file and all the files below
it. Using this command twice substitutes for having a "visual" mode. This is
described in more detail in the docs and in
https://github.com/gokcehan/lf/issues/477#issuecomment-1414563834.
Fixes#477. While that's not exactly what was asked for, I hope it's a suitable
replacement and seems more in the spirit of `lf`, at least until a better
replacement is implemented.
* Add `cursorparentfmt` option for cursors in parent dirs
The option defaults to the same value as `cursorfmt`, so the default look of `lf` is unchanged. However, I find it useful to make it different, since I seem to have so much trouble figuring out which of my cursors is the active one. :)
For example, here's what it looks like if one has `set cursorparentfmt "\033[7;90m"` in their `lfrc`:
https://user-images.githubusercontent.com/4123047/218299130-09ac411f-307a-489e-a4f0-4691710f8549.png
* Remove `cursorfmt` option to `cursoractivefmt`
This seems appropriate after introducing `cursorparentfmt`
* Allow separate styles for cursor in normal and preview panes
This defines new `cursorfmt` and `crusorpreviewfmt` options to style cursor in normal/preview panes. This allows using a different style for the normal and preview cursor. The documentation includes several possible values these options can be set to.
The default behavior is an underline, same as in
https://github.com/gokcehan/lf/pull/1072, since it should not cause severe
problems and be visible on all terminals. It can now be easily changed, as explained in the docs. I also added an example to `etc/lfrc.example`.
See linked issues and PRs for the more context.
Fixes https://github.com/gokcehan/lf/issues/1038
Follows up on:
https://github.com/gokcehan/lf/pull/1072https://github.com/gokcehan/lf/pull/924https://github.com/gokcehan/lf/commit/b47cf6d5a5
* Simplify configuration of several formatting options
This simplifies the configuration of `cursorfmt`, `cursorpreviewfmt`, `tagfmt`,
and `errorfmt` options.
In almost all usecases, the value of these options had to end with `%s\033[0m`
to print the contents of filename/tag/error and reset the terminal style. Now,
if `%s` is not part of the option's value, `%s\033[0m` is appended
automatically. This simplifies configuration.
I retained the same behavior as before when `%s` is part of the string for
backwards compatibility. I think it should be considered deprecated, but it
also causes no harm.
On my system, Shift+Mouse is captured by the terminal and
Alt+Mouse only works for one of the alt keys. Hence I picked
Ctrl.
This also allows binding of Ctrl+MouseButtons (but doesn't set
any such bindings).
As a minor bonus, that should allow using Ctrl+Click to select
`lf`'s terminal without moving the cursor no matter where you
click. On tmux, this doesn't work out of the box and requires
a change to `tmux.conf` along the following lines:
bind-key -T root C-MouseDown1Pane select-pane -t = \; send-keys -M
You can omit the `send-keys -M` if you never want to pass
`Ctrl+Click` to any of your terminal apps. (Then it will work
without this PR).
* When clicking on file preview, only open files on right-click
Currently, when mouse is on, I often click on the preview accidentally
since it's such a large target. Moreover, there is very little space I
can click without having the `lf` state change drastically (since I must
click on the current file for the preview to stay the same).
This commit prevents that.
* (Minor): Change example in docs to work around a bug
Currently, the example fails confusingly for newer versions
of `tput`. See https://github.com/gokcehan/lf/issues/718.
* Add mouse support for selecting and opening files
Left click to select, right click to open, similar to ranger.
Closes#919.
* Add default mouse wheel mappings
* Update tcell to d3cbfcf
Commit d3cbfcf fixes a bug where mouse wheel events were misdelivered as
button events.
* Directory previews, initial implementation.
* Continue previous; add goroutine for directory previews.
* Enable dirpreviews as an option, run gofmt and fix referencing nil.
* Only use dirpreviews if previewer script exists.
* Remove redundant function call to `dirPreview`.
* Remove unnecessary dev-comments.
* Send to `dirPreviewChan` also on modifying folder contents.
* Fix some multibyte character completion bugs
- matchLongest now operates on runes instead of bytes so we don't
complete part of a multibyte character.
- Fix some places that mixed string and rune slice indices.
* Fix wrong menu completion for subdirectories
When selecting a menu completion for a file in a subdirectory, the
entire filename would be appended to the command line, even if you had
already typed part of it.
* Escape file completions in menu completion
* Minor refactors and typo fixes
* Fix cmd-menu-complete-back bug
The first use of cmd-menu-complete-back after opening the completion
menu was incorrectly selecting the before-last completion instead of the
last completion.
* Allow completing broken symlinks
Also skip files with stat errors instead of returning.
* Add command to accept current menu selection
This is useful when completing filenames. For example
cmap <c-y> :cmd-menu-accept; cmd-menu-complete
can be used to accept the selected directory completion, then complete
files in the directory.
* Complete command names for map and cmap
- Document history option
- Use $() command substitution syntax because backticks are replaced
with quotes in gen/docstring.sh
- Movement commands no longer close the search prompt (85aa3b9)
- Use the -L flag of the file command instead of readlink
* initial tags implementation
* add tag to complete.go
* add gTagsPath to os_windows.go
* change behaviour to match other commands
* add tag-toggle to complete.go
* add tag and tag-toggle to docs
* address feedback about tags
* add scrollup scrolldown builtin cmd
Scrollup/down move window pane without moving current cursor position.
Default keybinding would be <c-y> for scrollup and <c-e> for scrolldown
just like in vim.
* limit scrolldown when reached bottom
scrolodown will not allow empty space
Fix typo