m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-15 23:03:47 -05:00

Compare commits

...

28 Commits

Author SHA1 Message Date
Junegunn Choi
e15cba0c8c 0.61.0 2025-03-30 19:51:28 +09:00
Junegunn Choi
31fd207ba2 Add 'r' flag (raw) for unquoted output
By default, placeholder expressions are automatically quoted to ensure
they are safely passed as arguments to external programs.

The r flag ({r}, {r1}, etc.) disables this behavior, outputting the
evaluated value without quotes.

For example,

  echo 'foo   bar' | fzf --preview 'echo {} {r}'

The preview command becomes:

  echo 'foo   bar' foo   bar

Since `{r}` expands to unquoted "foo   bar", 'foo' and 'bar' are passed
as separate arguments.

**Use with caution** Unquoted output can lead to broken commands.

  echo "let's go" | fzf --preview 'echo {r}'

Close #4330
2025-03-30 19:49:05 +09:00
Junegunn Choi
ba6d1b8772 Add change-ghost and transform-ghost 2025-03-28 23:35:20 +09:00
Junegunn Choi
0dce561ec9 Fix header window not updated on change-header 2025-03-28 23:23:43 +09:00
dependabot[bot]
376142eb0d Bump github.com/charlievieth/fastwalk from 1.0.9 to 1.0.10 (#4307)
Bumps [github.com/charlievieth/fastwalk](https://github.com/charlievieth/fastwalk) from 1.0.9 to 1.0.10.
- [Release notes](https://github.com/charlievieth/fastwalk/releases)
- [Commits](https://github.com/charlievieth/fastwalk/compare/v1.0.9...v1.0.10)

---
updated-dependencies:
- dependency-name: github.com/charlievieth/fastwalk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-28 23:05:34 +09:00
Junegunn Choi
664ee1f483 Add change-pointer and transform-pointer
Close #4178
2025-03-28 21:28:25 +09:00
Junegunn Choi
dac5b6fde1 Fix info not updated after track-current is disabled due to race condition 2025-03-26 16:00:05 +09:00
Junegunn Choi
998c57442b Fix query precedence in an action chain (#4326)
When 'search' and any action that modifies the query are in an action
chain, anything that comes later takes precedence.
2025-03-26 15:47:43 +09:00
Junegunn Choi
4a0ab6c926 Improve query modification prevention in input-less mode
fzf would restore the original query in input-less mode after executing
a chain of actions.

This commit changes the behavior so that the restoration
happens after each action to allow something like
'show-input+change-query(...)+hide-input'.

Fix #4326
2025-03-26 10:34:52 +09:00
Junegunn Choi
f43e82f17f Do not ignore current query when input is hidden
* The initial query given by --query should be respected
* The current query should still be respected after `hide-input`
  (or `toggle-input)

Fix #4327
2025-03-25 21:08:06 +09:00
Junegunn Choi
62238620a5 Fix first entry not clickable when input section is hidden
Fix #4325
2025-03-24 22:08:57 +09:00
Junegunn Choi
200745011a Fix cursor position when prompt is truncated
e.g.
    fzf --preview 'cat {}' --prompt "$(seq 100 | xargs)"
    fzf --preview 'cat {}' --prompt "$(seq 100 | xargs)" --input-border
2025-03-24 17:09:44 +09:00
Junegunn Choi
82fd88339b Fix offset-middle not updating the list 2025-03-23 11:13:21 +09:00
junegunn
de0f2efbfb Deploying to master from @ junegunn/fzf@29cf28d845 🚀 2025-03-23 00:02:20 +00:00
Junegunn Choi
29cf28d845 Suppress 'change' event during bracketed paste mode
Close #4316
2025-03-22 09:17:18 +09:00
Junegunn Choi
7e4dbb5f3b Prevent start:track-current from being disabled
# track-current state can be immediately disabled
  fzf --sync --bind 'start:track-current'
2025-03-20 11:51:20 +09:00
Junegunn Choi
923c3a814d [bash] Fix $FZF_COMPLETION_{DIR,PATH}_OPTS to support non-trivial arguments
This used to fail with 'unknown option: World>'

  export FZF_COMPLETION_PATH_OPTS="--prompt 'Hello World> '"
2025-03-17 18:12:26 +09:00
Junegunn Choi
779e3cc5b5 [vim] Use 24-bit colors on gvim even when &termguicolors is off
Close #2563
2025-03-17 17:46:56 +09:00
junegunn
3f3d1ef8f5 Deploying to master from @ junegunn/fzf@f92f9f137a 🚀 2025-03-16 00:02:19 +00:00
Junegunn Choi
f92f9f137a Fix wrapping of the list section
# The first line of the second chunk would prematurely wrap
  printf '%0500s\n\n%0500s' 0 0 | fzf --wrap --read0
2025-03-16 01:57:20 +09:00
Junegunn Choi
87f7f436e8 Fix ghost text with inline info
Fix #4312
2025-03-15 18:42:08 +09:00
Junegunn Choi
4298c0b1eb Add --ghost=TEXT to display a ghost text when the input is empty 2025-03-14 16:46:23 +09:00
Gabriel Marin
6c104d771e Change 'interface{}' to 'any' (#4308) 2025-03-11 14:24:54 +09:00
Junegunn Choi
aefb9a5bc4 Nullify unwanted FZF_DEFAULT_* variables in tmux popup
Fix #4298
2025-03-10 18:18:50 +09:00
Junegunn Choi
8868d7cbb8 Add .idea to .gitignore 2025-03-10 18:15:53 +09:00
junegunn
10cbac20f9 Deploying to master from @ junegunn/fzf@26bcd0c90d 🚀 2025-03-09 00:01:51 +00:00
Junegunn Choi
26bcd0c90d README: Sponsors ❤️ 2025-03-04 18:30:50 +09:00
Junegunn Choi
fbece2bb67 Update README 2025-03-04 17:43:02 +09:00
26 changed files with 498 additions and 234 deletions

1
.gitignore vendored
View File

@@ -11,3 +11,4 @@ gopath
fzf
tmp
*.patch
.idea

View File

@@ -1,6 +1,18 @@
CHANGELOG
=========
0.61.0
------
- Added `--ghost=TEXT` to display a ghost text when the input is empty
```sh
# Display "Type to search" when the input is empty
fzf --ghost "Type to search"
```
- Added `change-ghost` and `transform-ghost` actions for dynamically changing the ghost text
- Added `change-pointer` and `transform-pointer` actions for dynamically changing the pointer sign
- Added `r` flag for placeholder expression (raw mode) for unquoted output
- Bug fixes and improvements
0.60.3
------
- Bug fixes and improvements

File diff suppressed because one or more lines are too long

2
go.mod
View File

@@ -1,7 +1,7 @@
module github.com/junegunn/fzf
require (
github.com/charlievieth/fastwalk v1.0.9
github.com/charlievieth/fastwalk v1.0.10
github.com/gdamore/tcell/v2 v2.8.1
github.com/junegunn/go-shellwords v0.0.0-20250127100254-2aa3b3277741
github.com/mattn/go-isatty v0.0.20

4
go.sum
View File

@@ -1,5 +1,5 @@
github.com/charlievieth/fastwalk v1.0.9 h1:Odb92AfoReO3oFBfDGT5J+nwgzQPF/gWAw6E6/lkor0=
github.com/charlievieth/fastwalk v1.0.9/go.mod h1:yGy1zbxog41ZVMcKA/i8ojXLFsuayX5VvwhQVoj9PBI=
github.com/charlievieth/fastwalk v1.0.10 h1:0qUbvA2O+K+X+IrTfZTC0UH2DK5MOA+KjVfStAHUnGg=
github.com/charlievieth/fastwalk v1.0.10/go.mod h1:yGy1zbxog41ZVMcKA/i8ojXLFsuayX5VvwhQVoj9PBI=
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
github.com/gdamore/tcell/v2 v2.8.1 h1:KPNxyqclpWpWQlPLx6Xui1pMk8S+7+R37h3g07997NU=

View File

@@ -2,7 +2,7 @@
set -u
version=0.60.3
version=0.61.0
auto_completion=
key_bindings=
update_config=2

View File

@@ -1,4 +1,4 @@
$version="0.60.3"
$version="0.61.0"
$fzf_base=Split-Path -Parent $MyInvocation.MyCommand.Definition

View File

@@ -11,7 +11,7 @@ import (
"github.com/junegunn/fzf/src/protector"
)
var version = "0.60"
var version = "0.61"
var revision = "devel"
//go:embed shell/key-bindings.bash

View File

@@ -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 "Mar 2025" "fzf 0.60.3" "fzf\-tmux - open fzf in tmux split pane"
.TH fzf\-tmux 1 "Mar 2025" "fzf 0.61.0" "fzf\-tmux - open fzf in tmux split pane"
.SH NAME
fzf\-tmux - open fzf in tmux split pane

View File

@@ -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 "Mar 2025" "fzf 0.60.3" "fzf - a command-line fuzzy finder"
.TH fzf 1 "Mar 2025" "fzf 0.61.0" "fzf - a command-line fuzzy finder"
.SH NAME
fzf - a command-line fuzzy finder
@@ -709,6 +709,10 @@ ANSI color codes are supported.
Do not display horizontal separator on the info line. A synonym for
\fB\-\-separator=''\fB
.TP
.BI "\-\-ghost=" "TEXT"
Ghost text to display when the input is empty
.TP
.B "\-\-filepath\-word"
Make word-wise movements and actions respect path separators. The following
@@ -764,6 +768,12 @@ e.g.
\fBfzf \-\-multi \-\-preview='head \-10 {+}'
git log \-\-oneline | fzf \-\-multi \-\-preview 'git show {+1}'\fR
Each expression expands to a quoted string, so that it's safe to pass it as an
argument to an external command. So you should not manually add quotes around
the curly braces. But if you don't want this behavior, you can put
\fBr\fR flag (raw) in the expression (e.g. \fB{r}\fR, \fB{r1}\fR, etc).
Use it with caution as unquoted output can lead to broken commands.
When using a field index expression, leading and trailing whitespace is stripped
from the replacement string. To preserve the whitespace, use the \fBs\fR flag.
@@ -1605,6 +1615,7 @@ A key or an event can be bound to one or more of the following actions.
\fBbell\fR (ring the terminal bell)
\fBcancel\fR (clear query string if not empty, abort fzf otherwise)
\fBchange\-border\-label(...)\fR (change \fB\-\-border\-label\fR to the given string)
\fBchange\-ghost(...)\fR (change ghost text to the given string)
\fBchange\-header(...)\fR (change header to the given string; doesn't affect \fB\-\-header\-lines\fR)
\fBchange\-header\-label(...)\fR (change \fB\-\-header\-label\fR to the given string)
\fBchange\-input\-label(...)\fR (change \fB\-\-input\-label\fR to the given string)
@@ -1612,6 +1623,7 @@ A key or an event can be bound to one or more of the following actions.
\fBchange\-multi\fR (enable multi-select mode with no limit)
\fBchange\-multi(...)\fR (enable multi-select mode with a limit or disable it with 0)
\fBchange\-nth(...)\fR (change \fB\-\-nth\fR option; rotate through the multiple options separated by '|')
\fBchange\-pointer(...)\fR (change \fB\-\-pointer\fR option)
\fBchange\-preview(...)\fR (change \fB\-\-preview\fR option)
\fBchange\-preview\-label(...)\fR (change \fB\-\-preview\-label\fR to the given string)
\fBchange\-preview\-window(...)\fR (change \fB\-\-preview\-window\fR option; rotate through the multiple option sets separated by '|')
@@ -1700,11 +1712,13 @@ A key or an event can be bound to one or more of the following actions.
\fBtrack\-current\fR (track the current item; automatically disabled if focus changes)
\fBtransform(...)\fR (transform states using the output of an external command)
\fBtransform\-border\-label(...)\fR (transform border label using an external command)
\fBtransform\-ghost(...)\fR (transform ghost text using an external command)
\fBtransform\-header(...)\fR (transform header using an external command)
\fBtransform\-header\-label(...)\fR (transform header label using an external command)
\fBtransform\-input\-label(...)\fR (transform input label using an external command)
\fBtransform\-list\-label(...)\fR (transform list label using an external command)
\fBtransform\-nth(...)\fR (transform nth using an external command)
\fBtransform\-pointer(...)\fR (transform pointer using an external command)
\fBtransform\-preview\-label(...)\fR (transform preview label using an external command)
\fBtransform\-prompt(...)\fR (transform prompt string using an external command)
\fBtransform\-query(...)\fR (transform query string using an external command)

View File

@@ -358,7 +358,7 @@ endfunction
function! s:get_color(attr, ...)
" Force 24 bit colors: g:fzf_force_termguicolors (temporary workaround for https://github.com/junegunn/fzf.vim/issues/1152)
let gui = get(g:, 'fzf_force_termguicolors', 0) || (!s:is_win && !has('win32unix') && has('termguicolors') && &termguicolors)
let gui = get(g:, 'fzf_force_termguicolors', 0) || (!s:is_win && !has('win32unix') && (has('gui_running') || has('termguicolors') && &termguicolors))
let fam = gui ? 'gui' : 'cterm'
let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
for group in a:000

View File

@@ -311,12 +311,12 @@ __fzf_generic_path_completion() {
else
if [[ $1 =~ dir ]]; then
walker=dir,follow
rest=${FZF_COMPLETION_DIR_OPTS-}
eval "rest=(${FZF_COMPLETION_DIR_OPTS-})"
else
walker=file,dir,follow,hidden
rest=${FZF_COMPLETION_PATH_OPTS-}
eval "rest=(${FZF_COMPLETION_PATH_OPTS-})"
fi
__fzf_comprun "$4" -q "$leftover" --walker "$walker" --walker-root="$dir" $rest
__fzf_comprun "$4" -q "$leftover" --walker "$walker" --walker-root="$dir" "${rest[@]}"
fi | while read -r item; do
printf "%q " "${item%$3}$3"
done

View File

@@ -12,139 +12,145 @@ func _() {
_ = x[actStart-1]
_ = x[actClick-2]
_ = x[actInvalid-3]
_ = x[actChar-4]
_ = x[actMouse-5]
_ = x[actBeginningOfLine-6]
_ = x[actAbort-7]
_ = x[actAccept-8]
_ = x[actAcceptNonEmpty-9]
_ = x[actAcceptOrPrintQuery-10]
_ = x[actBackwardChar-11]
_ = x[actBackwardDeleteChar-12]
_ = x[actBackwardDeleteCharEof-13]
_ = x[actBackwardWord-14]
_ = x[actCancel-15]
_ = x[actChangeBorderLabel-16]
_ = x[actChangeListLabel-17]
_ = x[actChangeInputLabel-18]
_ = x[actChangeHeader-19]
_ = x[actChangeHeaderLabel-20]
_ = x[actChangeMulti-21]
_ = x[actChangePreviewLabel-22]
_ = x[actChangePrompt-23]
_ = x[actChangeQuery-24]
_ = x[actBracketedPasteBegin-4]
_ = x[actBracketedPasteEnd-5]
_ = x[actChar-6]
_ = x[actMouse-7]
_ = x[actBeginningOfLine-8]
_ = x[actAbort-9]
_ = x[actAccept-10]
_ = x[actAcceptNonEmpty-11]
_ = x[actAcceptOrPrintQuery-12]
_ = x[actBackwardChar-13]
_ = x[actBackwardDeleteChar-14]
_ = x[actBackwardDeleteCharEof-15]
_ = x[actBackwardWord-16]
_ = x[actCancel-17]
_ = x[actChangeBorderLabel-18]
_ = x[actChangeGhost-19]
_ = x[actChangeHeader-20]
_ = x[actChangeHeaderLabel-21]
_ = x[actChangeInputLabel-22]
_ = x[actChangeListLabel-23]
_ = x[actChangeMulti-24]
_ = x[actChangeNth-25]
_ = x[actClearScreen-26]
_ = x[actClearQuery-27]
_ = x[actClearSelection-28]
_ = x[actClose-29]
_ = x[actDeleteChar-30]
_ = x[actDeleteCharEof-31]
_ = x[actEndOfLine-32]
_ = x[actFatal-33]
_ = x[actForwardChar-34]
_ = x[actForwardWord-35]
_ = x[actKillLine-36]
_ = x[actKillWord-37]
_ = x[actUnixLineDiscard-38]
_ = x[actUnixWordRubout-39]
_ = x[actYank-40]
_ = x[actBackwardKillWord-41]
_ = x[actSelectAll-42]
_ = x[actDeselectAll-43]
_ = x[actToggle-44]
_ = x[actToggleSearch-45]
_ = x[actToggleAll-46]
_ = x[actToggleDown-47]
_ = x[actToggleUp-48]
_ = x[actToggleIn-49]
_ = x[actToggleOut-50]
_ = x[actToggleTrack-51]
_ = x[actToggleTrackCurrent-52]
_ = x[actToggleHeader-53]
_ = x[actToggleWrap-54]
_ = x[actToggleMultiLine-55]
_ = x[actToggleHscroll-56]
_ = x[actTrackCurrent-57]
_ = x[actToggleInput-58]
_ = x[actHideInput-59]
_ = x[actShowInput-60]
_ = x[actUntrackCurrent-61]
_ = x[actDown-62]
_ = x[actUp-63]
_ = x[actPageUp-64]
_ = x[actPageDown-65]
_ = x[actPosition-66]
_ = x[actHalfPageUp-67]
_ = x[actHalfPageDown-68]
_ = x[actOffsetUp-69]
_ = x[actOffsetDown-70]
_ = x[actOffsetMiddle-71]
_ = x[actJump-72]
_ = x[actJumpAccept-73]
_ = x[actPrintQuery-74]
_ = x[actRefreshPreview-75]
_ = x[actReplaceQuery-76]
_ = x[actToggleSort-77]
_ = x[actShowPreview-78]
_ = x[actHidePreview-79]
_ = x[actTogglePreview-80]
_ = x[actTogglePreviewWrap-81]
_ = x[actTransform-82]
_ = x[actTransformBorderLabel-83]
_ = x[actTransformListLabel-84]
_ = x[actTransformInputLabel-85]
_ = x[actTransformHeader-86]
_ = x[actTransformHeaderLabel-87]
_ = x[actTransformNth-88]
_ = x[actTransformPreviewLabel-89]
_ = x[actTransformPrompt-90]
_ = x[actTransformQuery-91]
_ = x[actTransformSearch-92]
_ = x[actSearch-93]
_ = x[actPreview-94]
_ = x[actChangePreview-95]
_ = x[actChangePreviewWindow-96]
_ = x[actPreviewTop-97]
_ = x[actPreviewBottom-98]
_ = x[actPreviewUp-99]
_ = x[actPreviewDown-100]
_ = x[actPreviewPageUp-101]
_ = x[actPreviewPageDown-102]
_ = x[actPreviewHalfPageUp-103]
_ = x[actPreviewHalfPageDown-104]
_ = x[actPrevHistory-105]
_ = x[actPrevSelected-106]
_ = x[actPrint-107]
_ = x[actPut-108]
_ = x[actNextHistory-109]
_ = x[actNextSelected-110]
_ = x[actExecute-111]
_ = x[actExecuteSilent-112]
_ = x[actExecuteMulti-113]
_ = x[actSigStop-114]
_ = x[actFirst-115]
_ = x[actLast-116]
_ = x[actReload-117]
_ = x[actReloadSync-118]
_ = x[actDisableSearch-119]
_ = x[actEnableSearch-120]
_ = x[actSelect-121]
_ = x[actDeselect-122]
_ = x[actUnbind-123]
_ = x[actRebind-124]
_ = x[actToggleBind-125]
_ = x[actBecome-126]
_ = x[actShowHeader-127]
_ = x[actHideHeader-128]
_ = x[actBell-129]
_ = x[actExclude-130]
_ = x[actExcludeMulti-131]
_ = x[actChangePointer-26]
_ = x[actChangePreview-27]
_ = x[actChangePreviewLabel-28]
_ = x[actChangePreviewWindow-29]
_ = x[actChangePrompt-30]
_ = x[actChangeQuery-31]
_ = x[actClearScreen-32]
_ = x[actClearQuery-33]
_ = x[actClearSelection-34]
_ = x[actClose-35]
_ = x[actDeleteChar-36]
_ = x[actDeleteCharEof-37]
_ = x[actEndOfLine-38]
_ = x[actFatal-39]
_ = x[actForwardChar-40]
_ = x[actForwardWord-41]
_ = x[actKillLine-42]
_ = x[actKillWord-43]
_ = x[actUnixLineDiscard-44]
_ = x[actUnixWordRubout-45]
_ = x[actYank-46]
_ = x[actBackwardKillWord-47]
_ = x[actSelectAll-48]
_ = x[actDeselectAll-49]
_ = x[actToggle-50]
_ = x[actToggleSearch-51]
_ = x[actToggleAll-52]
_ = x[actToggleDown-53]
_ = x[actToggleUp-54]
_ = x[actToggleIn-55]
_ = x[actToggleOut-56]
_ = x[actToggleTrack-57]
_ = x[actToggleTrackCurrent-58]
_ = x[actToggleHeader-59]
_ = x[actToggleWrap-60]
_ = x[actToggleMultiLine-61]
_ = x[actToggleHscroll-62]
_ = x[actTrackCurrent-63]
_ = x[actToggleInput-64]
_ = x[actHideInput-65]
_ = x[actShowInput-66]
_ = x[actUntrackCurrent-67]
_ = x[actDown-68]
_ = x[actUp-69]
_ = x[actPageUp-70]
_ = x[actPageDown-71]
_ = x[actPosition-72]
_ = x[actHalfPageUp-73]
_ = x[actHalfPageDown-74]
_ = x[actOffsetUp-75]
_ = x[actOffsetDown-76]
_ = x[actOffsetMiddle-77]
_ = x[actJump-78]
_ = x[actJumpAccept-79]
_ = x[actPrintQuery-80]
_ = x[actRefreshPreview-81]
_ = x[actReplaceQuery-82]
_ = x[actToggleSort-83]
_ = x[actShowPreview-84]
_ = x[actHidePreview-85]
_ = x[actTogglePreview-86]
_ = x[actTogglePreviewWrap-87]
_ = x[actTransform-88]
_ = x[actTransformBorderLabel-89]
_ = x[actTransformGhost-90]
_ = x[actTransformHeader-91]
_ = x[actTransformHeaderLabel-92]
_ = x[actTransformInputLabel-93]
_ = x[actTransformListLabel-94]
_ = x[actTransformNth-95]
_ = x[actTransformPointer-96]
_ = x[actTransformPreviewLabel-97]
_ = x[actTransformPrompt-98]
_ = x[actTransformQuery-99]
_ = x[actTransformSearch-100]
_ = x[actSearch-101]
_ = x[actPreview-102]
_ = x[actPreviewTop-103]
_ = x[actPreviewBottom-104]
_ = x[actPreviewUp-105]
_ = x[actPreviewDown-106]
_ = x[actPreviewPageUp-107]
_ = x[actPreviewPageDown-108]
_ = x[actPreviewHalfPageUp-109]
_ = x[actPreviewHalfPageDown-110]
_ = x[actPrevHistory-111]
_ = x[actPrevSelected-112]
_ = x[actPrint-113]
_ = x[actPut-114]
_ = x[actNextHistory-115]
_ = x[actNextSelected-116]
_ = x[actExecute-117]
_ = x[actExecuteSilent-118]
_ = x[actExecuteMulti-119]
_ = x[actSigStop-120]
_ = x[actFirst-121]
_ = x[actLast-122]
_ = x[actReload-123]
_ = x[actReloadSync-124]
_ = x[actDisableSearch-125]
_ = x[actEnableSearch-126]
_ = x[actSelect-127]
_ = x[actDeselect-128]
_ = x[actUnbind-129]
_ = x[actRebind-130]
_ = x[actToggleBind-131]
_ = x[actBecome-132]
_ = x[actShowHeader-133]
_ = x[actHideHeader-134]
_ = x[actBell-135]
_ = x[actExclude-136]
_ = x[actExcludeMulti-137]
}
const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeListLabelactChangeInputLabelactChangeHeaderactChangeHeaderLabelactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactChangeNthactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactToggleHscrollactTrackCurrentactToggleInputactHideInputactShowInputactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformListLabelactTransformInputLabelactTransformHeaderactTransformHeaderLabelactTransformNthactTransformPreviewLabelactTransformPromptactTransformQueryactTransformSearchactSearchactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactToggleBindactBecomeactShowHeaderactHideHeaderactBellactExcludeactExcludeMulti"
const _actionType_name = "actIgnoreactStartactClickactInvalidactBracketedPasteBeginactBracketedPasteEndactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeGhostactChangeHeaderactChangeHeaderLabelactChangeInputLabelactChangeListLabelactChangeMultiactChangeNthactChangePointeractChangePreviewactChangePreviewLabelactChangePreviewWindowactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactToggleHscrollactTrackCurrentactToggleInputactHideInputactShowInputactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformGhostactTransformHeaderactTransformHeaderLabelactTransformInputLabelactTransformListLabelactTransformNthactTransformPointeractTransformPreviewLabelactTransformPromptactTransformQueryactTransformSearchactSearchactPreviewactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactToggleBindactBecomeactShowHeaderactHideHeaderactBellactExcludeactExcludeMulti"
var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 42, 50, 68, 76, 85, 102, 123, 138, 159, 183, 198, 207, 227, 245, 264, 279, 299, 313, 334, 349, 363, 375, 389, 402, 419, 427, 440, 456, 468, 476, 490, 504, 515, 526, 544, 561, 568, 587, 599, 613, 622, 637, 649, 662, 673, 684, 696, 710, 731, 746, 759, 777, 793, 808, 822, 834, 846, 863, 870, 875, 884, 895, 906, 919, 934, 945, 958, 973, 980, 993, 1006, 1023, 1038, 1051, 1065, 1079, 1095, 1115, 1127, 1150, 1171, 1193, 1211, 1234, 1249, 1273, 1291, 1308, 1326, 1335, 1345, 1361, 1383, 1396, 1412, 1424, 1438, 1454, 1472, 1492, 1514, 1528, 1543, 1551, 1557, 1571, 1586, 1596, 1612, 1627, 1637, 1645, 1652, 1661, 1674, 1690, 1705, 1714, 1725, 1734, 1743, 1756, 1765, 1778, 1791, 1798, 1808, 1823}
var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 57, 77, 84, 92, 110, 118, 127, 144, 165, 180, 201, 225, 240, 249, 269, 283, 298, 318, 337, 355, 369, 381, 397, 413, 434, 456, 471, 485, 499, 512, 529, 537, 550, 566, 578, 586, 600, 614, 625, 636, 654, 671, 678, 697, 709, 723, 732, 747, 759, 772, 783, 794, 806, 820, 841, 856, 869, 887, 903, 918, 932, 944, 956, 973, 980, 985, 994, 1005, 1016, 1029, 1044, 1055, 1068, 1083, 1090, 1103, 1116, 1133, 1148, 1161, 1175, 1189, 1205, 1225, 1237, 1260, 1277, 1295, 1318, 1340, 1361, 1376, 1395, 1419, 1437, 1454, 1472, 1481, 1491, 1504, 1520, 1532, 1546, 1562, 1580, 1600, 1622, 1636, 1651, 1659, 1665, 1679, 1694, 1704, 1720, 1735, 1745, 1753, 1760, 1769, 1782, 1798, 1813, 1822, 1833, 1842, 1851, 1864, 1873, 1886, 1899, 1906, 1916, 1931}
func (i actionType) String() string {
if i < 0 || i >= actionType(len(_actionType_index)-1) {

View File

@@ -136,6 +136,7 @@ Usage: fzf [options]
--separator=STR Draw horizontal separator on info line using the string
(default: '─' or '-')
--no-separator Hide info line separator
--ghost=TEXT Ghost text to display when the input is empty
--filepath-word Make word-wise movements respect path separators
--input-border[=STYLE] Draw border around the input section
[rounded|sharp|bold|block|thinblock|double|horizontal|vertical|
@@ -574,6 +575,7 @@ type Options struct {
InfoStyle infoStyle
InfoPrefix string
InfoCommand string
Ghost string
Separator *string
JumpLabels string
Prompt string
@@ -689,6 +691,7 @@ func defaultOptions() *Options {
ScrollOff: 3,
FileWord: false,
InfoStyle: infoDefault,
Ghost: "",
Separator: nil,
JumpLabels: defaultJumpLabels,
Prompt: "> ",
@@ -1401,7 +1404,7 @@ const (
func init() {
executeRegexp = regexp.MustCompile(
`(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform)-(?:query|prompt|(?:border|list|preview|input|header)-label|header|search|nth)|transform|change-(?:preview-window|preview|multi)|(?:re|un|toggle-)bind|pos|put|print|search)`)
`(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform)-(?:query|prompt|(?:border|list|preview|input|header)-label|header|search|nth|pointer|ghost)|transform|change-(?:preview-window|preview|multi)|(?:re|un|toggle-)bind|pos|put|print|search)`)
splitRegexp = regexp.MustCompile("[,:]+")
actionNameRegexp = regexp.MustCompile("(?i)^[a-z-]+")
}
@@ -1796,6 +1799,10 @@ func isExecuteAction(str string) actionType {
return actChangeInputLabel
case "change-header-label":
return actChangeHeaderLabel
case "change-ghost":
return actChangeGhost
case "change-pointer":
return actChangePointer
case "change-preview-window":
return actChangePreviewWindow
case "change-preview":
@@ -1834,8 +1841,12 @@ func isExecuteAction(str string) actionType {
return actTransformHeaderLabel
case "transform-header":
return actTransformHeader
case "transform-ghost":
return actTransformGhost
case "transform-nth":
return actTransformNth
case "transform-pointer":
return actTransformPointer
case "transform-prompt":
return actTransformPrompt
case "transform-query":
@@ -2597,6 +2608,10 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
case "--no-separator":
nosep := ""
opts.Separator = &nosep
case "--ghost":
if opts.Ghost, err = nextString("ghost text required"); err != nil {
return err
}
case "--scrollbar":
given, bar := optionalNextString()
if given {

View File

@@ -90,9 +90,9 @@ func runProxy(commandPrefix string, cmdBuilder func(temp string, needBash bool)
}
}
// To ensure that the options are processed by a POSIX-compliant shell,
// we need to write the command to a temporary file and execute it with sh.
var exports []string
// * Write the command to a temporary file and run it with sh to ensure POSIX compliance.
// * Nullify FZF_DEFAULT_* variables as tmux popup may inject them even when undefined.
exports := []string{"FZF_DEFAULT_COMMAND=", "FZF_DEFAULT_OPTS=", "FZF_DEFAULT_OPTS_FILE="}
needBash := false
if withExports {
validIdentifier := regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_]*$`)

View File

@@ -38,7 +38,7 @@ As such it is not useful for validation, but rather to generate test
cases for example.
\\?(?: # escaped type
{\+?s?f?RANGE(?:,RANGE)*} # token type
{\+?s?f?r?RANGE(?:,RANGE)*} # token type
{q[:s?RANGE]} # query type
|{\+?n?f?} # item type (notice no mandatory element inside brackets)
)
@@ -65,7 +65,7 @@ const maxFocusEvents = 10000
const blockDuration = 1 * time.Second
func init() {
placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q(?::s?[0-9,-.]+)?}|{fzf:(?:query|action|prompt)}|{\+?f?nf?})`)
placeholder = regexp.MustCompile(`\\?(?:{[+sfr]*[0-9,-.]*}|{q(?::s?[0-9,-.]+)?}|{fzf:(?:query|action|prompt)}|{\+?f?nf?})`)
whiteSuffix = regexp.MustCompile(`\s*$`)
offsetComponentRegex = regexp.MustCompile(`([+-][0-9]+)|(-?/[1-9][0-9]*)`)
offsetTrimCharsRegex = regexp.MustCompile(`[^0-9/+-]`)
@@ -234,6 +234,7 @@ type Terminal struct {
wrap bool
wrapSign string
wrapSignWidth int
ghost string
separator labelPrinter
separatorLen int
spinner []string
@@ -278,6 +279,7 @@ type Terminal struct {
yanked []rune
input []rune
inputOverride *[]rune
pasting *[]rune
multi int
multiLine bool
sort bool
@@ -458,6 +460,8 @@ const (
actStart
actClick
actInvalid
actBracketedPasteBegin
actBracketedPasteEnd
actChar
actMouse
actBeginningOfLine
@@ -471,15 +475,19 @@ const (
actBackwardWord
actCancel
actChangeBorderLabel
actChangeListLabel
actChangeInputLabel
actChangeGhost
actChangeHeader
actChangeHeaderLabel
actChangeInputLabel
actChangeListLabel
actChangeMulti
actChangeNth
actChangePointer
actChangePreview
actChangePreviewLabel
actChangePreviewWindow
actChangePrompt
actChangeQuery
actChangeNth
actClearScreen
actClearQuery
actClearSelection
@@ -538,19 +546,19 @@ const (
actTogglePreviewWrap
actTransform
actTransformBorderLabel
actTransformListLabel
actTransformInputLabel
actTransformGhost
actTransformHeader
actTransformHeaderLabel
actTransformInputLabel
actTransformListLabel
actTransformNth
actTransformPointer
actTransformPreviewLabel
actTransformPrompt
actTransformQuery
actTransformSearch
actSearch
actPreview
actChangePreview
actChangePreviewWindow
actPreviewTop
actPreviewBottom
actPreviewUp
@@ -620,6 +628,7 @@ type placeholderFlags struct {
number bool
forceUpdate bool
file bool
raw bool
}
type searchRequest struct {
@@ -667,6 +676,8 @@ func defaultKeymap() map[tui.Event][]*action {
add(tui.Fatal, actFatal)
add(tui.Invalid, actInvalid)
add(tui.BracketedPasteBegin, actBracketedPasteBegin)
add(tui.BracketedPasteEnd, actBracketedPasteEnd)
add(tui.CtrlA, actBeginningOfLine)
add(tui.CtrlB, actBackwardChar)
add(tui.CtrlC, actAbort)
@@ -847,6 +858,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
infoCommand: opts.InfoCommand,
infoStyle: opts.InfoStyle,
infoPrefix: opts.InfoPrefix,
ghost: opts.Ghost,
separator: nil,
spinner: makeSpinner(opts.Unicode),
promptString: opts.Prompt,
@@ -1299,8 +1311,11 @@ func (t *Terminal) parsePrompt(prompt string) (func(), int) {
t.wrap = false
t.withWindow(t.inputWindow, func() {
line := t.promptLine()
preTask := func(markerClass) int {
return 1
}
t.printHighlighted(
Result{item: item}, tui.ColPrompt, tui.ColPrompt, false, false, line, line, true, nil, nil)
Result{item: item}, tui.ColPrompt, tui.ColPrompt, false, false, line, line, true, preTask, nil)
})
t.wrap = wrap
}
@@ -1408,10 +1423,7 @@ func (t *Terminal) Input() (bool, []rune) {
t.mutex.Lock()
defer t.mutex.Unlock()
paused := t.paused
var src []rune
if !t.inputless {
src = t.input
}
src := t.input
if t.inputOverride != nil {
paused = false
src = *t.inputOverride
@@ -2334,15 +2346,18 @@ func (t *Terminal) placeCursor() {
if t.inputless {
return
}
x := t.promptLen + t.queryLen[0]
if t.inputWindow != nil {
y := t.inputWindow.Height() - 1
if t.layout == layoutReverse {
y = 0
}
t.inputWindow.Move(y, t.promptLen+t.queryLen[0])
x = util.Min(x, t.inputWindow.Width()-1)
t.inputWindow.Move(y, x)
return
}
t.move(t.promptLine(), t.promptLen+t.queryLen[0], false)
x = util.Min(x, t.window.Width()-1)
t.move(t.promptLine(), x, false)
}
func (t *Terminal) printPrompt() {
@@ -2359,6 +2374,11 @@ func (t *Terminal) printPrompt() {
t.prompt()
before, after := t.updatePromptOffset()
if len(before) == 0 && len(after) == 0 && len(t.ghost) > 0 {
w.CPrint(tui.ColInput.WithAttr(tui.Dim), t.ghost)
return
}
color := tui.ColInput
if t.paused {
color = tui.ColDisabled
@@ -2478,6 +2498,10 @@ func (t *Terminal) printInfoImpl() {
outputPrinter, outputLen = t.ansiLabelPrinter(output, &tui.ColInfo, false)
}
shiftLen := t.queryLen[0] + t.queryLen[1] + 1
if shiftLen == 1 && len(t.ghost) > 0 {
shiftLen = util.StringWidth(t.ghost)
}
switch t.infoStyle {
case infoDefault:
if !move(line+1, 0, t.separatorLen == 0) {
@@ -2491,9 +2515,9 @@ func (t *Terminal) printInfoImpl() {
return
}
case infoInlineRight:
pos = t.promptLen + t.queryLen[0] + t.queryLen[1] + 1
pos = t.promptLen + shiftLen
case infoInline:
pos = t.promptLen + t.queryLen[0] + t.queryLen[1] + 1
pos = t.promptLen + shiftLen
printInfoPrefix()
}
@@ -3759,6 +3783,8 @@ func parsePlaceholder(match string) (bool, string, placeholderFlags) {
flags.number = true
case 'f':
flags.file = true
case 'r':
flags.raw = true
case 'q':
flags.forceUpdate = true
trimmed += string(char)
@@ -3910,7 +3936,7 @@ func replacePlaceholder(params replacePlaceholderParams) (string, []string) {
return "''"
}
return strconv.Itoa(int(n))
case flags.file:
case flags.file || flags.raw:
return item.AsString(params.stripAnsi)
default:
return params.executor.QuoteEntry(item.AsString(params.stripAnsi))
@@ -3952,7 +3978,7 @@ func replacePlaceholder(params replacePlaceholderParams) (string, []string) {
if !flags.preserveSpace {
str = strings.TrimSpace(str)
}
if !flags.file {
if !flags.file && !flags.raw {
str = params.executor.QuoteEntry(str)
}
return str
@@ -4606,11 +4632,7 @@ func (t *Terminal) Loop() error {
// U t.uiMutex |
t.uiMutex.Lock()
t.mutex.Lock()
printInfo := util.RunOnce(func() {
if !t.resizeIfNeeded() {
t.printInfo()
}
})
info := false
for _, key := range keys {
req := util.EventType(key)
value := (*events)[req]
@@ -4618,16 +4640,15 @@ func (t *Terminal) Loop() error {
case reqPrompt:
t.printPrompt()
if t.infoStyle == infoInline || t.infoStyle == infoInlineRight {
printInfo()
info = true
}
case reqInfo:
printInfo()
info = true
case reqList:
t.printList()
currentIndex := t.currentIndex()
focusChanged := focusedIndex != currentIndex
info := false
if focusChanged && t.track == trackCurrent {
if focusChanged && focusedIndex >= 0 && t.track == trackCurrent {
t.track = trackDisabled
info = true
}
@@ -4638,9 +4659,6 @@ func (t *Terminal) Loop() error {
info = true
}
}
if info {
printInfo()
}
if focusChanged || version != t.version {
version = t.version
focusedIndex = currentIndex
@@ -4732,6 +4750,9 @@ func (t *Terminal) Loop() error {
return
}
}
if info && !t.resizeIfNeeded() {
t.printInfo()
}
t.flush()
t.mutex.Unlock()
t.uiMutex.Unlock()
@@ -4915,6 +4936,14 @@ func (t *Terminal) Loop() error {
return true
}
doAction = func(a *action) bool {
// Keep track of the current query before the action is executed,
// so we can restore it when the input section is hidden (--no-input).
// * By doing this, we don't have to add a conditional branch to each
// query modifying action.
// * We restore the query after each action instead of after a set of
// actions to allow changing the query even when the input is hidden
// e.g. fzf --no-input --bind 'space:show-input+change-query(foo)+hide-input'
currentInput := t.input
Action:
switch a.t {
case actIgnore, actStart, actClick:
@@ -4966,6 +4995,14 @@ func (t *Terminal) Loop() error {
case actInvalid:
t.mutex.Unlock()
return false
case actBracketedPasteBegin:
current := []rune(t.input)
t.pasting = &current
case actBracketedPasteEnd:
if t.pasting != nil {
queryChanged = string(t.input) != string(*t.pasting)
t.pasting = nil
}
case actTogglePreview, actShowPreview, actHidePreview:
var act bool
switch a.t {
@@ -5101,7 +5138,12 @@ func (t *Terminal) Loop() error {
header = t.captureLines(a.a)
}
if t.changeHeader(header) {
if t.headerWindow != nil {
// Need to resize header window
req(reqFullRedraw)
} else {
req(reqHeader, reqList, reqPrompt, reqInfo)
}
} else {
req(reqHeader)
}
@@ -5462,6 +5504,7 @@ func (t *Terminal) Loop() error {
t.scrollOff = t.window.Height()
t.constrain()
t.scrollOff = soff
req(reqList)
case actJump:
t.jumping = jumpEnabled
req(reqJump)
@@ -5836,7 +5879,7 @@ func (t *Terminal) Loop() error {
if me.Down {
mxCons := util.Constrain(mx-t.promptLen, 0, len(t.input))
if t.inputWindow == nil && my == t.promptLine() && mxCons >= 0 {
if !t.inputless && t.inputWindow == nil && my == t.promptLine() && mxCons >= 0 {
// Prompt
t.cx = mxCons + t.xoffset
} else if my >= min {
@@ -5920,6 +5963,30 @@ func (t *Terminal) Loop() error {
}
}
}
case actChangeGhost, actTransformGhost:
ghost := a.a
if a.t == actTransformGhost {
ghost = t.captureLine(a.a)
}
t.ghost = ghost
if len(t.input) == 0 {
req(reqPrompt)
}
case actChangePointer, actTransformPointer:
pointer := a.a
if a.t == actTransformPointer {
pointer = t.captureLine(a.a)
}
length := uniseg.StringWidth(pointer)
if length <= 2 {
if length != t.pointerLen {
t.forceRerenderList()
}
t.pointer = pointer
t.pointerLen = length
t.pointerEmpty = strings.Repeat(" ", t.pointerLen)
req(reqList)
}
case actChangePreview:
if t.previewOpts.command != a.a {
t.previewOpts.command = a.a
@@ -5997,6 +6064,15 @@ func (t *Terminal) Loop() error {
if !processExecution(a.t) {
t.lastAction = a.t
}
if t.inputless {
// Always just discard the change
t.input = currentInput
t.cx = len(t.input)
beof = false
} else if string(t.input) != string(currentInput) {
t.inputOverride = nil
}
return true
}
@@ -6017,18 +6093,10 @@ func (t *Terminal) Loop() error {
} else if !doActions(actions) {
continue
}
if t.inputless {
// Always just discard the change
t.input = previousInput
t.cx = len(t.input)
beof = false
} else {
if !t.inputless {
t.truncateQuery()
}
queryChanged = string(previousInput) != string(t.input)
if queryChanged {
t.inputOverride = nil
}
queryChanged = queryChanged || t.pasting == nil && string(previousInput) != string(t.input)
changed = changed || queryChanged
if onChanges, prs := t.keymap[tui.Change.AsEvent()]; queryChanged && prs && !doActions(onChanges) {
continue

View File

@@ -75,6 +75,14 @@ func TestReplacePlaceholder(t *testing.T) {
result = replacePlaceholderTest("echo {}", true, Delimiter{}, printsep, false, "query", items1)
checkFormat("echo {{.O}} foo{{.I}}bar baz{{.O}}")
// {r}, strip ansi
result = replacePlaceholderTest("echo {r}", true, Delimiter{}, printsep, false, "query", items1)
checkFormat("echo foo'bar baz")
// {r..}, strip ansi
result = replacePlaceholderTest("echo {r..}", true, Delimiter{}, printsep, false, "query", items1)
checkFormat("echo foo'bar baz")
// {}, with multiple items
result = replacePlaceholderTest("echo {}", true, Delimiter{}, printsep, false, "query", items2)
checkFormat("echo {{.O}}foo{{.I}}bar baz{{.O}}")
@@ -565,7 +573,7 @@ func (item *Item) String() string {
}
// Helper function to parse, execute and convert "text/template" to string. Panics on error.
func templateToString(format string, data interface{}) string {
func templateToString(format string, data any) string {
bb := &bytes.Buffer{}
err := template.Must(template.New("").Parse(format)).Execute(bb, data)

View File

@@ -84,35 +84,37 @@ func _() {
_ = x[CtrlAlt-73]
_ = x[Invalid-74]
_ = x[Fatal-75]
_ = x[Mouse-76]
_ = x[DoubleClick-77]
_ = x[LeftClick-78]
_ = x[RightClick-79]
_ = x[SLeftClick-80]
_ = x[SRightClick-81]
_ = x[ScrollUp-82]
_ = x[ScrollDown-83]
_ = x[SScrollUp-84]
_ = x[SScrollDown-85]
_ = x[PreviewScrollUp-86]
_ = x[PreviewScrollDown-87]
_ = x[Resize-88]
_ = x[Change-89]
_ = x[BackwardEOF-90]
_ = x[Start-91]
_ = x[Load-92]
_ = x[Focus-93]
_ = x[One-94]
_ = x[Zero-95]
_ = x[Result-96]
_ = x[Jump-97]
_ = x[JumpCancel-98]
_ = x[ClickHeader-99]
_ = x[BracketedPasteBegin-76]
_ = x[BracketedPasteEnd-77]
_ = x[Mouse-78]
_ = x[DoubleClick-79]
_ = x[LeftClick-80]
_ = x[RightClick-81]
_ = x[SLeftClick-82]
_ = x[SRightClick-83]
_ = x[ScrollUp-84]
_ = x[ScrollDown-85]
_ = x[SScrollUp-86]
_ = x[SScrollDown-87]
_ = x[PreviewScrollUp-88]
_ = x[PreviewScrollDown-89]
_ = x[Resize-90]
_ = x[Change-91]
_ = x[BackwardEOF-92]
_ = x[Start-93]
_ = x[Load-94]
_ = x[Focus-95]
_ = x[One-96]
_ = x[Zero-97]
_ = x[Result-98]
_ = x[Jump-99]
_ = x[JumpCancel-100]
_ = x[ClickHeader-101]
}
const _EventType_name = "RuneCtrlACtrlBCtrlCCtrlDCtrlECtrlFCtrlGCtrlHTabCtrlJCtrlKCtrlLEnterCtrlNCtrlOCtrlPCtrlQCtrlRCtrlSCtrlTCtrlUCtrlVCtrlWCtrlXCtrlYCtrlZEscCtrlSpaceCtrlDeleteCtrlBackSlashCtrlRightBracketCtrlCaretCtrlSlashShiftTabBackspaceDeletePageUpPageDownUpDownLeftRightHomeEndInsertShiftUpShiftDownShiftLeftShiftRightShiftDeleteF1F2F3F4F5F6F7F8F9F10F11F12AltBackspaceAltUpAltDownAltLeftAltRightAltShiftUpAltShiftDownAltShiftLeftAltShiftRightAltCtrlAltInvalidFatalMouseDoubleClickLeftClickRightClickSLeftClickSRightClickScrollUpScrollDownSScrollUpSScrollDownPreviewScrollUpPreviewScrollDownResizeChangeBackwardEOFStartLoadFocusOneZeroResultJumpJumpCancelClickHeader"
const _EventType_name = "RuneCtrlACtrlBCtrlCCtrlDCtrlECtrlFCtrlGCtrlHTabCtrlJCtrlKCtrlLEnterCtrlNCtrlOCtrlPCtrlQCtrlRCtrlSCtrlTCtrlUCtrlVCtrlWCtrlXCtrlYCtrlZEscCtrlSpaceCtrlDeleteCtrlBackSlashCtrlRightBracketCtrlCaretCtrlSlashShiftTabBackspaceDeletePageUpPageDownUpDownLeftRightHomeEndInsertShiftUpShiftDownShiftLeftShiftRightShiftDeleteF1F2F3F4F5F6F7F8F9F10F11F12AltBackspaceAltUpAltDownAltLeftAltRightAltShiftUpAltShiftDownAltShiftLeftAltShiftRightAltCtrlAltInvalidFatalBracketedPasteBeginBracketedPasteEndMouseDoubleClickLeftClickRightClickSLeftClickSRightClickScrollUpScrollDownSScrollUpSScrollDownPreviewScrollUpPreviewScrollDownResizeChangeBackwardEOFStartLoadFocusOneZeroResultJumpJumpCancelClickHeader"
var _EventType_index = [...]uint16{0, 4, 9, 14, 19, 24, 29, 34, 39, 44, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97, 102, 107, 112, 117, 122, 127, 132, 135, 144, 154, 167, 183, 192, 201, 209, 218, 224, 230, 238, 240, 244, 248, 253, 257, 260, 266, 273, 282, 291, 301, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 333, 336, 339, 351, 356, 363, 370, 378, 388, 400, 412, 425, 428, 435, 442, 447, 452, 463, 472, 482, 492, 503, 511, 521, 530, 541, 556, 573, 579, 585, 596, 601, 605, 610, 613, 617, 623, 627, 637, 648}
var _EventType_index = [...]uint16{0, 4, 9, 14, 19, 24, 29, 34, 39, 44, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97, 102, 107, 112, 117, 122, 127, 132, 135, 144, 154, 167, 183, 192, 201, 209, 218, 224, 230, 238, 240, 244, 248, 253, 257, 260, 266, 273, 282, 291, 301, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 333, 336, 339, 351, 356, 363, 370, 378, 388, 400, 412, 425, 428, 435, 442, 447, 466, 483, 488, 499, 508, 518, 528, 539, 547, 557, 566, 577, 592, 609, 615, 621, 632, 637, 641, 646, 649, 653, 659, 663, 673, 684}
func (i EventType) String() string {
if i < 0 || i >= EventType(len(_EventType_index)-1) {

View File

@@ -214,6 +214,7 @@ func (r *LightRenderer) Init() error {
}
r.enableMouse()
r.csi("?2004h") // Enable bracketed paste mode
r.csi(fmt.Sprintf("%dA", r.MaxY()-1))
r.csi("G")
r.csi("K")
@@ -462,10 +463,11 @@ func (r *LightRenderer) escSequence(sz *int) Event {
}
// Bracketed paste mode: \e[200~ ... \e[201~
if len(r.buffer) > 5 && r.buffer[3] == '0' && (r.buffer[4] == '0' || r.buffer[4] == '1') && r.buffer[5] == '~' {
// Immediately discard the sequence from the buffer and reread input
r.buffer = r.buffer[6:]
*sz = 0
return r.GetChar()
*sz = 6
if r.buffer[4] == '0' {
return Event{BracketedPasteBegin, 0, nil}
}
return Event{BracketedPasteEnd, 0, nil}
}
return Event{Invalid, 0, nil} // INS
case '3':

View File

@@ -197,6 +197,7 @@ func (r *FullscreenRenderer) initScreen() error {
if e = s.Init(); e != nil {
return e
}
s.EnablePaste()
if r.mouse {
s.EnableMouse()
} else {
@@ -266,6 +267,11 @@ func (r *FullscreenRenderer) Size() TermSize {
func (r *FullscreenRenderer) GetChar() Event {
ev := _screen.PollEvent()
switch ev := ev.(type) {
case *tcell.EventPaste:
if ev.Start() {
return Event{BracketedPasteBegin, 0, nil}
}
return Event{BracketedPasteEnd, 0, nil}
case *tcell.EventResize:
// Ignore the first resize event
// https://github.com/gdamore/tcell/blob/v2.7.0/TUTORIAL.md?plain=1#L18

View File

@@ -10,7 +10,7 @@ import (
"github.com/junegunn/fzf/src/util"
)
func assert(t *testing.T, context string, got interface{}, want interface{}) bool {
func assert(t *testing.T, context string, got any, want any) bool {
if got == want {
return true
} else {

View File

@@ -103,6 +103,8 @@ const (
Invalid
Fatal
BracketedPasteBegin
BracketedPasteEnd
Mouse
DoubleClick

View File

@@ -294,9 +294,10 @@ func (chars *Chars) Lines(multiLine bool, maxLines int, wrapCols int, wrapSignWi
line = line[:len(line)-1]
}
hasWrapSign := false
for {
cols := wrapCols
if len(wrapped) > 0 {
if hasWrapSign {
cols -= wrapSignWidth
}
_, overflowIdx := RunesWidth(line, 0, tabstop, cols)
@@ -309,9 +310,11 @@ func (chars *Chars) Lines(multiLine bool, maxLines int, wrapCols int, wrapSignWi
return wrapped, true
}
wrapped = append(wrapped, line[:overflowIdx])
hasWrapSign = true
line = line[overflowIdx:]
continue
}
hasWrapSign = false
// Restore trailing '\n'
if newline {

View File

@@ -76,7 +76,7 @@ func TestCharsLines(t *testing.T) {
check(true, 100, 3, 1, 1, 8, false)
// With wrap sign (3 + 2)
check(true, 100, 3, 2, 1, 12, false)
check(true, 100, 3, 2, 1, 10, false)
// With wrap sign (3 + 2) and no multi-line
check(false, 100, 3, 2, 1, 13, false)

View File

@@ -6,7 +6,7 @@ import "sync"
type EventType int
// Events is a type that associates EventType to any data
type Events map[EventType]interface{}
type Events map[EventType]any
// EventBox is used for coordinating events
type EventBox struct {
@@ -36,7 +36,7 @@ func (b *EventBox) Wait(callback func(*Events)) {
}
// Set turns on the event type on the box
func (b *EventBox) Set(event EventType, value interface{}) {
func (b *EventBox) Set(event EventType, value any) {
b.cond.L.Lock()
b.events[event] = value
if _, found := b.ignore[event]; !found {

View File

@@ -1813,4 +1813,122 @@ class TestCore < TestInteractive
assert_equal ['[0] 1st: foo, 3rd: baz, 2nd: bar'], File.readlines(tempname, chomp: true)
end
end
def test_ghost
tmux.send_keys %(seq 100 | #{FZF} --prompt 'X ' --ghost 'Type in query ...' --bind 'space:change-ghost:Y Z' --bind 'enter:transform-ghost:echo Z Y'), :Enter
tmux.until do |lines|
assert_equal 100, lines.match_count
assert_includes lines, 'X Type in query ...'
end
tmux.send_keys '100'
tmux.until do |lines|
assert_equal 1, lines.match_count
assert_includes lines, 'X 100'
end
tmux.send_keys 'C-u'
tmux.until do |lines|
assert_equal 100, lines.match_count
assert_includes lines, 'X Type in query ...'
end
tmux.send_keys :Space
tmux.until { |lines| assert_includes lines, 'X Y Z' }
tmux.send_keys :Enter
tmux.until { |lines| assert_includes lines, 'X Z Y' }
end
def test_ghost_inline
tmux.send_keys %(seq 100 | #{FZF} --info 'inline: Y' --no-separator --prompt 'X ' --ghost 'Type in query ...'), :Enter
tmux.until do |lines|
assert_includes lines, 'X Type in query ... Y100/100'
end
tmux.send_keys '100'
tmux.until do |lines|
assert_includes lines, 'X 100 Y1/100'
end
tmux.send_keys 'C-u'
tmux.until do |lines|
assert_includes lines, 'X Type in query ... Y100/100'
end
end
def test_offset_middle
tmux.send_keys %(seq 1000 | #{FZF} --sync --no-input --reverse --height 5 --scroll-off 0 --bind space:offset-middle), :Enter
line = nil
tmux.until { |lines| line = lines.index('> 1') }
tmux.send_keys :PgDn
tmux.until { |lines| assert_includes lines[line + 4], "> 5" }
tmux.send_keys :Space
tmux.until { |lines| assert_includes lines[line + 2], "> 5" }
end
def test_no_input_query
tmux.send_keys %(seq 1000 | #{FZF} --no-input --query 555 --bind space:toggle-input), :Enter
tmux.until { |lines| assert_includes lines, '> 555' }
tmux.send_keys :Space
tmux.until do |lines|
assert_equal 1, lines.match_count
assert_includes lines, '> 555'
end
end
def test_no_input_change_query
tmux.send_keys %(seq 1000 | #{FZF} --multi --query 999 --no-input --bind 'enter:show-input+change-query(555)+hide-input,space:change-query(555)+select'), :Enter
tmux.until { |lines| assert_includes lines, '> 999' }
tmux.send_keys :Space
tmux.until do |lines|
assert_includes lines, '>>999'
refute_includes lines, '> 555'
end
tmux.send_keys :Enter
tmux.until do |lines|
refute_includes lines, '>>999'
assert_includes lines, '> 555'
end
end
def test_search_override_query_in_no_input_mode
tmux.send_keys %(seq 1000 | #{FZF} --sync --no-input --bind 'enter:show-input+change-query(555)+hide-input+search(999),space:search(111)+show-input+change-query(777)'), :Enter
tmux.until { |lines| assert_includes lines, '> 1' }
tmux.send_keys :Enter
tmux.until { |lines| assert_includes lines, '> 999' }
tmux.send_keys :Space
tmux.until { |lines| assert_includes lines, '> 777' }
end
def test_change_pointer
tmux.send_keys %(seq 2 | #{FZF} --bind 'a:change-pointer(a),b:change-pointer(bb),c:change-pointer(),d:change-pointer(ddd)'), :Enter
tmux.until { |lines| assert_includes lines, '> 1' }
tmux.send_keys 'a'
tmux.until { |lines| assert_includes lines, 'a 1' }
tmux.send_keys 'b'
tmux.until { |lines| assert_includes lines, 'bb 1' }
tmux.send_keys 'c'
tmux.until { |lines| assert_includes lines, ' 1' }
tmux.send_keys 'd'
tmux.until { |lines| refute_includes lines, 'ddd 1' }
tmux.send_keys :Up
tmux.until { |lines| assert_includes lines, ' 2' }
end
def test_transform_pointer
tmux.send_keys %(seq 2 | #{FZF} --bind 'a:transform-pointer(echo a),b:transform-pointer(echo bb),c:transform-pointer(),d:transform-pointer(echo ddd)'), :Enter
tmux.until { |lines| assert_includes lines, '> 1' }
tmux.send_keys 'a'
tmux.until { |lines| assert_includes lines, 'a 1' }
tmux.send_keys 'b'
tmux.until { |lines| assert_includes lines, 'bb 1' }
tmux.send_keys 'c'
tmux.until { |lines| assert_includes lines, ' 1' }
tmux.send_keys 'd'
tmux.until { |lines| refute_includes lines, 'ddd 1' }
tmux.send_keys :Up
tmux.until { |lines| assert_includes lines, ' 2' }
end
def test_change_header_on_header_window
tmux.send_keys %(seq 100 | #{FZF} --list-border --input-border --bind 'start:change-header(foo),space:change-header(bar)'), :Enter
tmux.until { |lines| assert lines.any_include?('foo') }
tmux.send_keys :Space
tmux.until { |lines| assert lines.any_include?('bar') }
end
end