mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-08 11:23:47 -05:00
Compare commits
35 Commits
edd08d5cc6
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f793bfa46c | ||
|
|
8cdfb23df6 | ||
|
|
4ffde48e2f | ||
|
|
f2b33f038a | ||
|
|
d5913bf86e | ||
|
|
0e9026b817 | ||
|
|
ab407c4645 | ||
|
|
91c4bef35f | ||
|
|
bf77206221 | ||
|
|
0cb1be3f04 | ||
|
|
01cb38a5fb | ||
|
|
c38c6cad79 | ||
|
|
ba6fc40cfd | ||
|
|
dd46a256c0 | ||
|
|
d19ce0ad8d | ||
|
|
ed7becfb47 | ||
|
|
9ace1351ff | ||
|
|
e1de29bc40 | ||
|
|
0df7d10550 | ||
|
|
91e119a77e | ||
|
|
3984161f6c | ||
|
|
91beacf0f4 | ||
|
|
e6ad01fb90 | ||
|
|
ce2200e908 | ||
|
|
548061dbde | ||
|
|
8f0c91545d | ||
|
|
0eefcf348e | ||
|
|
c1f8d18a0c | ||
|
|
8585969d6d | ||
|
|
8a943a9b1a | ||
|
|
c87a8eccd4 | ||
|
|
65df0abf0e | ||
|
|
b51bc6b50e | ||
|
|
febaadbee5 | ||
|
|
0e67c5aa7a |
2
.github/workflows/linux.yml
vendored
2
.github/workflows/linux.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.23"
|
||||
|
||||
|
||||
2
.github/workflows/macos.yml
vendored
2
.github/workflows/macos.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.23"
|
||||
|
||||
|
||||
300
CHANGELOG.md
300
CHANGELOG.md
@@ -3,30 +3,292 @@ CHANGELOG
|
||||
|
||||
0.66.0
|
||||
------
|
||||
- Style changes
|
||||
- Updated `--color base16` (alias: `16`) theme so that it works better with both dark and light themes.
|
||||
- Narrowed the gutter column by using the left-half block character (`▌`).
|
||||
- Removed background colors from markers.
|
||||
- Added `--gutter CHAR` option for customizing the gutter column. Some examples using [box-drawing characters](https://en.wikipedia.org/wiki/Box-drawing_characters):
|
||||
```sh
|
||||
# Right-aligned gutter
|
||||
fzf --gutter '▐'
|
||||
|
||||
# Even thinner gutter
|
||||
fzf --gutter '▎'
|
||||
### Quick summary
|
||||
|
||||
# Checker
|
||||
fzf --gutter '▚'
|
||||
This version introduces many new features centered around the new "raw" mode.
|
||||
|
||||
# Dotted
|
||||
fzf --gutter '▖'
|
||||
| Type | Class | Name | Description |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| New | Option | `--raw` | Enable raw mode by default |
|
||||
| New | Option | `--gutter CHAR` | Set the gutter column character |
|
||||
| New | Option | `--gutter-raw CHAR` | Set the gutter column character in raw mode |
|
||||
| Enhancement | Option | `--listen SOCKET` | Added support for Unix domain sockets |
|
||||
| New | Action | `toggle-raw` | Toggle raw mode |
|
||||
| New | Action | `enable-raw` | Enable raw mode |
|
||||
| New | Action | `disable-raw` | Disable raw mode |
|
||||
| New | Action | `up-match` | Move up to the matching item |
|
||||
| New | Action | `down-match` | Move down to the matching item |
|
||||
| New | Action | `best` | Move to the matching item with the best score |
|
||||
| New | Color | `nomatch` | Color for non-matching items in raw mode |
|
||||
| New | Env Var | `FZF_RAW` | Matching status in raw mode (0, 1, or undefined) |
|
||||
| New | Env Var | `FZF_DIRECTION` | `up` or `down` depending on the layout |
|
||||
| New | Env Var | `FZF_SOCK` | Path to the Unix domain socket fzf is listening on |
|
||||
| Enhancement | Key | `CTRL-N` | `down` -> `down-match` |
|
||||
| Enhancement | Key | `CTRL-P` | `up` -> `up-match` |
|
||||
| Enhancement | Shell | `CTRL-R` binding | Toggle raw mode with `ALT-R` |
|
||||
| Enhancement | Shell | `CTRL-R` binding | Opt-out with an empty `FZF_CTRL_R_COMMAND` |
|
||||
|
||||
# Full-width
|
||||
fzf --gutter '█'
|
||||
### 1. Introducing "raw" mode
|
||||
|
||||
# No gutter
|
||||
fzf --gutter ' '
|
||||
```
|
||||

|
||||
|
||||
This version introduces a new "raw" mode (named so because it shows the list
|
||||
"unfiltered"). In raw mode, non-matching items stay in their original positions,
|
||||
but appear dimmed. This allows you see surrounding items of a match and better
|
||||
understand the context of it. You can enable raw mode by default with `--raw`,
|
||||
but it's often more useful when toggled dynamically with the `toggle-raw`
|
||||
action.
|
||||
|
||||
```sh
|
||||
tree | fzf --reverse --bind alt-r:toggle-raw
|
||||
```
|
||||
|
||||
While non-matching items are displayed in a dimmed color, they are treated just
|
||||
like matching items, so you place the cursor on them and perform any action. If
|
||||
you prefer to navigate only through matching items, use the `down-match` and
|
||||
`up-match` actions, which are from now on bound to `CTRL-N` and `CTRL-P`
|
||||
respectively, and also to `ALT-DOWN` and `ALT-UP`.
|
||||
|
||||
| Key | Action | With `--history` |
|
||||
| :-- | :-- | :-- |
|
||||
| `down` | `down` | |
|
||||
| `up` | `up` | |
|
||||
| `ctrl-j` | `down` | |
|
||||
| `ctrl-k` | `up` | |
|
||||
| `ctrl-n` | `down-match` | `next-history` |
|
||||
| `ctrl-p` | `up-match` | `prev-history` |
|
||||
| `alt-down` | `down-match` | |
|
||||
| `alt-up` | `up-match` | |
|
||||
|
||||
> [!NOTE]
|
||||
> `CTRL-N` and `CTRL-P` are bound to `next-history` and `prev-history` when
|
||||
> `--history` option is enabled, so in that case, you'll need to manually bind
|
||||
> them, or use `ALT-DOWN` and `ALT-UP` instead.
|
||||
|
||||
> [!TIP]
|
||||
> `up-match` and `down-match` are equivalent to `up` and `down` when not in
|
||||
> raw mode, so you can safely bind them to `up` and `arrow` keys if you prefer.
|
||||
> ```sh
|
||||
> fzf --bind up:up-match,down:down-match
|
||||
> ```
|
||||
|
||||
#### Customizing the behavior
|
||||
|
||||
In raw mode, the input list is presented in its original order, unfiltered, and
|
||||
your cursor will not move to the matching item automatically. Here are ways to
|
||||
customize the behavior.
|
||||
|
||||
```sh
|
||||
# When the result list is updated, move the cursor to the item with the best score
|
||||
# (assuming sorting is not disabled)
|
||||
fzf --raw --bind result:best
|
||||
|
||||
# Move to the first matching item in the original list
|
||||
# - $FZF_RAW is set to 0 when raw mode is enabled and the current item is a non-match
|
||||
# - $FZF_DIRECTION is set to either 'up' or 'down' depending on the layout direction
|
||||
fzf --raw --bind 'result:first+transform:[[ $FZF_RAW = 0 ]] && echo $FZF_DIRECTION-match'
|
||||
```
|
||||
|
||||
#### Customizing the look
|
||||
|
||||
##### Gutter
|
||||
|
||||
To make the mode visually distinct, the gutter column is rendered in a dashed
|
||||
line using `▖` character. But you can customize it with the `--gutter-raw CHAR`
|
||||
option.
|
||||
|
||||
```sh
|
||||
# Use a thinner gutter instead of the default dashed line
|
||||
fzf --bind alt-r:toggle-raw --gutter-raw ▎
|
||||
```
|
||||
|
||||
##### Color and style of non-matching items
|
||||
|
||||
Non-matching items are displayed in a dimmed color by default, but you can
|
||||
change it with the `--color nomatch:...` option.
|
||||
|
||||
```sh
|
||||
fzf --raw --color nomatch:red
|
||||
fzf --raw --color nomatch:red:dim
|
||||
fzf --raw --color nomatch:red:dim:strikethrough
|
||||
fzf --raw --color nomatch:red:dim:strikethrough:italic
|
||||
```
|
||||
|
||||
For colored input, dimming alone may not be enough, and you may prefer to remove
|
||||
colors entirely. For that case, a new special style attribute `strip` has been
|
||||
added.
|
||||
|
||||
```sh
|
||||
fd --color always | fzf --ansi --raw --color nomatch:dim:strip:strikethrough
|
||||
```
|
||||
|
||||
#### Conditional actions for raw mode
|
||||
|
||||
You may want to perform different actions depending on whether the current item
|
||||
is a match or not. For that, fzf now exports `$FZF_RAW` environment variable.
|
||||
|
||||
It's:
|
||||
|
||||
- Undefined if raw mode is disabled
|
||||
- `1` if the current item is a match
|
||||
- `0` otherwise
|
||||
|
||||
```sh
|
||||
# Do not allow selecting non-matching items
|
||||
fzf --raw --bind 'enter:transform:[[ ${FZF_RAW-1} = 1 ]] && echo accept || echo bell'
|
||||
```
|
||||
|
||||
#### Leveraging raw mode in shell integration
|
||||
|
||||
The `CTRL-R` binding (command history) now lets you toggle raw mode with `ALT-R`.
|
||||
|
||||
### 2. Style changes
|
||||
|
||||
The screenshot on the right shows the updated gutter style:
|
||||
|
||||

|
||||
|
||||
This version includes a few minor updates to fzf's classic visual style:
|
||||
|
||||
- The gutter column is now narrower, rendered with the left-half block character (`▌`).
|
||||
- Markers no longer use background colors.
|
||||
- The `--color base16` theme (alias: `16`) has been updated for better compatibility with both dark and light themes.
|
||||
|
||||
### 3. `--listen` now supports Unix domain sockets
|
||||
|
||||
If an argument to `--listen` ends with `.sock`, fzf will listen on a Unix
|
||||
domain socket at the specified path.
|
||||
|
||||
```sh
|
||||
fzf --listen /tmp/fzf.sock --no-tmux
|
||||
|
||||
# GET
|
||||
curl --unix-socket /tmp/fzf.sock http
|
||||
|
||||
# POST
|
||||
curl --unix-socket /tmp/fzf.sock http -d up
|
||||
```
|
||||
|
||||
Note that any existing file at the given path will be removed before creating
|
||||
the socket, so avoid using an important file path.
|
||||
|
||||
### 4. Added options
|
||||
|
||||
#### `--gutter CHAR`
|
||||
|
||||
The gutter column can now be customized using `--gutter CHAR` and styled with
|
||||
`--color gutter:...`. Examples:
|
||||
|
||||
```sh
|
||||
# Right-aligned gutter
|
||||
fzf --gutter '▐'
|
||||
|
||||
# Even thinner gutter
|
||||
fzf --gutter '▎'
|
||||
|
||||
# Yellow checker pattern
|
||||
fzf --gutter '▚' --color gutter:yellow
|
||||
|
||||
# Classic style
|
||||
fzf --gutter ' ' --color gutter:reverse
|
||||
```
|
||||
|
||||
#### `--gutter-raw CHAR`
|
||||
|
||||
As noted above, the `--gutter-raw CHAR` option was also added for customizing the gutter column in raw mode.
|
||||
|
||||
### 5. Added actions
|
||||
|
||||
The following actions were introduced to support working with raw mode:
|
||||
|
||||
| Action | Description |
|
||||
| :-- | :-- |
|
||||
| `toggle-raw` | Toggle raw mode |
|
||||
| `enable-raw` | Enable raw mode |
|
||||
| `disable-raw` | Disable raw mode |
|
||||
| `up-match` | Move up to the matching item; identical to `up` if raw mode is disabled |
|
||||
| `down-match` | Move down to the matching item; identical to `down` if raw mode is disabled |
|
||||
| `best` | Move to the matching item with the best score; identical to `first` if raw mode is disabled |
|
||||
|
||||
### 6. Added environment variables
|
||||
|
||||
#### `$FZF_DIRECTION`
|
||||
|
||||
`$FZF_DIRECTION` is now exported to child processes, indicating the list direction of the current layout:
|
||||
|
||||
- `up` for the default layout
|
||||
- `down` for `reverse` or `reverse-list`
|
||||
|
||||
This simplifies writing transform actions involving layout-dependent actions
|
||||
like `{up,down}-match`, `{up,down}-selected`, and `toggle+{up,down}`.
|
||||
|
||||
```sh
|
||||
fzf --raw --bind 'result:first+transform:[[ $FZF_RAW = 0 ]] && echo $FZF_DIRECTION-match'
|
||||
```
|
||||
|
||||
#### `$FZF_SOCK`
|
||||
|
||||
When fzf is listening on a Unix domain socket using `--listen`, the path to the
|
||||
socket is exported as `$FZF_SOCK`, analogous to `$FZF_PORT` for TCP sockets.
|
||||
|
||||
#### `$FZF_RAW`
|
||||
|
||||
As described above, `$FZF_RAW` is now exported to child processes in raw mode,
|
||||
indicating whether the current item is a match (`1`) or not (`0`). It is not
|
||||
defined when not in raw mode.
|
||||
|
||||
#### `$FZF_CTRL_R_COMMAND`
|
||||
|
||||
You can opt-out `CTRL-R` binding from the shell integration by setting
|
||||
`FZF_CTRL_R_COMMAND` to an empty string. Setting it to any other value is not
|
||||
supported and will result in a warning.
|
||||
|
||||
```sh
|
||||
# Disable the CTRL-R binding from the shell integration
|
||||
FZF_CTRL_R_COMMAND= eval "$(fzf --bash)"
|
||||
```
|
||||
|
||||
### 7. Added key support for `--bind`
|
||||
|
||||
Pull request [#3996](https://github.com/junegunn/fzf/pull/3996) added support
|
||||
for many additional keys for `--bind` option, such as `ctrl-backspace`.
|
||||
|
||||
### 8. Breaking changes
|
||||
|
||||
#### Hiding the gutter column
|
||||
|
||||
In the previous versions, the recommended way to hide the gutter column was to
|
||||
set `--color gutter:-1`. That's because the gutter column was just a space
|
||||
character, reversed. But now that it's using a visible character (`▌`), applying
|
||||
the default color is no longer enough to hide it. Instead, you can set it to
|
||||
a space character.
|
||||
|
||||
```sh
|
||||
# Hide the gutter column
|
||||
fzf --gutter ' '
|
||||
|
||||
# Classic style
|
||||
fzf --gutter ' ' --color gutter:reverse
|
||||
```
|
||||
|
||||
#### `--color` option
|
||||
|
||||
In the previous versions, some elements had default style attributes applied and
|
||||
you would have to explicitly unset them with `regular` attribute if you wanted
|
||||
to reset them. This is no longer needed now, as the default style attributes
|
||||
are applied only when you do not specify any color or style for that element.
|
||||
|
||||
```sh
|
||||
# No 'dim', just red and italic.
|
||||
fzf --ghost 'Type to search' --color ghost:red:italic
|
||||
```
|
||||
|
||||
#### Compatibility changes
|
||||
|
||||
Starting with this release, fzf is built with Go 1.23. Support for some old OS versions has been dropped.
|
||||
|
||||
See https://go.dev/wiki/MinimumRequirements.
|
||||
|
||||
0.65.2
|
||||
------
|
||||
|
||||
6
go.mod
6
go.mod
@@ -6,8 +6,8 @@ require (
|
||||
github.com/junegunn/go-shellwords v0.0.0-20250127100254-2aa3b3277741
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/rivo/uniseg v0.4.7
|
||||
golang.org/x/sys v0.35.0
|
||||
golang.org/x/term v0.34.0
|
||||
golang.org/x/sys v0.37.0
|
||||
golang.org/x/term v0.36.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -17,4 +17,4 @@ require (
|
||||
golang.org/x/text v0.28.0 // indirect
|
||||
)
|
||||
|
||||
go 1.23.0
|
||||
go 1.24.0
|
||||
|
||||
8
go.sum
8
go.sum
@@ -34,13 +34,13 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
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.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
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.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
|
||||
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
|
||||
golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
|
||||
golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
|
||||
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=
|
||||
|
||||
2
install
2
install
@@ -2,7 +2,7 @@
|
||||
|
||||
set -u
|
||||
|
||||
version=0.65.2
|
||||
version=0.66.0
|
||||
auto_completion=
|
||||
key_bindings=
|
||||
update_config=2
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$version="0.65.2"
|
||||
$version="0.66.0"
|
||||
|
||||
$fzf_base=Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
|
||||
|
||||
2
main.go
2
main.go
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/junegunn/fzf/src/protector"
|
||||
)
|
||||
|
||||
var version = "0.65"
|
||||
var version = "0.66"
|
||||
var revision = "devel"
|
||||
|
||||
//go:embed shell/key-bindings.bash
|
||||
|
||||
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
..
|
||||
.TH fzf\-tmux 1 "Aug 2025" "fzf 0.65.2" "fzf\-tmux - open fzf in tmux split pane"
|
||||
.TH fzf\-tmux 1 "Oct 2025" "fzf 0.66.0" "fzf\-tmux - open fzf in tmux split pane"
|
||||
|
||||
.SH NAME
|
||||
fzf\-tmux - open fzf in tmux split pane
|
||||
|
||||
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
..
|
||||
.TH fzf 1 "Sep 2025" "fzf 0.66.0" "fzf - a command-line fuzzy finder"
|
||||
.TH fzf 1 "Oct 2025" "fzf 0.66.0" "fzf - a command-line fuzzy finder"
|
||||
|
||||
.SH NAME
|
||||
fzf - a command-line fuzzy finder
|
||||
@@ -299,6 +299,7 @@ color mappings. Each entry is separated by a comma and/or whitespaces.
|
||||
\fBheader (header\-fg) \fRHeader
|
||||
\fBfooter (footer\-fg) \fRFooter
|
||||
\fBnth \fRParts of the line specified by \fB\-\-nth\fR (only supports attributes)
|
||||
\fBnomatch \fRNon-matching items in raw mode (default: \fBdim\fR)
|
||||
|
||||
.B ANSI COLORS:
|
||||
\fB\-1 \fRDefault terminal foreground/background color
|
||||
@@ -324,7 +325,8 @@ color mappings. Each entry is separated by a comma and/or whitespaces.
|
||||
\fB#rrggbb \fR24-bit colors
|
||||
|
||||
.B ANSI ATTRIBUTES: (Only applies to foreground colors)
|
||||
\fBregular \fRClears previously set attributes; should precede the other ones
|
||||
\fBregular \fRClear previously set attributes; should precede the other ones
|
||||
\fBstrip \fRRemove colors
|
||||
\fBbold\fR
|
||||
\fBunderline\fR
|
||||
\fBreverse\fR
|
||||
@@ -596,6 +598,9 @@ Indicator for wrapped lines. The default is '↳ ' or '> ' depending on
|
||||
.B "\-\-no\-multi\-line"
|
||||
Disable multi-line display of items when using \fB\-\-read0\fR
|
||||
.TP
|
||||
.B "\-\-raw"
|
||||
Enable raw mode where non-matching items are also displayed in a dimmed color.
|
||||
.TP
|
||||
.B "\-\-track"
|
||||
Make fzf track the current selection when the result list is updated.
|
||||
This can be useful when browsing logs using fzf with sorting disabled. It is
|
||||
@@ -1128,19 +1133,25 @@ On Windows, the default value is \fBcmd /s/c\fR when \fB$SHELL\fR is not
|
||||
set.
|
||||
|
||||
.TP
|
||||
.B "\-\-listen[=[ADDR:]PORT]" "\-\-listen\-unsafe[=[ADDR:]PORT]"
|
||||
Start HTTP server and listen on the given address. It allows external processes
|
||||
to send actions to perform via POST method.
|
||||
.B "\-\-listen[=SOCKET_PATH|[ADDR:]PORT]" "\-\-listen\-unsafe[=[ADDR:]PORT]"
|
||||
Start HTTP server and listen on the given address or Unix socket. It allows
|
||||
external processes to send actions to perform via POST method and query the
|
||||
program state via GET method. For the argument to be recognized as a socket
|
||||
path, it must have \fB.sock\fR extension.
|
||||
|
||||
- If the port number is omitted or given as 0, fzf will automatically choose
|
||||
a port and export it as \fBFZF_PORT\fR environment variable to the child processes
|
||||
a port and export it as \fBFZF_PORT\fR environment variable to the child processes.
|
||||
|
||||
- If a Unix socket path is given, fzf will create a Unix domain socket at the
|
||||
given path. The existing file will be removed. The path to the socket file
|
||||
is exported as \fBFZF_SOCK\fR environment variable.
|
||||
|
||||
- If \fBFZF_API_KEY\fR environment variable is set, the server would require
|
||||
sending an API key with the same value in the \fBx\-api\-key\fR HTTP header
|
||||
sending an API key with the same value in the \fBx\-api\-key\fR HTTP header.
|
||||
|
||||
- \fBFZF_API_KEY\fR is required for a non-localhost listen address
|
||||
- \fBFZF_API_KEY\fR is required for a non-localhost listen address.
|
||||
|
||||
- To allow remote process execution, use \fB\-\-listen\-unsafe\fR
|
||||
- To allow remote process execution, use \fB\-\-listen\-unsafe\fR.
|
||||
|
||||
e.g.
|
||||
\fB# Start HTTP server on port 6266
|
||||
@@ -1179,6 +1190,18 @@ e.g.
|
||||
'
|
||||
\fR
|
||||
|
||||
Here is an example script that uses a Unix socket instead of a TCP port.
|
||||
|
||||
\fB
|
||||
fzf --listen=/tmp/fzf.sock
|
||||
|
||||
# GET
|
||||
curl --unix-socket /tmp/fzf.sock http
|
||||
|
||||
# POST
|
||||
curl --unix-socket /tmp/fzf.sock http -d up
|
||||
\fR
|
||||
|
||||
.SS DIRECTORY TRAVERSAL
|
||||
.TP
|
||||
.B "\-\-walker=[file][,dir][,follow][,hidden]"
|
||||
@@ -1330,6 +1353,8 @@ fzf exports the following environment variables to its child processes.
|
||||
.br
|
||||
.BR FZF_COLUMNS " Number of columns fzf takes up excluding padding and margin"
|
||||
.br
|
||||
.BR FZF_DIRECTION " Direction of the list (\fBup\fR or \fBdown\fR)"
|
||||
.br
|
||||
.BR FZF_TOTAL_COUNT " Total number of items"
|
||||
.br
|
||||
.BR FZF_MATCH_COUNT " Number of matched items"
|
||||
@@ -1366,6 +1391,8 @@ fzf exports the following environment variables to its child processes.
|
||||
.br
|
||||
.BR FZF_PORT " Port number when \-\-listen option is used"
|
||||
.br
|
||||
.BR FZF_SOCK " Unix socket path when \-\-listen option is used"
|
||||
.br
|
||||
.BR FZF_PREVIEW_TOP " Top position of the preview window"
|
||||
.br
|
||||
.BR FZF_PREVIEW_LEFT " Left position of the preview window"
|
||||
@@ -1373,6 +1400,8 @@ fzf exports the following environment variables to its child processes.
|
||||
.BR FZF_PREVIEW_LINES " Number of lines in the preview window"
|
||||
.br
|
||||
.BR FZF_PREVIEW_COLUMNS " Number of columns in the preview window"
|
||||
.br
|
||||
.BR FZF_RAW " Only in raw mode. 1 if the current item matches, 0 otherwise"
|
||||
|
||||
.SH EXTENDED SEARCH MODE
|
||||
|
||||
@@ -1817,6 +1846,7 @@ A key or an event can be bound to one or more of the following actions.
|
||||
\fBbecome(...)\fR (replace fzf process with the specified command; see below for the details)
|
||||
\fBbeginning\-of\-line\fR \fIctrl\-a home\fR
|
||||
\fBbell\fR (ring the terminal bell)
|
||||
\fBbest\fR (move to the best match; same as \fBfirst\fR if raw mode is disabled)
|
||||
\fBbg\-cancel\fR (cancel background transform processes)
|
||||
\fBcancel\fR (clear query string if not empty, abort fzf otherwise)
|
||||
\fBchange\-border\-label(...)\fR (change \fB\-\-border\-label\fR to the given string)
|
||||
@@ -1841,9 +1871,13 @@ A key or an event can be bound to one or more of the following actions.
|
||||
\fBdelete\-char\fR \fIdel\fR
|
||||
\fBdelete\-char/eof\fR \fIctrl\-d\fR (same as \fBdelete\-char\fR except aborts fzf if query is empty)
|
||||
\fBdeselect\fR
|
||||
\fBdeselect\-all\fR (deselect all matches; to also clear non-matched selections, use \fBclear\-multi\fR)
|
||||
\fBdeselect\-all\fR (deselect all matches; to also clear non-matching selections, use \fBclear\-multi\fR)
|
||||
\fBdisable\-raw\fR (disable raw mode)
|
||||
\fBdisable\-search\fR (disable search functionality)
|
||||
\fBdown\fR \fIctrl\-j ctrl\-n down\fR
|
||||
\fBdown\fR \fIctrl\-j down\fR
|
||||
\fBdown\-match\fR \fIctrl\-n\fR \fIalt\-down\fR (move to the match below the cursor)
|
||||
\fBdown\-selected\fR (move to the selected item below the cursor)
|
||||
\fBenable\-raw\fR (enable raw mode)
|
||||
\fBenable\-search\fR (enable search functionality)
|
||||
\fBend\-of\-line\fR \fIctrl\-e end\fR
|
||||
\fBexclude\fR (exclude the current item from the result)
|
||||
@@ -1861,7 +1895,7 @@ A key or an event can be bound to one or more of the following actions.
|
||||
\fBkill\-word\fR \fIalt\-d\fR
|
||||
\fBlast\fR (move to the last match; same as \fBpos(\-1)\fR)
|
||||
\fBnext\-history\fR (\fIctrl\-n\fR on \fB\-\-history\fR)
|
||||
\fBnext\-selected\fR (move to the next selected item)
|
||||
\fBnext\-selected\fR (synonym to \fBdown\-selected\fR)
|
||||
\fBpage\-down\fR \fIpgdn\fR
|
||||
\fBpage\-up\fR \fIpgup\fR
|
||||
\fBhalf\-page\-down\fR
|
||||
@@ -1874,7 +1908,7 @@ A key or an event can be bound to one or more of the following actions.
|
||||
\fBoffset\-middle\fR (place the current item is in the middle of the screen)
|
||||
\fBpos(...)\fR (move cursor to the numeric position; negative number to count from the end)
|
||||
\fBprev\-history\fR (\fIctrl\-p\fR on \fB\-\-history\fR)
|
||||
\fBprev\-selected\fR (move to the previous selected item)
|
||||
\fBprev\-selected\fR (synonym to \fBup\-selected\fR)
|
||||
\fBpreview(...)\fR (see below for the details)
|
||||
\fBpreview\-down\fR \fIshift\-down\fR
|
||||
\fBpreview\-up\fR \fIshift\-up\fR
|
||||
@@ -1909,6 +1943,7 @@ A key or an event can be bound to one or more of the following actions.
|
||||
\fBtoggle\-multi\-line\fR
|
||||
\fBtoggle\-preview\fR
|
||||
\fBtoggle\-preview\-wrap\fR
|
||||
\fBtoggle\-raw\fR (toggle raw mode for displaying non-matching items)
|
||||
\fBtoggle\-search\fR (toggle search functionality)
|
||||
\fBtoggle\-sort\fR
|
||||
\fBtoggle\-track\fR (toggle global tracking option (\fB\-\-track\fR))
|
||||
@@ -1935,7 +1970,9 @@ A key or an event can be bound to one or more of the following actions.
|
||||
\fBunix\-line\-discard\fR \fIctrl\-u\fR
|
||||
\fBunix\-word\-rubout\fR \fIctrl\-w\fR
|
||||
\fBuntrack\-current\fR (stop tracking the current item; no-op if global tracking is enabled)
|
||||
\fBup\fR \fIctrl\-k ctrl\-p up\fR
|
||||
\fBup\fR \fIctrl\-k up\fR
|
||||
\fBup\-match\fR \fIctrl\-p\fR \fIalt\-up\fR (move to the match above the cursor)
|
||||
\fBup\-selected\fR (move to the selected item above the cursor)
|
||||
\fByank\fR \fIctrl\-y\fR
|
||||
|
||||
Each \fBtransform*\fR action has a corresponding \fBbg\-transform*\fR
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# - $FZF_TMUX_OPTS
|
||||
# - $FZF_CTRL_T_COMMAND
|
||||
# - $FZF_CTRL_T_OPTS
|
||||
# - $FZF_CTRL_R_COMMAND
|
||||
# - $FZF_CTRL_R_OPTS
|
||||
# - $FZF_ALT_C_COMMAND
|
||||
# - $FZF_ALT_C_OPTS
|
||||
@@ -81,7 +82,7 @@ if command -v perl > /dev/null; then
|
||||
set +o pipefail
|
||||
builtin fc -lnr -2147483648 |
|
||||
last_hist=$(HISTTIMEFORMAT='' builtin history 1) command perl -n -l0 -e "$script" |
|
||||
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \
|
||||
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,alt-r:toggle-raw --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \
|
||||
FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) --query "$READLINE_LINE"
|
||||
) || return
|
||||
READLINE_LINE=$(command perl -pe 's/^\d*\t//' <<< "$output")
|
||||
@@ -104,7 +105,7 @@ else # awk - fallback for POSIX systems
|
||||
set +o pipefail
|
||||
builtin fc -lnr -2147483648 2> /dev/null | # ( $'\t '<lines>$'\n' )* ; <lines> ::= [^\n]* ( $'\n'<lines> )*
|
||||
__fzf_exec_awk "$script" | # ( <counter>$'\t'<lines>$'\000' )*
|
||||
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \
|
||||
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,alt-r:toggle-raw --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \
|
||||
FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) --query "$READLINE_LINE"
|
||||
) || return
|
||||
READLINE_LINE=${output#*$'\t'}
|
||||
@@ -132,9 +133,14 @@ if ((BASH_VERSINFO[0] < 4)); then
|
||||
fi
|
||||
|
||||
# CTRL-R - Paste the selected command from history into the command line
|
||||
bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er"'
|
||||
bind -m vi-command '"\C-r": "\C-z\C-r\C-z"'
|
||||
bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"'
|
||||
if [[ ${FZF_CTRL_R_COMMAND-x} != "" ]]; then
|
||||
if [[ -n ${FZF_CTRL_R_COMMAND-} ]]; then
|
||||
echo "warning: FZF_CTRL_R_COMMAND is set to a custom command, but custom commands are not yet supported for CTRL-R" >&2
|
||||
fi
|
||||
bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er"'
|
||||
bind -m vi-command '"\C-r": "\C-z\C-r\C-z"'
|
||||
bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"'
|
||||
fi
|
||||
else
|
||||
# CTRL-T - Paste the selected file path into the command line
|
||||
if [[ ${FZF_CTRL_T_COMMAND-x} != "" ]]; then
|
||||
@@ -144,9 +150,14 @@ else
|
||||
fi
|
||||
|
||||
# CTRL-R - Paste the selected command from history into the command line
|
||||
bind -m emacs-standard -x '"\C-r": __fzf_history__'
|
||||
bind -m vi-command -x '"\C-r": __fzf_history__'
|
||||
bind -m vi-insert -x '"\C-r": __fzf_history__'
|
||||
if [[ ${FZF_CTRL_R_COMMAND-x} != "" ]]; then
|
||||
if [[ -n ${FZF_CTRL_R_COMMAND-} ]]; then
|
||||
echo "warning: FZF_CTRL_R_COMMAND is set to a custom command, but custom commands are not yet supported for CTRL-R" >&2
|
||||
fi
|
||||
bind -m emacs-standard -x '"\C-r": __fzf_history__'
|
||||
bind -m vi-command -x '"\C-r": __fzf_history__'
|
||||
bind -m vi-insert -x '"\C-r": __fzf_history__'
|
||||
fi
|
||||
fi
|
||||
|
||||
# ALT-C - cd into the selected directory
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# - $FZF_TMUX_OPTS
|
||||
# - $FZF_CTRL_T_COMMAND
|
||||
# - $FZF_CTRL_T_OPTS
|
||||
# - $FZF_CTRL_R_COMMAND
|
||||
# - $FZF_CTRL_R_OPTS
|
||||
# - $FZF_ALT_C_COMMAND
|
||||
# - $FZF_ALT_C_OPTS
|
||||
@@ -159,7 +160,7 @@ function fzf_key_bindings
|
||||
set -lx FZF_DEFAULT_OPTS (__fzf_defaults '' \
|
||||
'--nth=2..,.. --scheme=history --multi --wrap-sign="\t↳ "' \
|
||||
'--bind=\'shift-delete:execute-silent(eval history delete --exact --case-sensitive -- (string escape -n -- {+} | string replace -r -a "^\d*\\\\\\t|(?<=\\\\\\n)\\\\\\t" ""))+reload(eval $FZF_DEFAULT_COMMAND)\'' \
|
||||
"--bind=ctrl-r:toggle-sort --highlight-line $FZF_CTRL_R_OPTS" \
|
||||
"--bind=ctrl-r:toggle-sort,alt-r:toggle-raw --highlight-line $FZF_CTRL_R_OPTS" \
|
||||
'--accept-nth=2.. --read0 --print0 --with-shell='(status fish-path)\\ -c)
|
||||
|
||||
set -lx FZF_DEFAULT_OPTS_FILE
|
||||
@@ -214,8 +215,13 @@ function fzf_key_bindings
|
||||
commandline -f repaint
|
||||
end
|
||||
|
||||
bind \cr fzf-history-widget
|
||||
bind -M insert \cr fzf-history-widget
|
||||
if not set -q FZF_CTRL_R_COMMAND; or test -n "$FZF_CTRL_R_COMMAND"
|
||||
if test -n "$FZF_CTRL_R_COMMAND"
|
||||
echo "warning: FZF_CTRL_R_COMMAND is set to a custom command, but custom commands are not yet supported for CTRL-R" >&2
|
||||
end
|
||||
bind \cr fzf-history-widget
|
||||
bind -M insert \cr fzf-history-widget
|
||||
end
|
||||
|
||||
if not set -q FZF_CTRL_T_COMMAND; or test -n "$FZF_CTRL_T_COMMAND"
|
||||
bind \ct fzf-file-widget
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# - $FZF_TMUX_OPTS
|
||||
# - $FZF_CTRL_T_COMMAND
|
||||
# - $FZF_CTRL_T_OPTS
|
||||
# - $FZF_CTRL_R_COMMAND
|
||||
# - $FZF_CTRL_R_OPTS
|
||||
# - $FZF_ALT_C_COMMAND
|
||||
# - $FZF_ALT_C_OPTS
|
||||
@@ -132,11 +133,11 @@ fzf-history-widget() {
|
||||
if zmodload -F zsh/parameter p:{commands,history} 2>/dev/null && (( ${+commands[perl]} )); then
|
||||
selected="$(printf '%s\t%s\000' "${(kv)history[@]}" |
|
||||
perl -0 -ne 'if (!$seen{(/^\s*[0-9]+\**\t(.*)/s, $1)}++) { s/\n/\n\t/g; print; }' |
|
||||
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m --read0") \
|
||||
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,alt-r:toggle-raw --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m --read0") \
|
||||
FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))"
|
||||
else
|
||||
selected="$(fc -rl 1 | __fzf_exec_awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' |
|
||||
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m") \
|
||||
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,alt-r:toggle-raw --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m") \
|
||||
FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))"
|
||||
fi
|
||||
local ret=$?
|
||||
@@ -150,10 +151,15 @@ fzf-history-widget() {
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N fzf-history-widget
|
||||
bindkey -M emacs '^R' fzf-history-widget
|
||||
bindkey -M vicmd '^R' fzf-history-widget
|
||||
bindkey -M viins '^R' fzf-history-widget
|
||||
if [[ ${FZF_CTRL_R_COMMAND-x} != "" ]]; then
|
||||
if [[ -n ${FZF_CTRL_R_COMMAND-} ]]; then
|
||||
echo "warning: FZF_CTRL_R_COMMAND is set to a custom command, but custom commands are not yet supported for CTRL-R" >&2
|
||||
fi
|
||||
zle -N fzf-history-widget
|
||||
bindkey -M emacs '^R' fzf-history-widget
|
||||
bindkey -M vicmd '^R' fzf-history-widget
|
||||
bindkey -M viins '^R' fzf-history-widget
|
||||
fi
|
||||
fi
|
||||
|
||||
} always {
|
||||
|
||||
@@ -77,106 +77,112 @@ func _() {
|
||||
_ = x[actToggleWrap-66]
|
||||
_ = x[actToggleMultiLine-67]
|
||||
_ = x[actToggleHscroll-68]
|
||||
_ = x[actTrackCurrent-69]
|
||||
_ = x[actToggleInput-70]
|
||||
_ = x[actHideInput-71]
|
||||
_ = x[actShowInput-72]
|
||||
_ = x[actUntrackCurrent-73]
|
||||
_ = x[actDown-74]
|
||||
_ = x[actUp-75]
|
||||
_ = x[actPageUp-76]
|
||||
_ = x[actPageDown-77]
|
||||
_ = x[actPosition-78]
|
||||
_ = x[actHalfPageUp-79]
|
||||
_ = x[actHalfPageDown-80]
|
||||
_ = x[actOffsetUp-81]
|
||||
_ = x[actOffsetDown-82]
|
||||
_ = x[actOffsetMiddle-83]
|
||||
_ = x[actJump-84]
|
||||
_ = x[actJumpAccept-85]
|
||||
_ = x[actPrintQuery-86]
|
||||
_ = x[actRefreshPreview-87]
|
||||
_ = x[actReplaceQuery-88]
|
||||
_ = x[actToggleSort-89]
|
||||
_ = x[actShowPreview-90]
|
||||
_ = x[actHidePreview-91]
|
||||
_ = x[actTogglePreview-92]
|
||||
_ = x[actTogglePreviewWrap-93]
|
||||
_ = x[actTransform-94]
|
||||
_ = x[actTransformBorderLabel-95]
|
||||
_ = x[actTransformGhost-96]
|
||||
_ = x[actTransformHeader-97]
|
||||
_ = x[actTransformFooter-98]
|
||||
_ = x[actTransformHeaderLabel-99]
|
||||
_ = x[actTransformFooterLabel-100]
|
||||
_ = x[actTransformInputLabel-101]
|
||||
_ = x[actTransformListLabel-102]
|
||||
_ = x[actTransformNth-103]
|
||||
_ = x[actTransformPointer-104]
|
||||
_ = x[actTransformPreviewLabel-105]
|
||||
_ = x[actTransformPrompt-106]
|
||||
_ = x[actTransformQuery-107]
|
||||
_ = x[actTransformSearch-108]
|
||||
_ = x[actTrigger-109]
|
||||
_ = x[actBgTransform-110]
|
||||
_ = x[actBgTransformBorderLabel-111]
|
||||
_ = x[actBgTransformGhost-112]
|
||||
_ = x[actBgTransformHeader-113]
|
||||
_ = x[actBgTransformFooter-114]
|
||||
_ = x[actBgTransformHeaderLabel-115]
|
||||
_ = x[actBgTransformFooterLabel-116]
|
||||
_ = x[actBgTransformInputLabel-117]
|
||||
_ = x[actBgTransformListLabel-118]
|
||||
_ = x[actBgTransformNth-119]
|
||||
_ = x[actBgTransformPointer-120]
|
||||
_ = x[actBgTransformPreviewLabel-121]
|
||||
_ = x[actBgTransformPrompt-122]
|
||||
_ = x[actBgTransformQuery-123]
|
||||
_ = x[actBgTransformSearch-124]
|
||||
_ = x[actBgCancel-125]
|
||||
_ = x[actSearch-126]
|
||||
_ = x[actPreview-127]
|
||||
_ = x[actPreviewTop-128]
|
||||
_ = x[actPreviewBottom-129]
|
||||
_ = x[actPreviewUp-130]
|
||||
_ = x[actPreviewDown-131]
|
||||
_ = x[actPreviewPageUp-132]
|
||||
_ = x[actPreviewPageDown-133]
|
||||
_ = x[actPreviewHalfPageUp-134]
|
||||
_ = x[actPreviewHalfPageDown-135]
|
||||
_ = x[actPrevHistory-136]
|
||||
_ = x[actPrevSelected-137]
|
||||
_ = x[actPrint-138]
|
||||
_ = x[actPut-139]
|
||||
_ = x[actNextHistory-140]
|
||||
_ = x[actNextSelected-141]
|
||||
_ = x[actExecute-142]
|
||||
_ = x[actExecuteSilent-143]
|
||||
_ = x[actExecuteMulti-144]
|
||||
_ = x[actSigStop-145]
|
||||
_ = x[actFirst-146]
|
||||
_ = x[actLast-147]
|
||||
_ = x[actReload-148]
|
||||
_ = x[actReloadSync-149]
|
||||
_ = x[actDisableSearch-150]
|
||||
_ = x[actEnableSearch-151]
|
||||
_ = x[actSelect-152]
|
||||
_ = x[actDeselect-153]
|
||||
_ = x[actUnbind-154]
|
||||
_ = x[actRebind-155]
|
||||
_ = x[actToggleBind-156]
|
||||
_ = x[actBecome-157]
|
||||
_ = x[actShowHeader-158]
|
||||
_ = x[actHideHeader-159]
|
||||
_ = x[actBell-160]
|
||||
_ = x[actExclude-161]
|
||||
_ = x[actExcludeMulti-162]
|
||||
_ = x[actAsync-163]
|
||||
_ = x[actToggleRaw-69]
|
||||
_ = x[actEnableRaw-70]
|
||||
_ = x[actDisableRaw-71]
|
||||
_ = x[actTrackCurrent-72]
|
||||
_ = x[actToggleInput-73]
|
||||
_ = x[actHideInput-74]
|
||||
_ = x[actShowInput-75]
|
||||
_ = x[actUntrackCurrent-76]
|
||||
_ = x[actDown-77]
|
||||
_ = x[actDownMatch-78]
|
||||
_ = x[actUp-79]
|
||||
_ = x[actUpMatch-80]
|
||||
_ = x[actPageUp-81]
|
||||
_ = x[actPageDown-82]
|
||||
_ = x[actPosition-83]
|
||||
_ = x[actHalfPageUp-84]
|
||||
_ = x[actHalfPageDown-85]
|
||||
_ = x[actOffsetUp-86]
|
||||
_ = x[actOffsetDown-87]
|
||||
_ = x[actOffsetMiddle-88]
|
||||
_ = x[actJump-89]
|
||||
_ = x[actJumpAccept-90]
|
||||
_ = x[actPrintQuery-91]
|
||||
_ = x[actRefreshPreview-92]
|
||||
_ = x[actReplaceQuery-93]
|
||||
_ = x[actToggleSort-94]
|
||||
_ = x[actShowPreview-95]
|
||||
_ = x[actHidePreview-96]
|
||||
_ = x[actTogglePreview-97]
|
||||
_ = x[actTogglePreviewWrap-98]
|
||||
_ = x[actTransform-99]
|
||||
_ = x[actTransformBorderLabel-100]
|
||||
_ = x[actTransformGhost-101]
|
||||
_ = x[actTransformHeader-102]
|
||||
_ = x[actTransformFooter-103]
|
||||
_ = x[actTransformHeaderLabel-104]
|
||||
_ = x[actTransformFooterLabel-105]
|
||||
_ = x[actTransformInputLabel-106]
|
||||
_ = x[actTransformListLabel-107]
|
||||
_ = x[actTransformNth-108]
|
||||
_ = x[actTransformPointer-109]
|
||||
_ = x[actTransformPreviewLabel-110]
|
||||
_ = x[actTransformPrompt-111]
|
||||
_ = x[actTransformQuery-112]
|
||||
_ = x[actTransformSearch-113]
|
||||
_ = x[actTrigger-114]
|
||||
_ = x[actBgTransform-115]
|
||||
_ = x[actBgTransformBorderLabel-116]
|
||||
_ = x[actBgTransformGhost-117]
|
||||
_ = x[actBgTransformHeader-118]
|
||||
_ = x[actBgTransformFooter-119]
|
||||
_ = x[actBgTransformHeaderLabel-120]
|
||||
_ = x[actBgTransformFooterLabel-121]
|
||||
_ = x[actBgTransformInputLabel-122]
|
||||
_ = x[actBgTransformListLabel-123]
|
||||
_ = x[actBgTransformNth-124]
|
||||
_ = x[actBgTransformPointer-125]
|
||||
_ = x[actBgTransformPreviewLabel-126]
|
||||
_ = x[actBgTransformPrompt-127]
|
||||
_ = x[actBgTransformQuery-128]
|
||||
_ = x[actBgTransformSearch-129]
|
||||
_ = x[actBgCancel-130]
|
||||
_ = x[actSearch-131]
|
||||
_ = x[actPreview-132]
|
||||
_ = x[actPreviewTop-133]
|
||||
_ = x[actPreviewBottom-134]
|
||||
_ = x[actPreviewUp-135]
|
||||
_ = x[actPreviewDown-136]
|
||||
_ = x[actPreviewPageUp-137]
|
||||
_ = x[actPreviewPageDown-138]
|
||||
_ = x[actPreviewHalfPageUp-139]
|
||||
_ = x[actPreviewHalfPageDown-140]
|
||||
_ = x[actPrevHistory-141]
|
||||
_ = x[actPrevSelected-142]
|
||||
_ = x[actPrint-143]
|
||||
_ = x[actPut-144]
|
||||
_ = x[actNextHistory-145]
|
||||
_ = x[actNextSelected-146]
|
||||
_ = x[actExecute-147]
|
||||
_ = x[actExecuteSilent-148]
|
||||
_ = x[actExecuteMulti-149]
|
||||
_ = x[actSigStop-150]
|
||||
_ = x[actBest-151]
|
||||
_ = x[actFirst-152]
|
||||
_ = x[actLast-153]
|
||||
_ = x[actReload-154]
|
||||
_ = x[actReloadSync-155]
|
||||
_ = x[actDisableSearch-156]
|
||||
_ = x[actEnableSearch-157]
|
||||
_ = x[actSelect-158]
|
||||
_ = x[actDeselect-159]
|
||||
_ = x[actUnbind-160]
|
||||
_ = x[actRebind-161]
|
||||
_ = x[actToggleBind-162]
|
||||
_ = x[actBecome-163]
|
||||
_ = x[actShowHeader-164]
|
||||
_ = x[actHideHeader-165]
|
||||
_ = x[actBell-166]
|
||||
_ = x[actExclude-167]
|
||||
_ = x[actExcludeMulti-168]
|
||||
_ = x[actAsync-169]
|
||||
}
|
||||
|
||||
const _actionType_name = "actIgnoreactStartactClickactInvalidactBracketedPasteBeginactBracketedPasteEndactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactBackwardSubWordactCancelactChangeBorderLabelactChangeGhostactChangeHeaderactChangeFooteractChangeHeaderLabelactChangeFooterLabelactChangeInputLabelactChangeListLabelactChangeMultiactChangeNthactChangePointeractChangePreviewactChangePreviewLabelactChangePreviewWindowactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactForwardSubWordactKillLineactKillWordactKillSubWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactBackwardKillSubWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactToggleHscrollactTrackCurrentactToggleInputactHideInputactShowInputactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformGhostactTransformHeaderactTransformFooteractTransformHeaderLabelactTransformFooterLabelactTransformInputLabelactTransformListLabelactTransformNthactTransformPointeractTransformPreviewLabelactTransformPromptactTransformQueryactTransformSearchactTriggeractBgTransformactBgTransformBorderLabelactBgTransformGhostactBgTransformHeaderactBgTransformFooteractBgTransformHeaderLabelactBgTransformFooterLabelactBgTransformInputLabelactBgTransformListLabelactBgTransformNthactBgTransformPointeractBgTransformPreviewLabelactBgTransformPromptactBgTransformQueryactBgTransformSearchactBgCancelactSearchactPreviewactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactToggleBindactBecomeactShowHeaderactHideHeaderactBellactExcludeactExcludeMultiactAsync"
|
||||
const _actionType_name = "actIgnoreactStartactClickactInvalidactBracketedPasteBeginactBracketedPasteEndactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactBackwardSubWordactCancelactChangeBorderLabelactChangeGhostactChangeHeaderactChangeFooteractChangeHeaderLabelactChangeFooterLabelactChangeInputLabelactChangeListLabelactChangeMultiactChangeNthactChangePointeractChangePreviewactChangePreviewLabelactChangePreviewWindowactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactForwardSubWordactKillLineactKillWordactKillSubWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactBackwardKillSubWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactToggleHscrollactToggleRawactEnableRawactDisableRawactTrackCurrentactToggleInputactHideInputactShowInputactUntrackCurrentactDownactDownMatchactUpactUpMatchactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformGhostactTransformHeaderactTransformFooteractTransformHeaderLabelactTransformFooterLabelactTransformInputLabelactTransformListLabelactTransformNthactTransformPointeractTransformPreviewLabelactTransformPromptactTransformQueryactTransformSearchactTriggeractBgTransformactBgTransformBorderLabelactBgTransformGhostactBgTransformHeaderactBgTransformFooteractBgTransformHeaderLabelactBgTransformFooterLabelactBgTransformInputLabelactBgTransformListLabelactBgTransformNthactBgTransformPointeractBgTransformPreviewLabelactBgTransformPromptactBgTransformQueryactBgTransformSearchactBgCancelactSearchactPreviewactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactBestactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactToggleBindactBecomeactShowHeaderactHideHeaderactBellactExcludeactExcludeMultiactAsync"
|
||||
|
||||
var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 57, 77, 84, 92, 110, 118, 127, 144, 165, 180, 201, 225, 240, 258, 267, 287, 301, 316, 331, 351, 371, 390, 408, 422, 434, 450, 466, 487, 509, 524, 538, 552, 565, 582, 590, 603, 619, 631, 639, 653, 667, 684, 695, 706, 720, 738, 755, 762, 781, 803, 815, 829, 838, 853, 865, 878, 889, 900, 912, 926, 947, 962, 975, 993, 1009, 1024, 1038, 1050, 1062, 1079, 1086, 1091, 1100, 1111, 1122, 1135, 1150, 1161, 1174, 1189, 1196, 1209, 1222, 1239, 1254, 1267, 1281, 1295, 1311, 1331, 1343, 1366, 1383, 1401, 1419, 1442, 1465, 1487, 1508, 1523, 1542, 1566, 1584, 1601, 1619, 1629, 1643, 1668, 1687, 1707, 1727, 1752, 1777, 1801, 1824, 1841, 1862, 1888, 1908, 1927, 1947, 1958, 1967, 1977, 1990, 2006, 2018, 2032, 2048, 2066, 2086, 2108, 2122, 2137, 2145, 2151, 2165, 2180, 2190, 2206, 2221, 2231, 2239, 2246, 2255, 2268, 2284, 2299, 2308, 2319, 2328, 2337, 2350, 2359, 2372, 2385, 2392, 2402, 2417, 2425}
|
||||
var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 57, 77, 84, 92, 110, 118, 127, 144, 165, 180, 201, 225, 240, 258, 267, 287, 301, 316, 331, 351, 371, 390, 408, 422, 434, 450, 466, 487, 509, 524, 538, 552, 565, 582, 590, 603, 619, 631, 639, 653, 667, 684, 695, 706, 720, 738, 755, 762, 781, 803, 815, 829, 838, 853, 865, 878, 889, 900, 912, 926, 947, 962, 975, 993, 1009, 1021, 1033, 1046, 1061, 1075, 1087, 1099, 1116, 1123, 1135, 1140, 1150, 1159, 1170, 1181, 1194, 1209, 1220, 1233, 1248, 1255, 1268, 1281, 1298, 1313, 1326, 1340, 1354, 1370, 1390, 1402, 1425, 1442, 1460, 1478, 1501, 1524, 1546, 1567, 1582, 1601, 1625, 1643, 1660, 1678, 1688, 1702, 1727, 1746, 1766, 1786, 1811, 1836, 1860, 1883, 1900, 1921, 1947, 1967, 1986, 2006, 2017, 2026, 2036, 2049, 2065, 2077, 2091, 2107, 2125, 2145, 2167, 2181, 2196, 2204, 2210, 2224, 2239, 2249, 2265, 2280, 2290, 2297, 2305, 2312, 2321, 2334, 2350, 2365, 2374, 2385, 2394, 2403, 2416, 2425, 2438, 2451, 2458, 2468, 2483, 2491}
|
||||
|
||||
func (i actionType) String() string {
|
||||
if i < 0 || i >= actionType(len(_actionType_index)-1) {
|
||||
|
||||
19
src/core.go
19
src/core.go
@@ -267,11 +267,11 @@ func Run(opts *Options) (int, error) {
|
||||
|
||||
// NOTE: Streaming filter is inherently not compatible with --tail
|
||||
snapshot, _, _ := chunkList.Snapshot(opts.Tail)
|
||||
merger, _ := matcher.scan(MatchRequest{
|
||||
result := matcher.scan(MatchRequest{
|
||||
chunks: snapshot,
|
||||
pattern: pattern})
|
||||
for i := 0; i < merger.Length(); i++ {
|
||||
opts.Printer(merger.Get(i).item.AsString(opts.Ansi))
|
||||
for i := 0; i < result.merger.Length(); i++ {
|
||||
opts.Printer(result.merger.Get(i).item.AsString(opts.Ansi))
|
||||
found = true
|
||||
}
|
||||
}
|
||||
@@ -479,12 +479,13 @@ func Run(opts *Options) (int, error) {
|
||||
|
||||
case EvtSearchFin:
|
||||
switch val := value.(type) {
|
||||
case *Merger:
|
||||
case MatchResult:
|
||||
merger := val.merger
|
||||
if deferred {
|
||||
count := val.Length()
|
||||
count := merger.Length()
|
||||
if opts.Select1 && count > 1 || opts.Exit0 && !opts.Select1 && count > 0 {
|
||||
determine(val.final)
|
||||
} else if val.final {
|
||||
determine(merger.final)
|
||||
} else if merger.final {
|
||||
if opts.Exit0 && count == 0 || opts.Select1 && count == 1 {
|
||||
if opts.PrintQuery {
|
||||
opts.Printer(opts.Query)
|
||||
@@ -502,7 +503,7 @@ func Run(opts *Options) (int, error) {
|
||||
}
|
||||
}
|
||||
for i := 0; i < count; i++ {
|
||||
opts.Printer(transformer(val.Get(i).item))
|
||||
opts.Printer(transformer(merger.Get(i).item))
|
||||
}
|
||||
if count == 0 {
|
||||
exitCode = ExitNoMatch
|
||||
@@ -510,7 +511,7 @@ func Run(opts *Options) (int, error) {
|
||||
stop = true
|
||||
return
|
||||
}
|
||||
determine(val.final)
|
||||
determine(merger.final)
|
||||
}
|
||||
}
|
||||
terminal.UpdateList(val)
|
||||
|
||||
@@ -19,6 +19,20 @@ type MatchRequest struct {
|
||||
revision revision
|
||||
}
|
||||
|
||||
type MatchResult struct {
|
||||
merger *Merger
|
||||
passMerger *Merger
|
||||
cancelled bool
|
||||
}
|
||||
|
||||
func (mr MatchResult) cacheable() bool {
|
||||
return mr.merger != nil && mr.merger.cacheable()
|
||||
}
|
||||
|
||||
func (mr MatchResult) final() bool {
|
||||
return mr.merger != nil && mr.merger.final
|
||||
}
|
||||
|
||||
// Matcher is responsible for performing search
|
||||
type Matcher struct {
|
||||
cache *ChunkCache
|
||||
@@ -29,7 +43,7 @@ type Matcher struct {
|
||||
reqBox *util.EventBox
|
||||
partitions int
|
||||
slab []*util.Slab
|
||||
mergerCache map[string]*Merger
|
||||
mergerCache map[string]MatchResult
|
||||
revision revision
|
||||
}
|
||||
|
||||
@@ -51,7 +65,7 @@ func NewMatcher(cache *ChunkCache, patternBuilder func([]rune) *Pattern,
|
||||
reqBox: util.NewEventBox(),
|
||||
partitions: partitions,
|
||||
slab: make([]*util.Slab, partitions),
|
||||
mergerCache: make(map[string]*Merger),
|
||||
mergerCache: make(map[string]MatchResult),
|
||||
revision: revision}
|
||||
}
|
||||
|
||||
@@ -85,7 +99,7 @@ func (m *Matcher) Loop() {
|
||||
cacheCleared := false
|
||||
if request.sort != m.sort || request.revision != m.revision {
|
||||
m.sort = request.sort
|
||||
m.mergerCache = make(map[string]*Merger)
|
||||
m.mergerCache = make(map[string]MatchResult)
|
||||
if !request.revision.compatible(m.revision) {
|
||||
m.cache.Clear()
|
||||
}
|
||||
@@ -95,33 +109,32 @@ func (m *Matcher) Loop() {
|
||||
|
||||
// Restart search
|
||||
patternString := request.pattern.AsString()
|
||||
var merger *Merger
|
||||
cancelled := false
|
||||
var result MatchResult
|
||||
count := CountItems(request.chunks)
|
||||
|
||||
if !cacheCleared {
|
||||
if count == prevCount {
|
||||
// Look up mergerCache
|
||||
if cached, found := m.mergerCache[patternString]; found && cached.final == request.final {
|
||||
merger = cached
|
||||
if cached, found := m.mergerCache[patternString]; found && cached.final() == request.final {
|
||||
result = cached
|
||||
}
|
||||
} else {
|
||||
// Invalidate mergerCache
|
||||
prevCount = count
|
||||
m.mergerCache = make(map[string]*Merger)
|
||||
m.mergerCache = make(map[string]MatchResult)
|
||||
}
|
||||
}
|
||||
|
||||
if merger == nil {
|
||||
merger, cancelled = m.scan(request)
|
||||
if result.merger == nil {
|
||||
result = m.scan(request)
|
||||
}
|
||||
|
||||
if !cancelled {
|
||||
if merger.cacheable() {
|
||||
m.mergerCache[patternString] = merger
|
||||
if !result.cancelled {
|
||||
if result.cacheable() {
|
||||
m.mergerCache[patternString] = result
|
||||
}
|
||||
merger.final = request.final
|
||||
m.eventBox.Set(EvtSearchFin, merger)
|
||||
result.merger.final = request.final
|
||||
m.eventBox.Set(EvtSearchFin, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,16 +165,18 @@ type partialResult struct {
|
||||
matches []Result
|
||||
}
|
||||
|
||||
func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
|
||||
func (m *Matcher) scan(request MatchRequest) MatchResult {
|
||||
startedAt := time.Now()
|
||||
|
||||
numChunks := len(request.chunks)
|
||||
if numChunks == 0 {
|
||||
return EmptyMerger(request.revision), false
|
||||
m := EmptyMerger(request.revision)
|
||||
return MatchResult{m, m, false}
|
||||
}
|
||||
pattern := request.pattern
|
||||
passMerger := PassMerger(&request.chunks, m.tac, request.revision)
|
||||
if pattern.IsEmpty() {
|
||||
return PassMerger(&request.chunks, m.tac, request.revision), false
|
||||
return MatchResult{passMerger, passMerger, false}
|
||||
}
|
||||
|
||||
minIndex := request.chunks[0].items[0].Index()
|
||||
@@ -224,7 +239,7 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
|
||||
}
|
||||
|
||||
if m.reqBox.Peek(reqReset) {
|
||||
return nil, wait()
|
||||
return MatchResult{nil, nil, wait()}
|
||||
}
|
||||
|
||||
if time.Since(startedAt) > progressMinDuration {
|
||||
@@ -237,7 +252,8 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
|
||||
partialResult := <-resultChan
|
||||
partialResults[partialResult.index] = partialResult.matches
|
||||
}
|
||||
return NewMerger(pattern, partialResults, m.sort && request.pattern.sortable, m.tac, request.revision, minIndex, maxIndex), false
|
||||
merger := NewMerger(pattern, partialResults, m.sort && request.pattern.sortable, m.tac, request.revision, minIndex, maxIndex)
|
||||
return MatchResult{merger, passMerger, false}
|
||||
}
|
||||
|
||||
// Reset is called to interrupt/signal the ongoing search
|
||||
|
||||
@@ -141,6 +141,15 @@ func (mg *Merger) Get(idx int) Result {
|
||||
panic(fmt.Sprintf("Index out of bounds (unsorted, %d/%d)", idx, mg.count))
|
||||
}
|
||||
|
||||
func (mg *Merger) ToMap() map[int32]Result {
|
||||
ret := make(map[int32]Result, mg.count)
|
||||
for i := 0; i < mg.count; i++ {
|
||||
result := mg.Get(i)
|
||||
ret[result.Index()] = result
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (mg *Merger) cacheable() bool {
|
||||
return mg.count < mergerCacheMax
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ Usage: fzf [options]
|
||||
--wrap Enable line wrap
|
||||
--wrap-sign=STR Indicator for wrapped lines
|
||||
--no-multi-line Disable multi-line display of items when using --read0
|
||||
--raw Enable raw mode (show non-matching items)
|
||||
--track Track the current selection when the result is updated
|
||||
--tac Reverse the order of the input
|
||||
--gap[=N] Render empty lines between each item
|
||||
@@ -111,6 +112,7 @@ Usage: fzf [options]
|
||||
highlighted substring (default: 10)
|
||||
--jump-labels=CHARS Label characters for jump mode
|
||||
--gutter=CHAR Character used for the gutter column (default: '▌')
|
||||
--gutter-raw=CHAR Character used for the gutter column in raw mode (default: '▖')
|
||||
--pointer=STR Pointer to the current line (default: '▌' or '>')
|
||||
--marker=STR Multi-select marker (default: '┃' or '>')
|
||||
--marker-multi-line=STR Multi-select marker for multi-line entries;
|
||||
@@ -204,8 +206,10 @@ Usage: fzf [options]
|
||||
|
||||
ADVANCED
|
||||
--with-shell=STR Shell command and flags to start child processes with
|
||||
--listen[=[ADDR:]PORT] Start HTTP server to receive actions (POST /)
|
||||
--listen[=[ADDR:]PORT] Start HTTP server to receive actions via TCP
|
||||
(To allow remote process execution, use --listen-unsafe)
|
||||
--listen=SOCKET_PATH Start HTTP server to receive actions via Unix domain socket
|
||||
(Path should end with .sock)
|
||||
|
||||
DIRECTORY TRAVERSAL (Only used when $FZF_DEFAULT_COMMAND is not set)
|
||||
--walker=OPTS [file][,dir][,follow][,hidden] (default: file,follow,hidden)
|
||||
@@ -562,6 +566,7 @@ type Options struct {
|
||||
AcceptNth func(Delimiter) func([]Token, int32) string
|
||||
Delimiter Delimiter
|
||||
Sort int
|
||||
Raw bool
|
||||
Track trackOption
|
||||
Tac bool
|
||||
Tail int
|
||||
@@ -569,6 +574,7 @@ type Options struct {
|
||||
Multi int
|
||||
Ansi bool
|
||||
Mouse bool
|
||||
BaseTheme *tui.ColorTheme
|
||||
Theme *tui.ColorTheme
|
||||
Black bool
|
||||
Bold bool
|
||||
@@ -593,6 +599,7 @@ type Options struct {
|
||||
JumpLabels string
|
||||
Prompt string
|
||||
Gutter *string
|
||||
GutterRaw *string
|
||||
Pointer *string
|
||||
Marker *string
|
||||
MarkerMulti *[3]string
|
||||
@@ -668,9 +675,9 @@ func defaultPreviewOpts(command string) previewOpts {
|
||||
func defaultOptions() *Options {
|
||||
var theme *tui.ColorTheme
|
||||
if os.Getenv("NO_COLOR") != "" {
|
||||
theme = tui.NoColorTheme()
|
||||
theme = tui.NoColorTheme
|
||||
} else {
|
||||
theme = tui.EmptyTheme()
|
||||
theme = tui.EmptyTheme
|
||||
}
|
||||
|
||||
return &Options{
|
||||
@@ -714,6 +721,7 @@ func defaultOptions() *Options {
|
||||
JumpLabels: defaultJumpLabels,
|
||||
Prompt: "> ",
|
||||
Gutter: nil,
|
||||
GutterRaw: nil,
|
||||
Pointer: nil,
|
||||
Marker: nil,
|
||||
MarkerMulti: nil,
|
||||
@@ -1312,8 +1320,9 @@ func dupeTheme(theme *tui.ColorTheme) *tui.ColorTheme {
|
||||
return &dupe
|
||||
}
|
||||
|
||||
func parseTheme(defaultTheme *tui.ColorTheme, str string) (*tui.ColorTheme, error) {
|
||||
func parseTheme(defaultTheme *tui.ColorTheme, str string) (*tui.ColorTheme, *tui.ColorTheme, error) {
|
||||
var err error
|
||||
var baseTheme *tui.ColorTheme
|
||||
theme := dupeTheme(defaultTheme)
|
||||
rrggbb := regexp.MustCompile("^#[0-9a-fA-F]{6}$")
|
||||
comma := regexp.MustCompile(`[\s,]+`)
|
||||
@@ -1324,13 +1333,17 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) (*tui.ColorTheme, erro
|
||||
}
|
||||
switch str {
|
||||
case "dark":
|
||||
baseTheme = tui.Dark256
|
||||
theme = dupeTheme(tui.Dark256)
|
||||
case "light":
|
||||
baseTheme = tui.Light256
|
||||
theme = dupeTheme(tui.Light256)
|
||||
case "base16", "16":
|
||||
baseTheme = tui.Default16
|
||||
theme = dupeTheme(tui.Default16)
|
||||
case "bw", "no":
|
||||
theme = tui.NoColorTheme()
|
||||
baseTheme = tui.NoColorTheme
|
||||
theme = dupeTheme(tui.NoColorTheme)
|
||||
default:
|
||||
fail := func() {
|
||||
// Let the code proceed to simplify the error handling
|
||||
@@ -1355,6 +1368,8 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) (*tui.ColorTheme, erro
|
||||
cattr.Attr |= tui.Bold
|
||||
case "dim":
|
||||
cattr.Attr |= tui.Dim
|
||||
case "strip":
|
||||
cattr.Attr |= tui.Strip
|
||||
case "italic":
|
||||
cattr.Attr |= tui.Italic
|
||||
case "underline":
|
||||
@@ -1442,6 +1457,8 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) (*tui.ColorTheme, erro
|
||||
mergeAttr(&theme.SelectedBg)
|
||||
case "nth":
|
||||
mergeAttr(&theme.Nth)
|
||||
case "nomatch":
|
||||
mergeAttr(&theme.Nomatch)
|
||||
case "gutter":
|
||||
mergeAttr(&theme.Gutter)
|
||||
case "hl":
|
||||
@@ -1507,7 +1524,7 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) (*tui.ColorTheme, erro
|
||||
}
|
||||
}
|
||||
}
|
||||
return theme, err
|
||||
return baseTheme, theme, err
|
||||
}
|
||||
|
||||
func parseWalkerOpts(str string) (walkerOpts, error) {
|
||||
@@ -1741,6 +1758,12 @@ func parseActionList(masked string, original string, prevActions []*action, putA
|
||||
appendAction(actToggleMultiLine)
|
||||
case "toggle-hscroll":
|
||||
appendAction(actToggleHscroll)
|
||||
case "toggle-raw":
|
||||
appendAction(actToggleRaw)
|
||||
case "enable-raw":
|
||||
appendAction(actEnableRaw)
|
||||
case "disable-raw":
|
||||
appendAction(actDisableRaw)
|
||||
case "show-header":
|
||||
appendAction(actShowHeader)
|
||||
case "hide-header":
|
||||
@@ -1761,12 +1784,18 @@ func parseActionList(masked string, original string, prevActions []*action, putA
|
||||
appendAction(actToggle)
|
||||
case "down":
|
||||
appendAction(actDown)
|
||||
case "down-match":
|
||||
appendAction(actDownMatch)
|
||||
case "up":
|
||||
appendAction(actUp)
|
||||
case "up-match":
|
||||
appendAction(actUpMatch)
|
||||
case "first", "top":
|
||||
appendAction(actFirst)
|
||||
case "last":
|
||||
appendAction(actLast)
|
||||
case "best":
|
||||
appendAction(actBest)
|
||||
case "page-up":
|
||||
appendAction(actPageUp)
|
||||
case "page-down":
|
||||
@@ -1779,9 +1808,9 @@ func parseActionList(masked string, original string, prevActions []*action, putA
|
||||
appendAction(actPrevHistory)
|
||||
case "next-history":
|
||||
appendAction(actNextHistory)
|
||||
case "prev-selected":
|
||||
case "up-selected", "prev-selected":
|
||||
appendAction(actPrevSelected)
|
||||
case "next-selected":
|
||||
case "down-selected", "next-selected":
|
||||
appendAction(actNextSelected)
|
||||
case "show-preview":
|
||||
appendAction(actShowPreview)
|
||||
@@ -2632,11 +2661,15 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
||||
case "--color":
|
||||
_, spec := optionalNextString()
|
||||
if len(spec) == 0 {
|
||||
opts.Theme = tui.EmptyTheme()
|
||||
opts.Theme = tui.EmptyTheme
|
||||
} else {
|
||||
if opts.Theme, err = parseTheme(opts.Theme, spec); err != nil {
|
||||
var baseTheme *tui.ColorTheme
|
||||
if baseTheme, opts.Theme, err = parseTheme(opts.Theme, spec); err != nil {
|
||||
return err
|
||||
}
|
||||
if baseTheme != nil {
|
||||
opts.BaseTheme = baseTheme
|
||||
}
|
||||
}
|
||||
case "--toggle-sort":
|
||||
str, err := nextString("key name required")
|
||||
@@ -2682,6 +2715,10 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
||||
}
|
||||
case "+s", "--no-sort":
|
||||
opts.Sort = 0
|
||||
case "--raw":
|
||||
opts.Raw = true
|
||||
case "--no-raw":
|
||||
opts.Raw = false
|
||||
case "--track":
|
||||
opts.Track = trackEnabled
|
||||
case "--no-track":
|
||||
@@ -2718,7 +2755,8 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
||||
case "--no-mouse":
|
||||
opts.Mouse = false
|
||||
case "+c", "--no-color":
|
||||
opts.Theme = tui.NoColorTheme()
|
||||
opts.BaseTheme = tui.NoColorTheme
|
||||
opts.Theme = tui.NoColorTheme
|
||||
case "+2", "--no-256":
|
||||
opts.Theme = tui.Default16
|
||||
case "--black":
|
||||
@@ -2866,6 +2904,13 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
||||
}
|
||||
str = firstLine(str)
|
||||
opts.Gutter = &str
|
||||
case "--gutter-raw":
|
||||
str, err := nextString("gutter character for raw mode required")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
str = firstLine(str)
|
||||
opts.GutterRaw = &str
|
||||
case "--pointer":
|
||||
str, err := nextString("pointer sign required")
|
||||
if err != nil {
|
||||
@@ -3384,10 +3429,9 @@ func validateOptions(opts *Options) error {
|
||||
}
|
||||
}
|
||||
|
||||
if opts.Gutter != nil {
|
||||
if err := validateSign(*opts.Gutter, "gutter", 1); err != nil {
|
||||
return err
|
||||
}
|
||||
if opts.Gutter != nil && uniseg.StringWidth(*opts.Gutter) != 1 ||
|
||||
opts.GutterRaw != nil && uniseg.StringWidth(*opts.GutterRaw) != 1 {
|
||||
return errors.New("gutter display width should be 1")
|
||||
}
|
||||
|
||||
if opts.Scrollbar != nil {
|
||||
@@ -3589,23 +3633,6 @@ func postProcessOptions(opts *Options) error {
|
||||
}
|
||||
}
|
||||
|
||||
if opts.Bold {
|
||||
theme := opts.Theme
|
||||
boldify := func(c tui.ColorAttr) tui.ColorAttr {
|
||||
dup := c
|
||||
if (c.Attr & tui.AttrRegular) == 0 {
|
||||
dup.Attr |= tui.BoldForce
|
||||
}
|
||||
return dup
|
||||
}
|
||||
theme.Current = boldify(theme.Current)
|
||||
theme.CurrentMatch = boldify(theme.CurrentMatch)
|
||||
theme.Prompt = boldify(theme.Prompt)
|
||||
theme.Input = boldify(theme.Input)
|
||||
theme.Cursor = boldify(theme.Cursor)
|
||||
theme.Spinner = boldify(theme.Spinner)
|
||||
}
|
||||
|
||||
// If --height option is not supported on the platform, just ignore it
|
||||
if !tui.IsLightRendererSupported() && opts.Height.size > 0 {
|
||||
opts.Height = heightSpec{}
|
||||
|
||||
@@ -300,8 +300,12 @@ func TestBind(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestColorSpec(t *testing.T) {
|
||||
var base *tui.ColorTheme
|
||||
theme := tui.Dark256
|
||||
dark, _ := parseTheme(theme, "dark")
|
||||
base, dark, _ := parseTheme(theme, "dark")
|
||||
if *dark != *base {
|
||||
t.Errorf("incorrect base theme returned")
|
||||
}
|
||||
if *dark != *theme {
|
||||
t.Errorf("colors should be equivalent")
|
||||
}
|
||||
@@ -309,7 +313,10 @@ func TestColorSpec(t *testing.T) {
|
||||
t.Errorf("point should not be equivalent")
|
||||
}
|
||||
|
||||
light, _ := parseTheme(theme, "dark,light")
|
||||
base, light, _ := parseTheme(theme, "dark,light")
|
||||
if *light != *base {
|
||||
t.Errorf("incorrect base theme returned")
|
||||
}
|
||||
if *light == *theme {
|
||||
t.Errorf("should not be equivalent")
|
||||
}
|
||||
@@ -320,7 +327,7 @@ func TestColorSpec(t *testing.T) {
|
||||
t.Errorf("point should not be equivalent")
|
||||
}
|
||||
|
||||
customized, _ := parseTheme(theme, "fg:231,bg:232")
|
||||
_, customized, _ := parseTheme(theme, "fg:231,bg:232")
|
||||
if customized.Fg.Color != 231 || customized.Bg.Color != 232 {
|
||||
t.Errorf("color not customized")
|
||||
}
|
||||
@@ -333,7 +340,7 @@ func TestColorSpec(t *testing.T) {
|
||||
t.Errorf("colors should now be equivalent: %v, %v", tui.Dark256, customized)
|
||||
}
|
||||
|
||||
customized, _ = parseTheme(theme, "fg:231,dark bg:232")
|
||||
_, customized, _ = parseTheme(theme, "fg:231,dark bg:232")
|
||||
if customized.Fg != tui.Dark256.Fg || customized.Bg == tui.Dark256.Bg {
|
||||
t.Errorf("color not customized")
|
||||
}
|
||||
@@ -350,8 +357,8 @@ func TestDefaultCtrlNP(t *testing.T) {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
check([]string{}, tui.CtrlN, actDown)
|
||||
check([]string{}, tui.CtrlP, actUp)
|
||||
check([]string{}, tui.CtrlN, actDownMatch)
|
||||
check([]string{}, tui.CtrlP, actUpMatch)
|
||||
|
||||
check([]string{"--bind=ctrl-n:accept"}, tui.CtrlN, actAccept)
|
||||
check([]string{"--bind=ctrl-p:accept"}, tui.CtrlP, actAccept)
|
||||
|
||||
@@ -123,7 +123,7 @@ func minRank() Result {
|
||||
return Result{item: &minItem, points: [4]uint16{math.MaxUint16, 0, 0, 0}}
|
||||
}
|
||||
|
||||
func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, theme *tui.ColorTheme, colBase tui.ColorPair, colMatch tui.ColorPair, attrNth tui.Attr) []colorOffset {
|
||||
func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, theme *tui.ColorTheme, colBase tui.ColorPair, colMatch tui.ColorPair, attrNth tui.Attr, hidden bool) []colorOffset {
|
||||
itemColors := result.item.Colors()
|
||||
|
||||
// No ANSI codes
|
||||
@@ -194,6 +194,10 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t
|
||||
if !theme.Colored {
|
||||
return tui.NewColorPair(-1, -1, ansi.color.attr).MergeAttr(base)
|
||||
}
|
||||
// fd --color always | fzf --ansi --delimiter / --nth -1 --color fg:dim:strip,nth:regular
|
||||
if base.ShouldStripColors() {
|
||||
return base
|
||||
}
|
||||
fg := ansi.color.fg
|
||||
bg := ansi.color.bg
|
||||
if fg == -1 {
|
||||
@@ -251,6 +255,9 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t
|
||||
if curr.nth {
|
||||
base = base.WithAttr(attrNth)
|
||||
}
|
||||
if hidden {
|
||||
base = base.WithFg(theme.Nomatch)
|
||||
}
|
||||
color := ansiToColorPair(ansi, base)
|
||||
colors = append(colors, colorOffset{
|
||||
offset: [2]int32{int32(start), int32(idx)},
|
||||
@@ -258,9 +265,13 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t
|
||||
match: false,
|
||||
url: ansi.color.url})
|
||||
} else {
|
||||
color := colBase.WithAttr(attrNth)
|
||||
if hidden {
|
||||
color = color.WithFg(theme.Nomatch)
|
||||
}
|
||||
colors = append(colors, colorOffset{
|
||||
offset: [2]int32{int32(start), int32(idx)},
|
||||
color: colBase.WithAttr(attrNth),
|
||||
color: color,
|
||||
match: false,
|
||||
url: nil})
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func TestColorOffset(t *testing.T) {
|
||||
|
||||
colBase := tui.NewColorPair(89, 189, tui.AttrUndefined)
|
||||
colMatch := tui.NewColorPair(99, 199, tui.AttrUndefined)
|
||||
colors := item.colorOffsets(offsets, nil, tui.Dark256, colBase, colMatch, tui.AttrUndefined)
|
||||
colors := item.colorOffsets(offsets, nil, tui.Dark256, colBase, colMatch, tui.AttrUndefined, false)
|
||||
assert := func(idx int, b int32, e int32, c tui.ColorPair) {
|
||||
o := colors[idx]
|
||||
if o.offset[0] != b || o.offset[1] != e || o.color != c {
|
||||
@@ -158,7 +158,7 @@ func TestColorOffset(t *testing.T) {
|
||||
|
||||
nthOffsets := []Offset{{37, 39}, {42, 45}}
|
||||
for _, attr := range []tui.Attr{tui.AttrRegular, tui.StrikeThrough} {
|
||||
colors = item.colorOffsets(offsets, nthOffsets, tui.Dark256, colRegular, colUnderline, attr)
|
||||
colors = item.colorOffsets(offsets, nthOffsets, tui.Dark256, colRegular, colUnderline, attr, false)
|
||||
|
||||
// [{[0 5] {1 5 0}} {[5 15] {1 5 8}} {[15 20] {1 5 0}}
|
||||
// {[22 25] {2 6 1}} {[25 27] {2 6 9}} {[27 30] {-1 -1 8}}
|
||||
|
||||
@@ -46,15 +46,20 @@ type httpServer struct {
|
||||
type listenAddress struct {
|
||||
host string
|
||||
port int
|
||||
sock string
|
||||
}
|
||||
|
||||
func (addr listenAddress) IsLocal() bool {
|
||||
return addr.host == "localhost" || addr.host == "127.0.0.1"
|
||||
return addr.host == "localhost" || addr.host == "127.0.0.1" || len(addr.sock) > 0
|
||||
}
|
||||
|
||||
var defaultListenAddr = listenAddress{"localhost", 0}
|
||||
var defaultListenAddr = listenAddress{"localhost", 0, ""}
|
||||
|
||||
func parseListenAddress(address string) (listenAddress, error) {
|
||||
if strings.HasSuffix(address, ".sock") {
|
||||
return listenAddress{"", 0, address}, nil
|
||||
}
|
||||
|
||||
parts := strings.SplitN(address, ":", 3)
|
||||
if len(parts) == 1 {
|
||||
parts = []string{"localhost", parts[0]}
|
||||
@@ -70,7 +75,7 @@ func parseListenAddress(address string) (listenAddress, error) {
|
||||
if len(parts[0]) == 0 {
|
||||
parts[0] = "localhost"
|
||||
}
|
||||
return listenAddress{parts[0], port}, nil
|
||||
return listenAddress{parts[0], port, ""}, nil
|
||||
}
|
||||
|
||||
func startHttpServer(address listenAddress, actionChannel chan []*action, getHandler func(getParams) string) (net.Listener, int, error) {
|
||||
@@ -80,21 +85,40 @@ func startHttpServer(address listenAddress, actionChannel chan []*action, getHan
|
||||
if !address.IsLocal() && len(apiKey) == 0 {
|
||||
return nil, port, errors.New("FZF_API_KEY is required to allow remote access")
|
||||
}
|
||||
addrStr := fmt.Sprintf("%s:%d", host, port)
|
||||
listener, err := net.Listen("tcp", addrStr)
|
||||
if err != nil {
|
||||
return nil, port, fmt.Errorf("failed to listen on %s", addrStr)
|
||||
}
|
||||
if port == 0 {
|
||||
addr := listener.Addr().String()
|
||||
parts := strings.Split(addr, ":")
|
||||
if len(parts) < 2 {
|
||||
return nil, port, fmt.Errorf("cannot extract port: %s", addr)
|
||||
|
||||
var listener net.Listener
|
||||
var err error
|
||||
if len(address.sock) > 0 {
|
||||
if _, err := os.Stat(address.sock); err == nil {
|
||||
// Check if the socket is already in use
|
||||
if conn, err := net.Dial("unix", address.sock); err == nil {
|
||||
conn.Close()
|
||||
return nil, 0, fmt.Errorf("socket already in use: %s", address.sock)
|
||||
}
|
||||
os.Remove(address.sock)
|
||||
}
|
||||
var err error
|
||||
port, err = strconv.Atoi(parts[len(parts)-1])
|
||||
listener, err = net.Listen("unix", address.sock)
|
||||
if err != nil {
|
||||
return nil, port, err
|
||||
return nil, 0, fmt.Errorf("failed to listen on %s", address.sock)
|
||||
}
|
||||
os.Chmod(address.sock, 0600)
|
||||
} else {
|
||||
addrStr := fmt.Sprintf("%s:%d", host, port)
|
||||
listener, err = net.Listen("tcp", addrStr)
|
||||
if err != nil {
|
||||
return nil, port, fmt.Errorf("failed to listen on %s", addrStr)
|
||||
}
|
||||
if port == 0 {
|
||||
addr := listener.Addr().String()
|
||||
parts := strings.Split(addr, ":")
|
||||
if len(parts) < 2 {
|
||||
return nil, port, fmt.Errorf("cannot extract port: %s", addr)
|
||||
}
|
||||
var err error
|
||||
port, err = strconv.Atoi(parts[len(parts)-1])
|
||||
if err != nil {
|
||||
return nil, port, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
299
src/terminal.go
299
src/terminal.go
@@ -180,6 +180,7 @@ type itemLine struct {
|
||||
result Result
|
||||
empty bool
|
||||
other bool
|
||||
hidden bool
|
||||
}
|
||||
|
||||
func (t *Terminal) inListWindow() bool {
|
||||
@@ -274,9 +275,11 @@ type Terminal struct {
|
||||
footerLabelLen int
|
||||
footerLabelOpts labelOpts
|
||||
gutterReverse bool
|
||||
gutterRawReverse bool
|
||||
pointer string
|
||||
pointerLen int
|
||||
pointerEmpty string
|
||||
pointerEmptyRaw string
|
||||
marker string
|
||||
markerLen int
|
||||
markerEmpty string
|
||||
@@ -383,6 +386,9 @@ type Terminal struct {
|
||||
printer func(string)
|
||||
printsep string
|
||||
merger *Merger
|
||||
passMerger *Merger
|
||||
resultMerger *Merger
|
||||
matchMap map[int32]Result
|
||||
selected map[int32]selectedItem
|
||||
version int64
|
||||
revision revision
|
||||
@@ -429,6 +435,7 @@ type Terminal struct {
|
||||
clickFooterColumn int
|
||||
proxyScript string
|
||||
numLinesCache map[int32]numLinesCacheValue
|
||||
raw bool
|
||||
}
|
||||
|
||||
type numLinesCacheValue struct {
|
||||
@@ -569,13 +576,18 @@ const (
|
||||
actToggleWrap
|
||||
actToggleMultiLine
|
||||
actToggleHscroll
|
||||
actToggleRaw
|
||||
actEnableRaw
|
||||
actDisableRaw
|
||||
actTrackCurrent
|
||||
actToggleInput
|
||||
actHideInput
|
||||
actShowInput
|
||||
actUntrackCurrent
|
||||
actDown
|
||||
actDownMatch
|
||||
actUp
|
||||
actUpMatch
|
||||
actPageUp
|
||||
actPageDown
|
||||
actPosition
|
||||
@@ -651,6 +663,7 @@ const (
|
||||
actExecuteSilent
|
||||
actExecuteMulti // Deprecated
|
||||
actSigStop
|
||||
actBest
|
||||
actFirst
|
||||
actLast
|
||||
actReload
|
||||
@@ -796,8 +809,10 @@ func defaultKeymap() map[tui.Event][]*action {
|
||||
add(tui.CtrlK, actUp)
|
||||
add(tui.CtrlL, actClearScreen)
|
||||
add(tui.Enter, actAccept)
|
||||
add(tui.CtrlN, actDown)
|
||||
add(tui.CtrlP, actUp)
|
||||
add(tui.CtrlN, actDownMatch)
|
||||
add(tui.CtrlP, actUpMatch)
|
||||
add(tui.AltDown, actDownMatch)
|
||||
add(tui.AltUp, actUpMatch)
|
||||
add(tui.CtrlU, actUnixLineDiscard)
|
||||
add(tui.CtrlW, actUnixWordRubout)
|
||||
add(tui.CtrlY, actYank)
|
||||
@@ -953,6 +968,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
||||
}
|
||||
keymapCopy := maps.Clone(opts.Keymap)
|
||||
|
||||
em := EmptyMerger(revision{})
|
||||
t := Terminal{
|
||||
initDelay: delay,
|
||||
infoCommand: opts.InfoCommand,
|
||||
@@ -1039,6 +1055,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
||||
nth: opts.Nth,
|
||||
nthCurrent: opts.Nth,
|
||||
tabstop: opts.Tabstop,
|
||||
raw: opts.Raw,
|
||||
hasStartActions: false,
|
||||
hasResultActions: false,
|
||||
hasFocusActions: false,
|
||||
@@ -1052,7 +1069,10 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
||||
printer: opts.Printer,
|
||||
printsep: opts.PrintSep,
|
||||
proxyScript: opts.ProxyScript,
|
||||
merger: EmptyMerger(revision{}),
|
||||
merger: em,
|
||||
passMerger: em,
|
||||
resultMerger: em,
|
||||
matchMap: make(map[int32]Result),
|
||||
selected: make(map[int32]selectedItem),
|
||||
runningCmds: util.NewConcurrentSet[*runningCmd](),
|
||||
reqBox: util.NewEventBox(),
|
||||
@@ -1089,26 +1109,41 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
||||
t.acceptNth = opts.AcceptNth(t.delimiter)
|
||||
}
|
||||
|
||||
baseTheme := opts.BaseTheme
|
||||
if baseTheme == nil {
|
||||
baseTheme = renderer.DefaultTheme()
|
||||
}
|
||||
// This should be called before accessing tui.Color*
|
||||
tui.InitTheme(opts.Theme, renderer.DefaultTheme(), opts.Black, opts.InputBorderShape.Visible(), opts.HeaderBorderShape.Visible())
|
||||
tui.InitTheme(opts.Theme, baseTheme, opts.Bold, opts.Black, opts.InputBorderShape.Visible(), opts.HeaderBorderShape.Visible())
|
||||
|
||||
// Gutter character
|
||||
var gutterChar string
|
||||
var gutterChar, gutterRawChar string
|
||||
if opts.Gutter != nil {
|
||||
gutterChar = *opts.Gutter
|
||||
} else if t.unicode && !t.theme.Gutter.Color.IsDefault() {
|
||||
} else if t.unicode {
|
||||
gutterChar = "▌"
|
||||
} else {
|
||||
gutterChar = " "
|
||||
t.gutterReverse = true
|
||||
}
|
||||
|
||||
if opts.GutterRaw != nil {
|
||||
gutterRawChar = *opts.GutterRaw
|
||||
} else if t.unicode {
|
||||
gutterRawChar = "▖"
|
||||
} else {
|
||||
gutterRawChar = ":"
|
||||
t.gutterRawReverse = false
|
||||
}
|
||||
|
||||
t.prompt, t.promptLen = t.parsePrompt(opts.Prompt)
|
||||
// Pre-calculated empty pointer and marker signs
|
||||
if t.pointerLen == 0 {
|
||||
t.pointerEmpty = ""
|
||||
t.pointerEmptyRaw = ""
|
||||
} else {
|
||||
t.pointerEmpty = gutterChar + strings.Repeat(" ", util.Max(0, t.pointerLen-1))
|
||||
t.pointerEmptyRaw = gutterRawChar + strings.Repeat(" ", util.Max(0, t.pointerLen-1))
|
||||
}
|
||||
t.markerEmpty = strings.Repeat(" ", t.markerLen)
|
||||
|
||||
@@ -1233,7 +1268,9 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
||||
return nil, err
|
||||
}
|
||||
t.listener = listener
|
||||
t.listenPort = &port
|
||||
if port > 0 {
|
||||
t.listenPort = &port
|
||||
}
|
||||
}
|
||||
|
||||
if t.hasStartActions {
|
||||
@@ -1257,6 +1294,9 @@ func (t *Terminal) environForPreview() []string {
|
||||
|
||||
func (t *Terminal) environImpl(forPreview bool) []string {
|
||||
env := os.Environ()
|
||||
if t.listenAddr != nil && len(t.listenAddr.sock) > 0 {
|
||||
env = append(env, "FZF_SOCK="+t.listenAddr.sock)
|
||||
}
|
||||
if t.listenPort != nil {
|
||||
env = append(env, fmt.Sprintf("FZF_PORT=%d", *t.listenPort))
|
||||
}
|
||||
@@ -1271,9 +1311,21 @@ func (t *Terminal) environImpl(forPreview bool) []string {
|
||||
env = append(env, "FZF_LIST_LABEL="+t.listLabelOpts.label)
|
||||
env = append(env, "FZF_INPUT_LABEL="+t.inputLabelOpts.label)
|
||||
env = append(env, "FZF_HEADER_LABEL="+t.headerLabelOpts.label)
|
||||
direction := "down"
|
||||
if t.layout == layoutDefault {
|
||||
direction = "up"
|
||||
}
|
||||
env = append(env, "FZF_DIRECTION="+direction)
|
||||
if len(t.nthCurrent) > 0 {
|
||||
env = append(env, "FZF_NTH="+RangesToString(t.nthCurrent))
|
||||
}
|
||||
if t.raw {
|
||||
val := "0"
|
||||
if t.isCurrentItemMatch() {
|
||||
val = "1"
|
||||
}
|
||||
env = append(env, "FZF_RAW="+val)
|
||||
}
|
||||
inputState := "enabled"
|
||||
if t.inputless {
|
||||
inputState = "hidden"
|
||||
@@ -1282,7 +1334,7 @@ func (t *Terminal) environImpl(forPreview bool) []string {
|
||||
}
|
||||
env = append(env, "FZF_INPUT_STATE="+inputState)
|
||||
env = append(env, fmt.Sprintf("FZF_TOTAL_COUNT=%d", t.count))
|
||||
env = append(env, fmt.Sprintf("FZF_MATCH_COUNT=%d", t.merger.Length()))
|
||||
env = append(env, fmt.Sprintf("FZF_MATCH_COUNT=%d", t.resultMerger.Length()))
|
||||
env = append(env, fmt.Sprintf("FZF_SELECT_COUNT=%d", len(t.selected)))
|
||||
env = append(env, fmt.Sprintf("FZF_LINES=%d", t.areaLines))
|
||||
env = append(env, fmt.Sprintf("FZF_COLUMNS=%d", t.areaColumns))
|
||||
@@ -1443,7 +1495,7 @@ func (t *Terminal) ansiLabelPrinter(str string, color *tui.ColorPair, fill bool)
|
||||
printFn := func(window tui.Window, limit int) {
|
||||
if offsets == nil {
|
||||
// tui.Col* are not initialized until renderer.Init()
|
||||
offsets = result.colorOffsets(nil, nil, t.theme, *color, *color, t.nthAttr)
|
||||
offsets = result.colorOffsets(nil, nil, t.theme, *color, *color, t.nthAttr, false)
|
||||
}
|
||||
for limit > 0 {
|
||||
if length > limit {
|
||||
@@ -1506,7 +1558,7 @@ func (t *Terminal) parsePrompt(prompt string) (func(), int) {
|
||||
return 1
|
||||
}
|
||||
t.printHighlighted(
|
||||
Result{item: item}, tui.ColPrompt, tui.ColPrompt, false, false, line, line, true, preTask, nil)
|
||||
Result{item: item}, tui.ColPrompt, tui.ColPrompt, false, false, false, line, line, true, preTask, nil)
|
||||
})
|
||||
t.wrap = wrap
|
||||
}
|
||||
@@ -1693,7 +1745,8 @@ func (t *Terminal) UpdateProgress(progress float32) {
|
||||
}
|
||||
|
||||
// UpdateList updates Merger to display the list
|
||||
func (t *Terminal) UpdateList(merger *Merger) {
|
||||
func (t *Terminal) UpdateList(result MatchResult) {
|
||||
merger := result.merger
|
||||
t.mutex.Lock()
|
||||
prevIndex := minItem.Index()
|
||||
newRevision := merger.Revision()
|
||||
@@ -1706,6 +1759,15 @@ func (t *Terminal) UpdateList(merger *Merger) {
|
||||
}
|
||||
t.progress = 100
|
||||
t.merger = merger
|
||||
t.resultMerger = merger
|
||||
t.passMerger = result.passMerger
|
||||
if t.raw {
|
||||
t.merger = result.passMerger
|
||||
t.matchMap = t.resultMerger.ToMap()
|
||||
} else {
|
||||
t.merger = result.merger
|
||||
t.matchMap = make(map[int32]Result)
|
||||
}
|
||||
if t.revision != newRevision {
|
||||
if !t.revision.compatible(newRevision) {
|
||||
// Reloaded: clear selection
|
||||
@@ -1754,7 +1816,7 @@ func (t *Terminal) UpdateList(merger *Merger) {
|
||||
}
|
||||
needActivation := false
|
||||
if !t.reading {
|
||||
switch t.merger.Length() {
|
||||
switch t.resultMerger.Length() {
|
||||
case 0:
|
||||
zero := tui.Zero.AsEvent()
|
||||
if _, prs := t.keymap[zero]; prs {
|
||||
@@ -2397,6 +2459,13 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) {
|
||||
innerHeight-shrink, tui.WindowList, noBorder, true)
|
||||
}
|
||||
|
||||
if len(t.scrollbar) == 0 {
|
||||
for y := 0; y < t.window.Height(); y++ {
|
||||
t.window.Move(y, t.window.Width()-1)
|
||||
t.window.Print(" ")
|
||||
}
|
||||
}
|
||||
|
||||
createInnerWindow := func(b tui.Window, shape tui.BorderShape, windowType tui.WindowType, shift int) tui.Window {
|
||||
top := b.Top()
|
||||
left := b.Left() + shift
|
||||
@@ -2794,7 +2863,7 @@ func (t *Terminal) printInfoImpl() {
|
||||
return
|
||||
}
|
||||
|
||||
found := t.merger.Length()
|
||||
found := t.resultMerger.Length()
|
||||
total := util.Max(found, t.count)
|
||||
output := fmt.Sprintf("%d/%d", found, total)
|
||||
if t.toggleSort {
|
||||
@@ -3011,7 +3080,7 @@ func (t *Terminal) printFooter() {
|
||||
colors: colors}
|
||||
|
||||
t.printHighlighted(Result{item: item},
|
||||
tui.ColFooter, tui.ColFooter, false, false, line, line, true,
|
||||
tui.ColFooter, tui.ColFooter, false, false, false, line, line, true,
|
||||
func(markerClass) int {
|
||||
t.footerWindow.Print(indent)
|
||||
return indentSize
|
||||
@@ -3083,7 +3152,7 @@ func (t *Terminal) printHeaderImpl(window tui.Window, borderShape tui.BorderShap
|
||||
colors: colors}
|
||||
|
||||
t.printHighlighted(Result{item: item},
|
||||
tui.ColHeader, tui.ColHeader, false, false, line, line, true,
|
||||
tui.ColHeader, tui.ColHeader, false, false, false, line, line, true,
|
||||
func(markerClass) int {
|
||||
t.window.Print(indent)
|
||||
return indentSize
|
||||
@@ -3115,12 +3184,16 @@ func (t *Terminal) gutter(current bool) {
|
||||
var color tui.ColorPair
|
||||
if current {
|
||||
color = tui.ColCurrentCursorEmpty
|
||||
} else if t.gutterReverse {
|
||||
} else if !t.raw && t.gutterReverse || t.raw && t.gutterRawReverse {
|
||||
color = tui.ColCursorEmpty
|
||||
} else {
|
||||
color = tui.ColCursorEmptyChar
|
||||
}
|
||||
t.window.CPrint(color, t.pointerEmpty)
|
||||
gutter := t.pointerEmpty
|
||||
if t.raw {
|
||||
gutter = t.pointerEmptyRaw
|
||||
}
|
||||
t.window.CPrint(color, gutter)
|
||||
}
|
||||
|
||||
func (t *Terminal) renderGapLine(line int, barRange [2]int, drawLine bool) {
|
||||
@@ -3155,7 +3228,8 @@ func (t *Terminal) printList() {
|
||||
for line, itemCount := startLine, 0; line <= maxy; line, itemCount = line+1, itemCount+1 {
|
||||
if itemCount < count {
|
||||
item := t.merger.Get(itemCount + t.offset)
|
||||
line = t.printItem(item, line, maxy, itemCount, itemCount == t.cy-t.offset, barRange)
|
||||
current := itemCount == t.cy-t.offset
|
||||
line = t.printItem(item, line, maxy, itemCount, current, barRange)
|
||||
} else if !t.prevLines[line].empty {
|
||||
t.renderEmptyLine(line, barRange)
|
||||
}
|
||||
@@ -3177,6 +3251,14 @@ func (t *Terminal) printBar(lineNum int, forceRedraw bool, barRange [2]int) bool
|
||||
|
||||
func (t *Terminal) printItem(result Result, line int, maxLine int, index int, current bool, barRange [2]int) int {
|
||||
item := result.item
|
||||
matched := true
|
||||
var matchResult Result
|
||||
if t.raw {
|
||||
if matchResult, matched = t.matchMap[item.Index()]; matched {
|
||||
result = matchResult
|
||||
}
|
||||
}
|
||||
|
||||
_, selected := t.selected[item.Index()]
|
||||
label := ""
|
||||
extraWidth := 0
|
||||
@@ -3207,7 +3289,7 @@ func (t *Terminal) printItem(result Result, line int, maxLine int, index int, cu
|
||||
// Avoid unnecessary redraw
|
||||
numLines, _ := t.numItemLines(item, maxLine-line+1)
|
||||
newLine := itemLine{valid: true, firstLine: line, numLines: numLines, cy: index + t.offset, current: current, selected: selected, label: label,
|
||||
result: result, queryLen: len(t.input), width: 0, hasBar: line >= barRange[0] && line < barRange[1]}
|
||||
result: result, queryLen: len(t.input), width: 0, hasBar: line >= barRange[0] && line < barRange[1], hidden: !matched}
|
||||
prevLine := t.prevLines[line]
|
||||
forceRedraw := !prevLine.valid || prevLine.other || prevLine.firstLine != newLine.firstLine
|
||||
printBar := func(lineNum int, forceRedraw bool) bool {
|
||||
@@ -3215,6 +3297,7 @@ func (t *Terminal) printItem(result Result, line int, maxLine int, index int, cu
|
||||
}
|
||||
|
||||
if !forceRedraw &&
|
||||
prevLine.hidden == newLine.hidden &&
|
||||
prevLine.numLines == newLine.numLines &&
|
||||
prevLine.current == newLine.current &&
|
||||
prevLine.selected == newLine.selected &&
|
||||
@@ -3303,7 +3386,7 @@ func (t *Terminal) printItem(result Result, line int, maxLine int, index int, cu
|
||||
}
|
||||
return indentSize
|
||||
}
|
||||
finalLineNum = t.printHighlighted(result, tui.ColCurrent, tui.ColCurrentMatch, true, true, line, maxLine, forceRedraw, preTask, postTask)
|
||||
finalLineNum = t.printHighlighted(result, tui.ColCurrent, tui.ColCurrentMatch, true, true, !matched, line, maxLine, forceRedraw, preTask, postTask)
|
||||
} else {
|
||||
preTask := func(marker markerClass) int {
|
||||
w := t.window.Width() - t.pointerLen
|
||||
@@ -3337,7 +3420,7 @@ func (t *Terminal) printItem(result Result, line int, maxLine int, index int, cu
|
||||
base = base.WithBg(altBg)
|
||||
match = match.WithBg(altBg)
|
||||
}
|
||||
finalLineNum = t.printHighlighted(result, base, match, false, true, line, maxLine, forceRedraw, preTask, postTask)
|
||||
finalLineNum = t.printHighlighted(result, base, match, false, true, !matched, line, maxLine, forceRedraw, preTask, postTask)
|
||||
}
|
||||
for i := 0; i < t.gap && finalLineNum < maxLine; i++ {
|
||||
finalLineNum++
|
||||
@@ -3384,13 +3467,13 @@ func (t *Terminal) overflow(runes []rune, max int) bool {
|
||||
return t.displayWidthWithLimit(runes, 0, max) > max
|
||||
}
|
||||
|
||||
func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMatch tui.ColorPair, current bool, match bool, lineNum int, maxLineNum int, forceRedraw bool, preTask func(markerClass) int, postTask func(int, int, bool, bool, tui.ColorPair)) int {
|
||||
func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMatch tui.ColorPair, current bool, match bool, hidden bool, lineNum int, maxLineNum int, forceRedraw bool, preTask func(markerClass) int, postTask func(int, int, bool, bool, tui.ColorPair)) int {
|
||||
var displayWidth int
|
||||
item := result.item
|
||||
matchOffsets := []Offset{}
|
||||
var pos *[]int
|
||||
if match && t.merger.pattern != nil {
|
||||
_, matchOffsets, pos = t.merger.pattern.MatchItem(item, true, t.slab)
|
||||
if match && t.resultMerger.pattern != nil {
|
||||
_, matchOffsets, pos = t.resultMerger.pattern.MatchItem(item, true, t.slab)
|
||||
}
|
||||
charOffsets := matchOffsets
|
||||
if pos != nil {
|
||||
@@ -3422,7 +3505,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
||||
}
|
||||
if !wholeCovered && t.nthAttr > 0 {
|
||||
var tokens []Token
|
||||
if item.transformed != nil && item.transformed.revision == t.merger.revision {
|
||||
if item.transformed != nil && item.transformed.revision == t.resultMerger.revision {
|
||||
tokens = item.transformed.tokens
|
||||
} else {
|
||||
tokens = Transform(Tokenize(item.text.ToString(), t.delimiter), t.nthCurrent)
|
||||
@@ -3436,7 +3519,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
||||
sort.Sort(ByOrder(nthOffsets))
|
||||
}
|
||||
}
|
||||
allOffsets := result.colorOffsets(charOffsets, nthOffsets, t.theme, colBase, colMatch, t.nthAttr)
|
||||
allOffsets := result.colorOffsets(charOffsets, nthOffsets, t.theme, colBase, colMatch, t.nthAttr, hidden)
|
||||
|
||||
maxLines := 1
|
||||
if t.canSpanMultiLines() {
|
||||
@@ -3635,7 +3718,11 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
||||
}
|
||||
|
||||
if maxWidth > 0 {
|
||||
t.printColoredString(t.window, line, offsets, colBase)
|
||||
color := colBase
|
||||
if hidden {
|
||||
color = color.WithFg(t.theme.Nomatch)
|
||||
}
|
||||
t.printColoredString(t.window, line, offsets, color)
|
||||
}
|
||||
if postTask != nil {
|
||||
postTask(actualLineNum, displayWidth, wasWrapped, forceRedraw, lbg)
|
||||
@@ -4670,6 +4757,33 @@ func (t *Terminal) currentItem() *Item {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Terminal) isCurrentItemMatch() bool {
|
||||
cnt := t.merger.Length()
|
||||
if t.cy >= 0 && cnt > 0 && cnt > t.cy {
|
||||
if !t.raw {
|
||||
return true
|
||||
}
|
||||
item := t.merger.Get(t.cy).item
|
||||
return t.isItemMatch(item)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *Terminal) isItemMatch(item *Item) bool {
|
||||
_, matched := t.matchMap[item.Index()]
|
||||
return matched
|
||||
}
|
||||
|
||||
func (t *Terminal) filterSelected() {
|
||||
filtered := make(map[int32]selectedItem)
|
||||
for k, v := range t.selected {
|
||||
if t.isItemMatch(v.item) {
|
||||
filtered[k] = v
|
||||
}
|
||||
}
|
||||
t.selected = filtered
|
||||
}
|
||||
|
||||
func (t *Terminal) buildPlusList(template string, forcePlus bool) (bool, [3][]*Item) {
|
||||
current := t.currentItem()
|
||||
slot, plus, asterisk, forceUpdate := hasPreviewFlags(template)
|
||||
@@ -5910,8 +6024,9 @@ func (t *Terminal) Loop() error {
|
||||
}
|
||||
case actSelectAll:
|
||||
if t.multi > 0 {
|
||||
for i := 0; i < t.merger.Length(); i++ {
|
||||
if !t.selectItem(t.merger.Get(i).item) {
|
||||
// Limit the scope only to the matching items
|
||||
for i := 0; i < t.resultMerger.Length(); i++ {
|
||||
if !t.selectItem(t.resultMerger.Get(i).item) {
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -5919,8 +6034,10 @@ func (t *Terminal) Loop() error {
|
||||
}
|
||||
case actDeselectAll:
|
||||
if t.multi > 0 {
|
||||
for i := 0; i < t.merger.Length() && len(t.selected) > 0; i++ {
|
||||
t.deselectItem(t.merger.Get(i).item)
|
||||
// Also limit the scope only to the matching items, while this may
|
||||
// not be straightforward in raw mode.
|
||||
for i := 0; i < t.resultMerger.Length() && len(t.selected) > 0; i++ {
|
||||
t.deselectItem(t.resultMerger.Get(i).item)
|
||||
}
|
||||
req(reqList, reqInfo)
|
||||
}
|
||||
@@ -5948,17 +6065,17 @@ func (t *Terminal) Loop() error {
|
||||
case actToggleAll:
|
||||
if t.multi > 0 {
|
||||
prevIndexes := make(map[int]struct{})
|
||||
for i := 0; i < t.merger.Length() && len(t.selected) > 0; i++ {
|
||||
item := t.merger.Get(i).item
|
||||
for i := 0; i < t.resultMerger.Length() && len(t.selected) > 0; i++ {
|
||||
item := t.resultMerger.Get(i).item
|
||||
if _, found := t.selected[item.Index()]; found {
|
||||
prevIndexes[i] = struct{}{}
|
||||
t.deselectItem(item)
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < t.merger.Length(); i++ {
|
||||
for i := 0; i < t.resultMerger.Length(); i++ {
|
||||
if _, found := prevIndexes[i]; !found {
|
||||
item := t.merger.Get(i).item
|
||||
item := t.resultMerger.Get(i).item
|
||||
if !t.selectItem(item) {
|
||||
break
|
||||
}
|
||||
@@ -5986,11 +6103,88 @@ func (t *Terminal) Loop() error {
|
||||
t.vmove(1, true)
|
||||
req(reqList)
|
||||
}
|
||||
case actDown:
|
||||
t.vmove(-1, true)
|
||||
case actDown, actDownMatch, actUp, actUpMatch:
|
||||
dir := -1
|
||||
if a.t == actUp || a.t == actUpMatch {
|
||||
dir = 1
|
||||
}
|
||||
if t.raw && (a.t == actDownMatch || a.t == actUpMatch) {
|
||||
if t.resultMerger.Length() > 0 {
|
||||
prevCy := t.cy
|
||||
for t.vmove(dir, true) && !t.isCurrentItemMatch() {
|
||||
}
|
||||
if !t.isCurrentItemMatch() {
|
||||
t.vset(prevCy)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
t.vmove(dir, true)
|
||||
}
|
||||
req(reqList)
|
||||
case actUp:
|
||||
t.vmove(1, true)
|
||||
case actToggleRaw, actEnableRaw, actDisableRaw:
|
||||
prevRaw := t.raw
|
||||
newRaw := t.raw
|
||||
switch a.t {
|
||||
case actEnableRaw:
|
||||
newRaw = true
|
||||
case actDisableRaw:
|
||||
newRaw = false
|
||||
case actToggleRaw:
|
||||
newRaw = !t.raw
|
||||
}
|
||||
if prevRaw == newRaw {
|
||||
break
|
||||
}
|
||||
prevPos := t.cy - t.offset
|
||||
prevIndex := t.currentIndex()
|
||||
if newRaw {
|
||||
// Build matchMap if not available
|
||||
if len(t.matchMap) == 0 {
|
||||
t.matchMap = t.resultMerger.ToMap()
|
||||
}
|
||||
t.merger = t.passMerger
|
||||
} else {
|
||||
// Find the closest matching item
|
||||
if !t.isCurrentItemMatch() && t.resultMerger.Length() > 1 {
|
||||
distance := 0
|
||||
Loop:
|
||||
for {
|
||||
distance++
|
||||
checks := 0
|
||||
for _, cy := range []int{t.cy + distance, t.cy - distance} {
|
||||
if cy >= 0 && cy < t.merger.Length() {
|
||||
checks++
|
||||
item := t.merger.Get(cy).item
|
||||
if t.isItemMatch(item) {
|
||||
prevIndex = item.Index()
|
||||
break Loop
|
||||
}
|
||||
}
|
||||
}
|
||||
if checks == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.merger = t.resultMerger
|
||||
|
||||
// Need to remove non-matching items from the selection
|
||||
if t.multi > 0 && len(t.selected) > 0 {
|
||||
t.filterSelected()
|
||||
req(reqInfo)
|
||||
}
|
||||
}
|
||||
t.raw = newRaw
|
||||
|
||||
// Try to retain position
|
||||
if prevIndex != minItem.Index() {
|
||||
t.cy = util.Max(0, t.merger.FindIndex(prevIndex))
|
||||
t.offset = t.cy - prevPos
|
||||
}
|
||||
|
||||
// List needs to be rerendered
|
||||
t.forceRerenderList()
|
||||
req(reqList)
|
||||
case actAccept:
|
||||
req(reqClose)
|
||||
@@ -6015,8 +6209,14 @@ func (t *Terminal) Loop() error {
|
||||
t.version++
|
||||
req(reqList, reqInfo)
|
||||
}
|
||||
case actFirst:
|
||||
t.vset(0)
|
||||
case actFirst, actBest:
|
||||
if t.raw && a.t == actBest {
|
||||
if t.resultMerger.Length() > 0 {
|
||||
t.vset(t.merger.FindIndex(t.resultMerger.Get(0).item.Index()))
|
||||
}
|
||||
} else {
|
||||
t.vset(0)
|
||||
}
|
||||
t.constrain()
|
||||
req(reqList)
|
||||
case actLast:
|
||||
@@ -6144,7 +6344,7 @@ func (t *Terminal) Loop() error {
|
||||
if a.t == actOffsetDown {
|
||||
diff = -1
|
||||
}
|
||||
if t.layout == layoutReverse {
|
||||
if t.layout != layoutDefault {
|
||||
diff *= -1
|
||||
}
|
||||
t.offset += diff
|
||||
@@ -6152,7 +6352,7 @@ func (t *Terminal) Loop() error {
|
||||
t.constrain()
|
||||
if before != t.offset {
|
||||
t.offset = before
|
||||
if t.layout == layoutReverse {
|
||||
if t.layout != layoutDefault {
|
||||
diff *= -1
|
||||
}
|
||||
t.vmove(diff, false)
|
||||
@@ -6834,7 +7034,7 @@ func (t *Terminal) Loop() error {
|
||||
reload := changed || newCommand != nil
|
||||
var reloadRequest *searchRequest
|
||||
if reload {
|
||||
reloadRequest = &searchRequest{sort: t.sort, sync: reloadSync, nth: newNth, command: newCommand, environ: t.environ(), changed: changed, denylist: denylist, revision: t.merger.Revision()}
|
||||
reloadRequest = &searchRequest{sort: t.sort, sync: reloadSync, nth: newNth, command: newCommand, environ: t.environ(), changed: changed, denylist: denylist, revision: t.resultMerger.Revision()}
|
||||
}
|
||||
|
||||
// Dispatch queued background requests
|
||||
@@ -6954,7 +7154,8 @@ func (t *Terminal) constrain() {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Terminal) vmove(o int, allowCycle bool) {
|
||||
// Returns true if the cursor position is successfully updated
|
||||
func (t *Terminal) vmove(o int, allowCycle bool) bool {
|
||||
if t.layout != layoutDefault {
|
||||
o *= -1
|
||||
}
|
||||
@@ -6971,7 +7172,7 @@ func (t *Terminal) vmove(o int, allowCycle bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
t.vset(dest)
|
||||
return t.vset(dest)
|
||||
}
|
||||
|
||||
func (t *Terminal) vset(o int) bool {
|
||||
@@ -7038,9 +7239,9 @@ func (t *Terminal) dumpStatus(params getParams) string {
|
||||
selected[i] = t.dumpItem(selectedItems[i+params.offset].item)
|
||||
}
|
||||
|
||||
matches := make([]StatusItem, util.Max(0, util.Min(params.limit, t.merger.Length()-params.offset)))
|
||||
matches := make([]StatusItem, util.Max(0, util.Min(params.limit, t.resultMerger.Length()-params.offset)))
|
||||
for i := range matches {
|
||||
matches[i] = t.dumpItem(t.merger.Get(i + params.offset).item)
|
||||
matches[i] = t.dumpItem(t.resultMerger.Get(i + params.offset).item)
|
||||
}
|
||||
|
||||
var current *StatusItem
|
||||
@@ -7057,7 +7258,7 @@ func (t *Terminal) dumpStatus(params getParams) string {
|
||||
Position: t.cy,
|
||||
Sort: t.sort,
|
||||
TotalCount: t.count,
|
||||
MatchCount: t.merger.Length(),
|
||||
MatchCount: t.resultMerger.Length(),
|
||||
Current: current,
|
||||
Matches: matches,
|
||||
Selected: selected,
|
||||
|
||||
@@ -2,30 +2,7 @@
|
||||
|
||||
package tui
|
||||
|
||||
type Attr int32
|
||||
|
||||
func HasFullscreenRenderer() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var DefaultBorderShape = BorderRounded
|
||||
|
||||
func (a Attr) Merge(b Attr) Attr {
|
||||
if b&AttrRegular > 0 {
|
||||
// Only keep bold attribute set by the system
|
||||
return (b &^ AttrRegular) | (a & BoldForce)
|
||||
}
|
||||
|
||||
return (a &^ AttrRegular) | b
|
||||
}
|
||||
|
||||
const (
|
||||
AttrUndefined = Attr(0)
|
||||
AttrRegular = Attr(1 << 8)
|
||||
AttrClear = Attr(1 << 9)
|
||||
BoldForce = Attr(1 << 10)
|
||||
FullBg = Attr(1 << 11)
|
||||
|
||||
Bold = Attr(1)
|
||||
Dim = Attr(1 << 1)
|
||||
Italic = Attr(1 << 2)
|
||||
@@ -36,6 +13,12 @@ const (
|
||||
StrikeThrough = Attr(1 << 7)
|
||||
)
|
||||
|
||||
func HasFullscreenRenderer() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var DefaultBorderShape = BorderRounded
|
||||
|
||||
func (r *FullscreenRenderer) Init() error { return nil }
|
||||
func (r *FullscreenRenderer) DefaultTheme() *ColorTheme { return nil }
|
||||
func (r *FullscreenRenderer) Resize(maxHeightFunc func(int) int) {}
|
||||
|
||||
@@ -36,8 +36,6 @@ func (p ColorPair) style() tcell.Style {
|
||||
return style.Foreground(asTcellColor(p.Fg())).Background(asTcellColor(p.Bg()))
|
||||
}
|
||||
|
||||
type Attr int32
|
||||
|
||||
type TcellWindow struct {
|
||||
color bool
|
||||
windowType WindowType
|
||||
@@ -98,14 +96,6 @@ const (
|
||||
Italic = Attr(tcell.AttrItalic)
|
||||
)
|
||||
|
||||
const (
|
||||
AttrUndefined = Attr(0)
|
||||
AttrRegular = Attr(1 << 7)
|
||||
AttrClear = Attr(1 << 8)
|
||||
BoldForce = Attr(1 << 10)
|
||||
FullBg = Attr(1 << 11)
|
||||
)
|
||||
|
||||
func (r *FullscreenRenderer) Bell() {
|
||||
_screen.Beep()
|
||||
}
|
||||
@@ -159,15 +149,6 @@ func (c Color) Style() tcell.Color {
|
||||
}
|
||||
}
|
||||
|
||||
func (a Attr) Merge(b Attr) Attr {
|
||||
if b&AttrRegular > 0 {
|
||||
// Only keep bold attribute set by the system
|
||||
return (b &^ AttrRegular) | (a & BoldForce)
|
||||
}
|
||||
|
||||
return (a &^ AttrRegular) | b
|
||||
}
|
||||
|
||||
// handle the following as private members of FullscreenRenderer instance
|
||||
// they are declared here to prevent introducing tcell library in non-windows builds
|
||||
var (
|
||||
|
||||
516
src/tui/tui.go
516
src/tui/tui.go
@@ -8,6 +8,26 @@ import (
|
||||
"github.com/rivo/uniseg"
|
||||
)
|
||||
|
||||
type Attr int32
|
||||
|
||||
const (
|
||||
AttrUndefined = Attr(0)
|
||||
AttrRegular = Attr(1 << 8)
|
||||
AttrClear = Attr(1 << 9)
|
||||
BoldForce = Attr(1 << 10)
|
||||
FullBg = Attr(1 << 11)
|
||||
Strip = Attr(1 << 12)
|
||||
)
|
||||
|
||||
func (a Attr) Merge(b Attr) Attr {
|
||||
if b&AttrRegular > 0 {
|
||||
// Only keep bold attribute set by the system
|
||||
return (b &^ AttrRegular) | (a & BoldForce)
|
||||
}
|
||||
|
||||
return (a &^ AttrRegular) | b
|
||||
}
|
||||
|
||||
// Types of user action
|
||||
//
|
||||
//go:generate stringer -type=EventType
|
||||
@@ -275,6 +295,13 @@ func (a ColorAttr) IsColorDefined() bool {
|
||||
return a.Color != colUndefined
|
||||
}
|
||||
|
||||
func (a ColorAttr) IsAttrDefined() bool {
|
||||
return a.Attr != AttrUndefined
|
||||
}
|
||||
func (a ColorAttr) IsUndefined() bool {
|
||||
return !a.IsColorDefined() && !a.IsAttrDefined()
|
||||
}
|
||||
|
||||
func NewColorAttr() ColorAttr {
|
||||
return ColorAttr{Color: colUndefined, Attr: AttrUndefined}
|
||||
}
|
||||
@@ -358,6 +385,10 @@ func (p ColorPair) IsFullBgMarker() bool {
|
||||
return p.attr&FullBg > 0
|
||||
}
|
||||
|
||||
func (p ColorPair) ShouldStripColors() bool {
|
||||
return p.attr&Strip > 0
|
||||
}
|
||||
|
||||
func (p ColorPair) HasBg() bool {
|
||||
return p.attr&Reverse == 0 && p.bg != colDefault ||
|
||||
p.attr&Reverse > 0 && p.fg != colDefault
|
||||
@@ -381,6 +412,12 @@ func (p ColorPair) WithAttr(attr Attr) ColorPair {
|
||||
return dup
|
||||
}
|
||||
|
||||
func (p ColorPair) WithFg(fg ColorAttr) ColorPair {
|
||||
dup := p
|
||||
fgPair := ColorPair{fg.Color, colUndefined, fg.Attr}
|
||||
return dup.Merge(fgPair)
|
||||
}
|
||||
|
||||
func (p ColorPair) WithBg(bg ColorAttr) ColorPair {
|
||||
dup := p
|
||||
bgPair := ColorPair{colUndefined, bg.Color, bg.Attr}
|
||||
@@ -410,6 +447,7 @@ type ColorTheme struct {
|
||||
ListBg ColorAttr
|
||||
AltBg ColorAttr
|
||||
Nth ColorAttr
|
||||
Nomatch ColorAttr
|
||||
SelectedFg ColorAttr
|
||||
SelectedBg ColorAttr
|
||||
SelectedMatch ColorAttr
|
||||
@@ -772,9 +810,11 @@ func NewFullscreenRenderer(theme *ColorTheme, forceBlack bool, mouse bool) Rende
|
||||
}
|
||||
|
||||
var (
|
||||
Default16 *ColorTheme
|
||||
Dark256 *ColorTheme
|
||||
Light256 *ColorTheme
|
||||
NoColorTheme *ColorTheme
|
||||
EmptyTheme *ColorTheme
|
||||
Default16 *ColorTheme
|
||||
Dark256 *ColorTheme
|
||||
Light256 *ColorTheme
|
||||
|
||||
ColPrompt ColorPair
|
||||
ColNormal ColorPair
|
||||
@@ -818,119 +858,120 @@ var (
|
||||
ColInputLabel ColorPair
|
||||
)
|
||||
|
||||
func EmptyTheme() *ColorTheme {
|
||||
return &ColorTheme{
|
||||
Colored: true,
|
||||
Input: ColorAttr{colUndefined, AttrUndefined},
|
||||
Fg: ColorAttr{colUndefined, AttrUndefined},
|
||||
Bg: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
AltBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedMatch: ColorAttr{colUndefined, AttrUndefined},
|
||||
DarkBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
Prompt: ColorAttr{colUndefined, AttrUndefined},
|
||||
Match: ColorAttr{colUndefined, AttrUndefined},
|
||||
Current: ColorAttr{colUndefined, AttrUndefined},
|
||||
CurrentMatch: ColorAttr{colUndefined, AttrUndefined},
|
||||
Spinner: ColorAttr{colUndefined, AttrUndefined},
|
||||
Info: ColorAttr{colUndefined, AttrUndefined},
|
||||
Cursor: ColorAttr{colUndefined, AttrUndefined},
|
||||
Marker: ColorAttr{colUndefined, AttrUndefined},
|
||||
Header: ColorAttr{colUndefined, AttrUndefined},
|
||||
Footer: ColorAttr{colUndefined, AttrUndefined},
|
||||
Border: ColorAttr{colUndefined, AttrUndefined},
|
||||
BorderLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
Ghost: ColorAttr{colUndefined, Dim},
|
||||
Disabled: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
Separator: ColorAttr{colUndefined, AttrUndefined},
|
||||
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
GapLine: ColorAttr{colUndefined, AttrUndefined},
|
||||
Nth: ColorAttr{colUndefined, AttrUndefined},
|
||||
}
|
||||
}
|
||||
|
||||
func NoColorTheme() *ColorTheme {
|
||||
return &ColorTheme{
|
||||
Colored: false,
|
||||
Input: ColorAttr{colDefault, AttrUndefined},
|
||||
Fg: ColorAttr{colDefault, AttrUndefined},
|
||||
Bg: ColorAttr{colDefault, AttrUndefined},
|
||||
ListFg: ColorAttr{colDefault, AttrUndefined},
|
||||
ListBg: ColorAttr{colDefault, AttrUndefined},
|
||||
AltBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedFg: ColorAttr{colDefault, AttrUndefined},
|
||||
SelectedBg: ColorAttr{colDefault, AttrUndefined},
|
||||
SelectedMatch: ColorAttr{colDefault, AttrUndefined},
|
||||
DarkBg: ColorAttr{colDefault, AttrUndefined},
|
||||
Prompt: ColorAttr{colDefault, AttrUndefined},
|
||||
Match: ColorAttr{colDefault, Underline},
|
||||
Current: ColorAttr{colDefault, Reverse},
|
||||
CurrentMatch: ColorAttr{colDefault, Reverse | Underline},
|
||||
Spinner: ColorAttr{colDefault, AttrUndefined},
|
||||
Info: ColorAttr{colDefault, AttrUndefined},
|
||||
Cursor: ColorAttr{colDefault, AttrUndefined},
|
||||
Marker: ColorAttr{colDefault, AttrUndefined},
|
||||
Header: ColorAttr{colDefault, AttrUndefined},
|
||||
Border: ColorAttr{colDefault, AttrUndefined},
|
||||
BorderLabel: ColorAttr{colDefault, AttrUndefined},
|
||||
Ghost: ColorAttr{colDefault, Dim},
|
||||
Disabled: ColorAttr{colDefault, AttrUndefined},
|
||||
PreviewFg: ColorAttr{colDefault, AttrUndefined},
|
||||
PreviewBg: ColorAttr{colDefault, AttrUndefined},
|
||||
Gutter: ColorAttr{colDefault, AttrUndefined},
|
||||
PreviewBorder: ColorAttr{colDefault, AttrUndefined},
|
||||
PreviewScrollbar: ColorAttr{colDefault, AttrUndefined},
|
||||
PreviewLabel: ColorAttr{colDefault, AttrUndefined},
|
||||
ListLabel: ColorAttr{colDefault, AttrUndefined},
|
||||
ListBorder: ColorAttr{colDefault, AttrUndefined},
|
||||
Separator: ColorAttr{colDefault, AttrUndefined},
|
||||
Scrollbar: ColorAttr{colDefault, AttrUndefined},
|
||||
InputBg: ColorAttr{colDefault, AttrUndefined},
|
||||
InputBorder: ColorAttr{colDefault, AttrUndefined},
|
||||
InputLabel: ColorAttr{colDefault, AttrUndefined},
|
||||
HeaderBg: ColorAttr{colDefault, AttrUndefined},
|
||||
HeaderBorder: ColorAttr{colDefault, AttrUndefined},
|
||||
HeaderLabel: ColorAttr{colDefault, AttrUndefined},
|
||||
FooterBg: ColorAttr{colDefault, AttrUndefined},
|
||||
FooterBorder: ColorAttr{colDefault, AttrUndefined},
|
||||
FooterLabel: ColorAttr{colDefault, AttrUndefined},
|
||||
GapLine: ColorAttr{colDefault, AttrUndefined},
|
||||
Nth: ColorAttr{colUndefined, AttrUndefined},
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
defaultColor := ColorAttr{colDefault, AttrUndefined}
|
||||
undefined := ColorAttr{colUndefined, AttrUndefined}
|
||||
|
||||
NoColorTheme = &ColorTheme{
|
||||
Colored: false,
|
||||
Input: defaultColor,
|
||||
Fg: defaultColor,
|
||||
Bg: defaultColor,
|
||||
ListFg: defaultColor,
|
||||
ListBg: defaultColor,
|
||||
AltBg: undefined,
|
||||
SelectedFg: defaultColor,
|
||||
SelectedBg: defaultColor,
|
||||
SelectedMatch: defaultColor,
|
||||
DarkBg: defaultColor,
|
||||
Prompt: defaultColor,
|
||||
Match: defaultColor,
|
||||
Current: undefined,
|
||||
CurrentMatch: undefined,
|
||||
Spinner: defaultColor,
|
||||
Info: defaultColor,
|
||||
Cursor: defaultColor,
|
||||
Marker: defaultColor,
|
||||
Header: defaultColor,
|
||||
Border: undefined,
|
||||
BorderLabel: defaultColor,
|
||||
Ghost: undefined,
|
||||
Disabled: defaultColor,
|
||||
PreviewFg: defaultColor,
|
||||
PreviewBg: defaultColor,
|
||||
Gutter: undefined,
|
||||
PreviewBorder: defaultColor,
|
||||
PreviewScrollbar: defaultColor,
|
||||
PreviewLabel: defaultColor,
|
||||
ListLabel: defaultColor,
|
||||
ListBorder: defaultColor,
|
||||
Separator: defaultColor,
|
||||
Scrollbar: defaultColor,
|
||||
InputBg: defaultColor,
|
||||
InputBorder: defaultColor,
|
||||
InputLabel: defaultColor,
|
||||
HeaderBg: defaultColor,
|
||||
HeaderBorder: defaultColor,
|
||||
HeaderLabel: defaultColor,
|
||||
FooterBg: defaultColor,
|
||||
FooterBorder: defaultColor,
|
||||
FooterLabel: defaultColor,
|
||||
GapLine: defaultColor,
|
||||
Nth: undefined,
|
||||
Nomatch: undefined,
|
||||
}
|
||||
|
||||
EmptyTheme = &ColorTheme{
|
||||
Colored: true,
|
||||
Input: undefined,
|
||||
Fg: undefined,
|
||||
Bg: undefined,
|
||||
ListFg: undefined,
|
||||
ListBg: undefined,
|
||||
AltBg: undefined,
|
||||
SelectedFg: undefined,
|
||||
SelectedBg: undefined,
|
||||
SelectedMatch: undefined,
|
||||
DarkBg: undefined,
|
||||
Prompt: undefined,
|
||||
Match: undefined,
|
||||
Current: undefined,
|
||||
CurrentMatch: undefined,
|
||||
Spinner: undefined,
|
||||
Info: undefined,
|
||||
Cursor: undefined,
|
||||
Marker: undefined,
|
||||
Header: undefined,
|
||||
Footer: undefined,
|
||||
Border: undefined,
|
||||
BorderLabel: undefined,
|
||||
ListLabel: undefined,
|
||||
ListBorder: undefined,
|
||||
Ghost: undefined,
|
||||
Disabled: undefined,
|
||||
PreviewFg: undefined,
|
||||
PreviewBg: undefined,
|
||||
Gutter: undefined,
|
||||
PreviewBorder: undefined,
|
||||
PreviewScrollbar: undefined,
|
||||
PreviewLabel: undefined,
|
||||
Separator: undefined,
|
||||
Scrollbar: undefined,
|
||||
InputBg: undefined,
|
||||
InputBorder: undefined,
|
||||
InputLabel: undefined,
|
||||
HeaderBg: undefined,
|
||||
HeaderBorder: undefined,
|
||||
HeaderLabel: undefined,
|
||||
FooterBg: undefined,
|
||||
FooterBorder: undefined,
|
||||
FooterLabel: undefined,
|
||||
GapLine: undefined,
|
||||
Nth: undefined,
|
||||
Nomatch: undefined,
|
||||
}
|
||||
|
||||
Default16 = &ColorTheme{
|
||||
Colored: true,
|
||||
Input: ColorAttr{colDefault, AttrUndefined},
|
||||
Fg: ColorAttr{colDefault, AttrUndefined},
|
||||
Bg: ColorAttr{colDefault, AttrUndefined},
|
||||
ListFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
AltBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedMatch: ColorAttr{colUndefined, AttrUndefined},
|
||||
Input: defaultColor,
|
||||
Fg: defaultColor,
|
||||
Bg: defaultColor,
|
||||
ListFg: undefined,
|
||||
ListBg: undefined,
|
||||
AltBg: undefined,
|
||||
SelectedFg: undefined,
|
||||
SelectedBg: undefined,
|
||||
SelectedMatch: undefined,
|
||||
DarkBg: ColorAttr{colGrey, AttrUndefined},
|
||||
Prompt: ColorAttr{colBlue, AttrUndefined},
|
||||
Match: ColorAttr{colGreen, AttrUndefined},
|
||||
@@ -942,43 +983,45 @@ func init() {
|
||||
Marker: ColorAttr{colMagenta, AttrUndefined},
|
||||
Header: ColorAttr{colCyan, AttrUndefined},
|
||||
Footer: ColorAttr{colCyan, AttrUndefined},
|
||||
Border: ColorAttr{colDefault, Dim},
|
||||
BorderLabel: ColorAttr{colDefault, AttrUndefined},
|
||||
Ghost: ColorAttr{colUndefined, Dim},
|
||||
Disabled: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
Separator: ColorAttr{colUndefined, AttrUndefined},
|
||||
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
GapLine: ColorAttr{colUndefined, AttrUndefined},
|
||||
Nth: ColorAttr{colUndefined, AttrUndefined},
|
||||
Border: undefined,
|
||||
BorderLabel: defaultColor,
|
||||
Ghost: undefined,
|
||||
Disabled: undefined,
|
||||
PreviewFg: undefined,
|
||||
PreviewBg: undefined,
|
||||
Gutter: undefined,
|
||||
PreviewBorder: undefined,
|
||||
PreviewScrollbar: undefined,
|
||||
PreviewLabel: undefined,
|
||||
ListLabel: undefined,
|
||||
ListBorder: undefined,
|
||||
Separator: undefined,
|
||||
Scrollbar: undefined,
|
||||
InputBg: undefined,
|
||||
InputBorder: undefined,
|
||||
InputLabel: undefined,
|
||||
HeaderBg: undefined,
|
||||
HeaderBorder: undefined,
|
||||
HeaderLabel: undefined,
|
||||
FooterBg: undefined,
|
||||
FooterBorder: undefined,
|
||||
FooterLabel: undefined,
|
||||
GapLine: undefined,
|
||||
Nth: undefined,
|
||||
Nomatch: undefined,
|
||||
}
|
||||
|
||||
Dark256 = &ColorTheme{
|
||||
Colored: true,
|
||||
Input: ColorAttr{colDefault, AttrUndefined},
|
||||
Fg: ColorAttr{colDefault, AttrUndefined},
|
||||
Bg: ColorAttr{colDefault, AttrUndefined},
|
||||
ListFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
AltBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedMatch: ColorAttr{colUndefined, AttrUndefined},
|
||||
Input: defaultColor,
|
||||
Fg: defaultColor,
|
||||
Bg: defaultColor,
|
||||
ListFg: undefined,
|
||||
ListBg: undefined,
|
||||
AltBg: undefined,
|
||||
SelectedFg: undefined,
|
||||
SelectedBg: undefined,
|
||||
SelectedMatch: undefined,
|
||||
DarkBg: ColorAttr{236, AttrUndefined},
|
||||
Prompt: ColorAttr{110, AttrUndefined},
|
||||
Match: ColorAttr{108, AttrUndefined},
|
||||
@@ -992,41 +1035,43 @@ func init() {
|
||||
Footer: ColorAttr{109, AttrUndefined},
|
||||
Border: ColorAttr{59, AttrUndefined},
|
||||
BorderLabel: ColorAttr{145, AttrUndefined},
|
||||
Ghost: ColorAttr{colUndefined, Dim},
|
||||
Disabled: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
Separator: ColorAttr{colUndefined, AttrUndefined},
|
||||
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
GapLine: ColorAttr{colUndefined, AttrUndefined},
|
||||
Nth: ColorAttr{colUndefined, AttrUndefined},
|
||||
Ghost: undefined,
|
||||
Disabled: undefined,
|
||||
PreviewFg: undefined,
|
||||
PreviewBg: undefined,
|
||||
Gutter: undefined,
|
||||
PreviewBorder: undefined,
|
||||
PreviewScrollbar: undefined,
|
||||
PreviewLabel: undefined,
|
||||
ListLabel: undefined,
|
||||
ListBorder: undefined,
|
||||
Separator: undefined,
|
||||
Scrollbar: undefined,
|
||||
InputBg: undefined,
|
||||
InputBorder: undefined,
|
||||
InputLabel: undefined,
|
||||
HeaderBg: undefined,
|
||||
HeaderBorder: undefined,
|
||||
HeaderLabel: undefined,
|
||||
FooterBg: undefined,
|
||||
FooterBorder: undefined,
|
||||
FooterLabel: undefined,
|
||||
GapLine: undefined,
|
||||
Nth: undefined,
|
||||
Nomatch: undefined,
|
||||
}
|
||||
|
||||
Light256 = &ColorTheme{
|
||||
Colored: true,
|
||||
Input: ColorAttr{colDefault, AttrUndefined},
|
||||
Fg: ColorAttr{colDefault, AttrUndefined},
|
||||
Bg: ColorAttr{colDefault, AttrUndefined},
|
||||
ListFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
AltBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
SelectedMatch: ColorAttr{colUndefined, AttrUndefined},
|
||||
Input: defaultColor,
|
||||
Fg: defaultColor,
|
||||
Bg: defaultColor,
|
||||
ListFg: undefined,
|
||||
ListBg: undefined,
|
||||
AltBg: undefined,
|
||||
SelectedFg: undefined,
|
||||
SelectedBg: undefined,
|
||||
SelectedMatch: undefined,
|
||||
DarkBg: ColorAttr{251, AttrUndefined},
|
||||
Prompt: ColorAttr{25, AttrUndefined},
|
||||
Match: ColorAttr{66, AttrUndefined},
|
||||
@@ -1040,37 +1085,54 @@ func init() {
|
||||
Footer: ColorAttr{31, AttrUndefined},
|
||||
Border: ColorAttr{145, AttrUndefined},
|
||||
BorderLabel: ColorAttr{59, AttrUndefined},
|
||||
Ghost: ColorAttr{colUndefined, Dim},
|
||||
Disabled: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
ListBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
Separator: ColorAttr{colUndefined, AttrUndefined},
|
||||
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
InputLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
HeaderLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterBg: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||
FooterLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||
GapLine: ColorAttr{colUndefined, AttrUndefined},
|
||||
Nth: ColorAttr{colUndefined, AttrUndefined},
|
||||
Ghost: undefined,
|
||||
Disabled: undefined,
|
||||
PreviewFg: undefined,
|
||||
PreviewBg: undefined,
|
||||
Gutter: undefined,
|
||||
PreviewBorder: undefined,
|
||||
PreviewScrollbar: undefined,
|
||||
PreviewLabel: undefined,
|
||||
ListLabel: undefined,
|
||||
ListBorder: undefined,
|
||||
Separator: undefined,
|
||||
Scrollbar: undefined,
|
||||
InputBg: undefined,
|
||||
InputBorder: undefined,
|
||||
InputLabel: undefined,
|
||||
HeaderBg: undefined,
|
||||
HeaderBorder: undefined,
|
||||
HeaderLabel: undefined,
|
||||
FooterBg: undefined,
|
||||
FooterBorder: undefined,
|
||||
FooterLabel: undefined,
|
||||
GapLine: undefined,
|
||||
Nth: undefined,
|
||||
Nomatch: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool, hasInputWindow bool, hasHeaderWindow bool) {
|
||||
func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, boldify bool, forceBlack bool, hasInputWindow bool, hasHeaderWindow bool) {
|
||||
if forceBlack {
|
||||
theme.Bg = ColorAttr{colBlack, AttrUndefined}
|
||||
}
|
||||
|
||||
if boldify {
|
||||
boldify := func(c ColorAttr) ColorAttr {
|
||||
dup := c
|
||||
if (c.Attr & AttrRegular) == 0 {
|
||||
dup.Attr |= BoldForce
|
||||
}
|
||||
return dup
|
||||
}
|
||||
theme.Current = boldify(theme.Current)
|
||||
theme.CurrentMatch = boldify(theme.CurrentMatch)
|
||||
theme.Prompt = boldify(theme.Prompt)
|
||||
theme.Input = boldify(theme.Input)
|
||||
theme.Cursor = boldify(theme.Cursor)
|
||||
theme.Spinner = boldify(theme.Spinner)
|
||||
}
|
||||
|
||||
o := func(a ColorAttr, b ColorAttr) ColorAttr {
|
||||
c := a
|
||||
if b.Color != colUndefined {
|
||||
@@ -1086,18 +1148,36 @@ func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool, hasInp
|
||||
theme.Bg = o(baseTheme.Bg, theme.Bg)
|
||||
theme.DarkBg = o(baseTheme.DarkBg, theme.DarkBg)
|
||||
theme.Prompt = o(baseTheme.Prompt, theme.Prompt)
|
||||
theme.Match = o(baseTheme.Match, theme.Match)
|
||||
match := theme.Match
|
||||
if !baseTheme.Colored && match.IsUndefined() {
|
||||
match.Attr = Underline
|
||||
}
|
||||
theme.Match = o(baseTheme.Match, match)
|
||||
// Inherit from 'fg', so that we don't have to write 'current-fg:dim'
|
||||
// e.g. fzf --delimiter / --nth -1 --color fg:dim,nth:regular
|
||||
theme.Current = theme.Fg.Merge(o(baseTheme.Current, theme.Current))
|
||||
theme.CurrentMatch = o(baseTheme.CurrentMatch, theme.CurrentMatch)
|
||||
current := theme.Current
|
||||
if !baseTheme.Colored && current.IsUndefined() {
|
||||
current.Attr = Reverse
|
||||
}
|
||||
theme.Current = theme.Fg.Merge(o(baseTheme.Current, current))
|
||||
currentMatch := theme.CurrentMatch
|
||||
if !baseTheme.Colored && currentMatch.IsUndefined() {
|
||||
currentMatch.Attr = Reverse | Underline
|
||||
}
|
||||
theme.CurrentMatch = o(baseTheme.CurrentMatch, currentMatch)
|
||||
theme.Spinner = o(baseTheme.Spinner, theme.Spinner)
|
||||
theme.Info = o(baseTheme.Info, theme.Info)
|
||||
theme.Cursor = o(baseTheme.Cursor, theme.Cursor)
|
||||
theme.Marker = o(baseTheme.Marker, theme.Marker)
|
||||
theme.Header = o(baseTheme.Header, theme.Header)
|
||||
theme.Footer = o(baseTheme.Footer, theme.Footer)
|
||||
theme.Border = o(baseTheme.Border, theme.Border)
|
||||
|
||||
// If border color is undefined, set it to default color with dim attribute.
|
||||
border := theme.Border
|
||||
if baseTheme.Border.IsUndefined() && border.IsUndefined() {
|
||||
border.Attr = Dim
|
||||
}
|
||||
theme.Border = o(baseTheme.Border, border)
|
||||
theme.BorderLabel = o(baseTheme.BorderLabel, theme.BorderLabel)
|
||||
|
||||
undefined := NewColorAttr()
|
||||
@@ -1110,9 +1190,23 @@ func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool, hasInp
|
||||
theme.SelectedFg = o(theme.ListFg, theme.SelectedFg)
|
||||
theme.SelectedBg = o(theme.ListBg, theme.SelectedBg)
|
||||
theme.SelectedMatch = o(theme.Match, theme.SelectedMatch)
|
||||
theme.Ghost = o(theme.Input, theme.Ghost)
|
||||
|
||||
ghost := theme.Ghost
|
||||
if ghost.IsUndefined() {
|
||||
ghost.Attr = Dim
|
||||
} else if ghost.IsColorDefined() && !ghost.IsAttrDefined() {
|
||||
// Don't want to inherit 'bold' from 'input'
|
||||
ghost.Attr = AttrRegular
|
||||
}
|
||||
theme.Ghost = o(theme.Input, ghost)
|
||||
theme.Disabled = o(theme.Input, theme.Disabled)
|
||||
theme.Gutter = o(theme.DarkBg, theme.Gutter)
|
||||
|
||||
// Use dim gutter on non-colored themes if undefined
|
||||
gutter := theme.Gutter
|
||||
if !baseTheme.Colored && gutter.IsUndefined() {
|
||||
gutter.Attr = Dim
|
||||
}
|
||||
theme.Gutter = o(theme.DarkBg, gutter)
|
||||
theme.PreviewFg = o(theme.Fg, theme.PreviewFg)
|
||||
theme.PreviewBg = o(theme.Bg, theme.PreviewBg)
|
||||
theme.PreviewLabel = o(theme.BorderLabel, theme.PreviewLabel)
|
||||
@@ -1154,6 +1248,10 @@ func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool, hasInp
|
||||
theme.FooterBorder = o(theme.Border, theme.FooterBorder)
|
||||
theme.FooterLabel = o(theme.BorderLabel, theme.FooterLabel)
|
||||
|
||||
if theme.Nomatch.IsUndefined() {
|
||||
theme.Nomatch.Attr = Dim
|
||||
}
|
||||
|
||||
initPalette(theme)
|
||||
}
|
||||
|
||||
|
||||
@@ -1682,6 +1682,7 @@ class TestCore < TestInteractive
|
||||
|
||||
tmux.send_keys %(seq 100 | #{FZF} --multi --reverse --preview-window 0 --preview 'env | grep ^FZF_ | sort > #{tempname}' --no-input --bind enter:show-input+refresh-preview,space:disable-search+refresh-preview), :Enter
|
||||
expected = {
|
||||
FZF_DIRECTION: 'down',
|
||||
FZF_TOTAL_COUNT: '100',
|
||||
FZF_MATCH_COUNT: '100',
|
||||
FZF_SELECT_COUNT: '0',
|
||||
|
||||
@@ -1192,6 +1192,29 @@ class TestLayout < TestInteractive
|
||||
tmux.until { assert_block(block, it) }
|
||||
end
|
||||
|
||||
# https://github.com/junegunn/fzf/issues/4537
|
||||
def test_no_scrollbar_preview_toggle
|
||||
x = 'x' * 300
|
||||
y = 'y' * 300
|
||||
tmux.send_keys %(yes #{x} | head -1000 | fzf --bind 'tab:toggle-preview' --border --no-scrollbar --preview 'echo #{y}' --preview-window 'border-left'), :Enter
|
||||
|
||||
# │ ▌ xxxxxxxx·· │ yyyyyyyy│
|
||||
tmux.until do |lines|
|
||||
lines.any? { it.match?(/x·· │ y+│$/) }
|
||||
end
|
||||
tmux.send_keys :Tab
|
||||
|
||||
# │ ▌ xxxxxxxx·· │
|
||||
tmux.until do |lines|
|
||||
lines.none? { it.match?(/x··y│$/) }
|
||||
end
|
||||
|
||||
tmux.send_keys :Tab
|
||||
tmux.until do |lines|
|
||||
lines.any? { it.match?(/x·· │ y+│$/) }
|
||||
end
|
||||
end
|
||||
|
||||
def test_combinations
|
||||
skip unless ENV['LONGTEST']
|
||||
|
||||
|
||||
113
test/test_raw.rb
Normal file
113
test/test_raw.rb
Normal file
@@ -0,0 +1,113 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'lib/common'
|
||||
|
||||
# Testing raw mode
|
||||
class TestRaw < TestInteractive
|
||||
def test_raw_mode
|
||||
tmux.send_keys %(seq 1000 | #{FZF} --raw --bind ctrl-x:toggle-raw,a:enable-raw,b:disable-raw --gutter '▌' --multi --bind 'space:transform-prompt:echo "[[$FZF_RAW]] "'), :Enter
|
||||
tmux.until { assert_equal 1000, it.match_count }
|
||||
|
||||
tmux.send_keys 1
|
||||
tmux.until { assert_equal 272, it.match_count }
|
||||
|
||||
tmux.send_keys :Up
|
||||
tmux.until { assert_includes it, '> 2' }
|
||||
|
||||
tmux.send_keys 'C-p'
|
||||
tmux.until do
|
||||
assert_includes it, '> 10'
|
||||
assert_includes it, '▖ 9'
|
||||
end
|
||||
|
||||
tmux.send_keys 'C-x'
|
||||
tmux.until do
|
||||
assert_includes it, '> 10'
|
||||
assert_includes it, '▌ 1'
|
||||
end
|
||||
|
||||
tmux.send_keys :Up, 'C-x'
|
||||
tmux.until do
|
||||
assert_includes it, '> 11'
|
||||
assert_includes it, '▖ 10'
|
||||
end
|
||||
|
||||
tmux.send_keys 1
|
||||
tmux.until { assert_equal 28, it.match_count }
|
||||
|
||||
tmux.send_keys 'C-p'
|
||||
tmux.until do
|
||||
assert_includes it, '> 101'
|
||||
assert_includes it, '▖ 100'
|
||||
end
|
||||
|
||||
tmux.send_keys 'C-n'
|
||||
tmux.until do
|
||||
assert_includes it, '> 11'
|
||||
assert_includes it, '▖ 10'
|
||||
end
|
||||
|
||||
tmux.send_keys :Tab, :Tab, :Tab
|
||||
tmux.until { assert_equal 3, it.select_count }
|
||||
|
||||
tmux.send_keys 'C-x'
|
||||
tmux.until do
|
||||
assert_equal 1, it.select_count
|
||||
assert_includes it, '▌ 110'
|
||||
assert_includes it, '>>11'
|
||||
end
|
||||
|
||||
tmux.send_keys 'a'
|
||||
tmux.until do
|
||||
assert_equal 1, it.select_count
|
||||
assert_includes it, '>>11'
|
||||
assert_includes it, '▖ 10'
|
||||
end
|
||||
|
||||
tmux.send_keys :Down, :Space
|
||||
tmux.until { assert_includes it, '[[0]] 11' }
|
||||
|
||||
tmux.send_keys :Up, :Space
|
||||
tmux.until { assert_includes it, '[[1]] 11' }
|
||||
|
||||
tmux.send_keys 'b'
|
||||
tmux.until do
|
||||
assert_equal 1, it.select_count
|
||||
assert_includes it, '▌ 110'
|
||||
assert_includes it, '>>11'
|
||||
end
|
||||
|
||||
tmux.send_keys :Space
|
||||
tmux.until { assert_includes it, '[[]] 11' }
|
||||
|
||||
tmux.send_keys 'C-u', '5'
|
||||
tmux.until { assert_includes it, '> 5' }
|
||||
|
||||
tmux.send_keys 'C-x', 'C-p', 'C-p'
|
||||
tmux.until do
|
||||
assert_includes it, '> 25'
|
||||
assert_includes it, '▖ 24'
|
||||
end
|
||||
|
||||
tmux.send_keys 'C-x'
|
||||
tmux.until do
|
||||
assert_includes it, '> 25'
|
||||
assert_includes it, '▌ 15'
|
||||
end
|
||||
|
||||
# 35 is the closest match in raw mode
|
||||
tmux.send_keys 'C-x', :Up, :Up, :Up, :Up, :Up, :Up, 'C-x'
|
||||
tmux.until do
|
||||
assert_includes it, '> 35'
|
||||
assert_includes it, '▌ 25'
|
||||
end
|
||||
end
|
||||
|
||||
def test_raw_best
|
||||
tmux.send_keys %(seq 1000 | #{FZF} --raw --bind space:best), :Enter
|
||||
tmux.send_keys 999
|
||||
tmux.until { assert_includes it, '> 1' }
|
||||
tmux.send_keys :Space
|
||||
tmux.until { assert_includes it, '> 999' }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user