mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-25 16:18:27 +00:00
parent
2fb285e530
commit
687c2741b8
13
CHANGELOG.md
13
CHANGELOG.md
@ -3,7 +3,9 @@ CHANGELOG
|
|||||||
|
|
||||||
0.46.0 (WIP)
|
0.46.0 (WIP)
|
||||||
------
|
------
|
||||||
- Added `result` event that is triggered when the filtering for the current query is complete and the result list is ready.
|
- Added two new events
|
||||||
|
- `result` - triggered when the filtering for the current query is complete and the result list is ready
|
||||||
|
- `resize` - triggered when the terminal size is changed
|
||||||
- fzf now exports the following environment variables to the child processes
|
- fzf now exports the following environment variables to the child processes
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
@ -17,8 +19,8 @@ CHANGELOG
|
|||||||
| `FZF_ACTION` | The name of the last action performed |
|
| `FZF_ACTION` | The name of the last action performed |
|
||||||
- This allows you to write sophisticated transformations like so
|
- This allows you to write sophisticated transformations like so
|
||||||
```sh
|
```sh
|
||||||
# Dynamically resize preview window
|
# Script to dynamically resize the preview window
|
||||||
seq 10000 | fzf --bind 'result:transform:
|
transformer='
|
||||||
# 1 line for info, another for prompt, and 2 more lines for preview window border
|
# 1 line for info, another for prompt, and 2 more lines for preview window border
|
||||||
lines=$(( FZF_LINES - FZF_MATCH_COUNT - 4 ))
|
lines=$(( FZF_LINES - FZF_MATCH_COUNT - 4 ))
|
||||||
if [[ $FZF_MATCH_COUNT -eq 0 ]]; then
|
if [[ $FZF_MATCH_COUNT -eq 0 ]]; then
|
||||||
@ -28,7 +30,10 @@ CHANGELOG
|
|||||||
elif [[ $FZF_PREVIEW_LINES -ne 3 ]]; then
|
elif [[ $FZF_PREVIEW_LINES -ne 3 ]]; then
|
||||||
echo "change-preview-window:3"
|
echo "change-preview-window:3"
|
||||||
fi
|
fi
|
||||||
' --preview 'seq {} 10000' --preview-window up
|
'
|
||||||
|
seq 10000 | fzf --preview 'seq {} 10000' --preview-window up \
|
||||||
|
--bind "result:transform:$transformer" \
|
||||||
|
--bind "resize:transform:$transformer"
|
||||||
```
|
```
|
||||||
- And we're phasing out `{fzf:prompt}` and `{fzf:action}`
|
- And we're phasing out `{fzf:prompt}` and `{fzf:action}`
|
||||||
- Changed [mattn/go-runewidth](https://github.com/mattn/go-runewidth) dependency to [rivo/uniseg](https://github.com/rivo/uniseg) for accurate results
|
- Changed [mattn/go-runewidth](https://github.com/mattn/go-runewidth) dependency to [rivo/uniseg](https://github.com/rivo/uniseg) for accurate results
|
||||||
|
@ -1110,6 +1110,13 @@ e.g.
|
|||||||
\fB# Change the prompt to "loaded" when the input stream is complete
|
\fB# Change the prompt to "loaded" when the input stream is complete
|
||||||
(seq 10; sleep 1; seq 11 20) | fzf --prompt 'Loading> ' --bind 'load:change-prompt:Loaded> '\fR
|
(seq 10; sleep 1; seq 11 20) | fzf --prompt 'Loading> ' --bind 'load:change-prompt:Loaded> '\fR
|
||||||
.RE
|
.RE
|
||||||
|
\fIresize\fR
|
||||||
|
.RS
|
||||||
|
Triggered when the terminal size is changed.
|
||||||
|
|
||||||
|
e.g.
|
||||||
|
\fBfzf --bind 'resize:transform-header:echo Resized: ${FZF_COLUMNS}x${FZF_LINES}'\fR
|
||||||
|
.RE
|
||||||
\fIresult\fR
|
\fIresult\fR
|
||||||
.RS
|
.RS
|
||||||
Triggered when the filtering for the current query is complete and the result list is ready.
|
Triggered when the filtering for the current query is complete and the result list is ready.
|
||||||
|
@ -654,6 +654,8 @@ func parseKeyChordsImpl(str string, message string, exit func(string)) map[tui.E
|
|||||||
add(tui.Focus)
|
add(tui.Focus)
|
||||||
case "result":
|
case "result":
|
||||||
add(tui.Result)
|
add(tui.Result)
|
||||||
|
case "resize":
|
||||||
|
add(tui.Resize)
|
||||||
case "one":
|
case "one":
|
||||||
add(tui.One)
|
add(tui.One)
|
||||||
case "zero":
|
case "zero":
|
||||||
|
@ -253,6 +253,7 @@ type Terminal struct {
|
|||||||
hasResultActions bool
|
hasResultActions bool
|
||||||
hasFocusActions bool
|
hasFocusActions bool
|
||||||
hasLoadActions bool
|
hasLoadActions bool
|
||||||
|
hasResizeActions bool
|
||||||
triggerLoad bool
|
triggerLoad bool
|
||||||
reading bool
|
reading bool
|
||||||
running bool
|
running bool
|
||||||
@ -533,7 +534,6 @@ func defaultKeymap() map[tui.Event][]*action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
add(tui.Invalid, actInvalid)
|
add(tui.Invalid, actInvalid)
|
||||||
add(tui.Resize, actClearScreen)
|
|
||||||
add(tui.CtrlA, actBeginningOfLine)
|
add(tui.CtrlA, actBeginningOfLine)
|
||||||
add(tui.CtrlB, actBackwardChar)
|
add(tui.CtrlB, actBackwardChar)
|
||||||
add(tui.CtrlC, actAbort)
|
add(tui.CtrlC, actAbort)
|
||||||
@ -773,7 +773,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|||||||
killChan: make(chan int),
|
killChan: make(chan int),
|
||||||
serverInputChan: make(chan []*action, 10),
|
serverInputChan: make(chan []*action, 10),
|
||||||
serverOutputChan: make(chan string),
|
serverOutputChan: make(chan string),
|
||||||
eventChan: make(chan tui.Event, 5), // (load + result + zero|one) | (focus) | (GetChar)
|
eventChan: make(chan tui.Event, 6), // (load + result + zero|one) | (focus) | (resize) | (GetChar)
|
||||||
tui: renderer,
|
tui: renderer,
|
||||||
initFunc: func() { renderer.Init() },
|
initFunc: func() { renderer.Init() },
|
||||||
executing: util.NewAtomicBool(false),
|
executing: util.NewAtomicBool(false),
|
||||||
@ -817,6 +817,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, t.hasResizeActions = t.keymap[tui.Resize.AsEvent()]
|
||||||
_, t.hasResultActions = t.keymap[tui.Result.AsEvent()]
|
_, t.hasResultActions = t.keymap[tui.Result.AsEvent()]
|
||||||
_, t.hasFocusActions = t.keymap[tui.Focus.AsEvent()]
|
_, t.hasFocusActions = t.keymap[tui.Focus.AsEvent()]
|
||||||
_, t.hasLoadActions = t.keymap[tui.Load.AsEvent()]
|
_, t.hasLoadActions = t.keymap[tui.Load.AsEvent()]
|
||||||
@ -3129,6 +3130,9 @@ func (t *Terminal) Loop() {
|
|||||||
if wasHidden && t.hasPreviewWindow() {
|
if wasHidden && t.hasPreviewWindow() {
|
||||||
refreshPreview(t.previewOpts.command)
|
refreshPreview(t.previewOpts.command)
|
||||||
}
|
}
|
||||||
|
if req == reqResize && t.hasResizeActions {
|
||||||
|
t.eventChan <- tui.Resize.AsEvent()
|
||||||
|
}
|
||||||
case reqClose:
|
case reqClose:
|
||||||
exit(func() int {
|
exit(func() int {
|
||||||
if t.output() {
|
if t.output() {
|
||||||
@ -3211,7 +3215,7 @@ func (t *Terminal) Loop() {
|
|||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case event = <-t.eventChan:
|
case event = <-t.eventChan:
|
||||||
needBarrier = !event.Is(tui.Load, tui.Result, tui.Focus, tui.One, tui.Zero)
|
needBarrier = !event.Is(tui.Load, tui.Result, tui.Focus, tui.One, tui.Zero, tui.Resize)
|
||||||
case serverActions := <-t.serverInputChan:
|
case serverActions := <-t.serverInputChan:
|
||||||
event = tui.Invalid.AsEvent()
|
event = tui.Invalid.AsEvent()
|
||||||
if t.listenAddr == nil || t.listenAddr.IsLocal() || t.listenUnsafe {
|
if t.listenAddr == nil || t.listenAddr.IsLocal() || t.listenUnsafe {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user