* 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.
# What this does
This makes the following changes:
1. If the we are in any of the shell command-line modes (after pressing one of
`!/$/%/&`) and the cursor is at the first character, pressing `backspace`
switches you to the `:` mode. Pressing `backspace` again will take you out of
the command-line mode as before (this commit extends the recent [escape on
backspace] functionality).
[escape on backspace]: https://github.com/gokcehan/lf/commit/36a7a18316580864f2f2ebd79e9ddae4858f6b60
2. Conversely, if we are in the `:` mode and the cursor is at the first
character, pressing one of `!/$/%/&` will take you to the corresponding mode
insted of inserting that character. This is a very minor change, since already
pressing `:!ls<ret>` and `!ls <ret>` in `lf` has the same effect. After this
commit, these will also look the same even before pressing `<ret>`.
3. There is a minor bugfix to the [escape on backspace] commit. In `>` mode
(when a program launched with `&` waits for input), `lf` currently switches to
normal mode on `backspace` without terminating the program. After this commit,
the "escape on backspace" functionality is disabled in `>` mode.
This idea is borrowed from the [Julia REPL modes].
[Julia REPL modes]: https://docs.julialang.org/en/v1/stdlib/REPL/#Help-mode
# What problems this solves
The main problem I want to solve is that I often type `$ls <many options>` and
realize I wanted `!ls` all along. Currently, there is no easy way to switch.
With this commit, it becomes trivial.
This problem also occurs when you scroll up to a `$ls <many options>` command
in history.
Finally, since `!` and `:!` have essentially the same effect in `lf`, I think
they should look the same.
- Clean up some code duplication.
- When completing files with menu completion while searching, don't
escape the selected match.
- Don't recompute completions while cycling completion menu.
* Revert escaping changes from cb7aa13
The changes introduced a bug where escapes were removed when there are
no completion matches.
* Add option to ignore case in filename completion
* Remove compignorecase option and hardcode it
* Get command default count from definition
The command count defined in opts.go will be respected. In order to do that a copy of the callExpr or listExpr command is created so that the defined count is not overridden.
* Copy the command only if we need to overwrite the count
* 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.
Previously the history position was only reset when executing the
history prev/next command in normal mode, so it was not reset if you
entered command-line mode then started moving through the history.