* Replace functions from `ioutil` with same functions from `io`
This is demanded by staticcheck if we upgrade the go version in go.mod.
* Replace ioutil.ReadDir with os.ReadDir
* Update Go version to 1.18 in go.mod
This requires abandoning use of the `ioutil` module (see parent commits)
to pass `staticcheck`.
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.
After looking at the list of possibilities for `app.ui.cmdPrefix` by searching
through the code, renaming looks to be the only remaining mode where exiting
via backspace doesn't make sense.
In particular, I don't think any commands other than `rename` commonly start
out with some editable text in the prompt. The other dangerous mode is the `>`
mode, but there exit-on-backspace was already disabled.
Fixes#1052, #1059
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.
* Fix Staticcheck errors & minor logic simplification
Simplify logic in ui.go. In that diff, `st` would already have the
Reversed flag set; there's no need to set it again.
Also, minor changes to remove all the statickcheck errors VS code's
Go extension complains about.
* Add staticcheck and Go 1.19 go-generate Github check
This adds a few Github action checks:
1. Check that `go fmt` and `go generate` were run on Go 1.19, following
up on https://github.com/gokcehan/lf/commit/654b8737b8a35729aa89aa93acf05ed5871b2616.
On earlier Go versions, `go generate` results in whitespace changes.
2. Check that [Staticcheck](https://staticcheck.io/) passes.
* For directories in preview column, dim cursor
When preview is on and consists of a directory listing, make the
cursor in there dimmer to emphasize it's not active. This makes it
visually obvious which cursor is active at all times, without
having to read the path. The active cursor is now always the
rightmost bright one, regardless of whether the `preview` option
is on or off.
See screenshots in the pull request at
https://github.com/gokcehan/lf/pull/924.
Before this, I noticed that I often open a file by accident because
I got confused which of the three cursors on the screen is the active
one.
* No-op changes to ui.go
Reduce number of arguments to printDir and list non-configurable colors
Simplify logic in ui.go. In that diff, `st` would already have the
Reversed flag set; there's no need to set it again.
Also, minor changes to remove all the statickcheck errors VS code's
Go extension complains about.