mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 03:19:01 +00:00
parent
2fb285e530
commit
687c2741b8
13
CHANGELOG.md
13
CHANGELOG.md
@ -3,7 +3,9 @@ CHANGELOG
|
||||
|
||||
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
|
||||
| Variable | Description |
|
||||
| --- | --- |
|
||||
@ -17,8 +19,8 @@ CHANGELOG
|
||||
| `FZF_ACTION` | The name of the last action performed |
|
||||
- This allows you to write sophisticated transformations like so
|
||||
```sh
|
||||
# Dynamically resize preview window
|
||||
seq 10000 | fzf --bind 'result:transform:
|
||||
# Script to dynamically resize the preview window
|
||||
transformer='
|
||||
# 1 line for info, another for prompt, and 2 more lines for preview window border
|
||||
lines=$(( FZF_LINES - FZF_MATCH_COUNT - 4 ))
|
||||
if [[ $FZF_MATCH_COUNT -eq 0 ]]; then
|
||||
@ -28,7 +30,10 @@ CHANGELOG
|
||||
elif [[ $FZF_PREVIEW_LINES -ne 3 ]]; then
|
||||
echo "change-preview-window:3"
|
||||
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}`
|
||||
- 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
|
||||
(seq 10; sleep 1; seq 11 20) | fzf --prompt 'Loading> ' --bind 'load:change-prompt:Loaded> '\fR
|
||||
.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
|
||||
.RS
|
||||
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)
|
||||
case "result":
|
||||
add(tui.Result)
|
||||
case "resize":
|
||||
add(tui.Resize)
|
||||
case "one":
|
||||
add(tui.One)
|
||||
case "zero":
|
||||
|
@ -253,6 +253,7 @@ type Terminal struct {
|
||||
hasResultActions bool
|
||||
hasFocusActions bool
|
||||
hasLoadActions bool
|
||||
hasResizeActions bool
|
||||
triggerLoad bool
|
||||
reading bool
|
||||
running bool
|
||||
@ -533,7 +534,6 @@ func defaultKeymap() map[tui.Event][]*action {
|
||||
}
|
||||
|
||||
add(tui.Invalid, actInvalid)
|
||||
add(tui.Resize, actClearScreen)
|
||||
add(tui.CtrlA, actBeginningOfLine)
|
||||
add(tui.CtrlB, actBackwardChar)
|
||||
add(tui.CtrlC, actAbort)
|
||||
@ -773,7 +773,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
||||
killChan: make(chan int),
|
||||
serverInputChan: make(chan []*action, 10),
|
||||
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,
|
||||
initFunc: func() { renderer.Init() },
|
||||
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.hasFocusActions = t.keymap[tui.Focus.AsEvent()]
|
||||
_, t.hasLoadActions = t.keymap[tui.Load.AsEvent()]
|
||||
@ -3129,6 +3130,9 @@ func (t *Terminal) Loop() {
|
||||
if wasHidden && t.hasPreviewWindow() {
|
||||
refreshPreview(t.previewOpts.command)
|
||||
}
|
||||
if req == reqResize && t.hasResizeActions {
|
||||
t.eventChan <- tui.Resize.AsEvent()
|
||||
}
|
||||
case reqClose:
|
||||
exit(func() int {
|
||||
if t.output() {
|
||||
@ -3211,7 +3215,7 @@ func (t *Terminal) Loop() {
|
||||
}
|
||||
select {
|
||||
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:
|
||||
event = tui.Invalid.AsEvent()
|
||||
if t.listenAddr == nil || t.listenAddr.IsLocal() || t.listenUnsafe {
|
||||
|
Loading…
Reference in New Issue
Block a user