Skip to content
Myr

Add 'resize' event

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Close #3570

authored by Junegunn Choi · committed by Junegunn Choi · parent 2fb285e · Browse files · 4 files+25 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+25 added−7 removed

  • other:+25 added−7 removed

4 files+25 added−7 removed

modified:man/man1/fzf.1+7 added
1108 unmodified lines
1109e.g.1110 \fB# Change the prompt to "loaded" when the input stream is complete1111 (seq 10; sleep 1; seq 11 20) | fzf --prompt 'Loading> ' --bind 'load:change-prompt:Loaded> '\fR1112.RE1113\fIresize\fR1114.RS1115Triggered when the terminal size is changed.11161117e.g.1118 \fBfzf --bind 'resize:transform-header:echo Resized: ${FZF_COLUMNS}x${FZF_LINES}'\fR1119.RE1120\fIresult\fR1121.RS1122Triggered when the filtering for the current query is complete and the result list is ready.1123
340 unmodified lines
modified:src/options.go+2 added
652 unmodified lines
653 case "focus":654 add(tui.Focus)655 case "result":656 add(tui.Result)657 case "resize":658 add(tui.Resize)659 case "one":660 add(tui.One)661 case "zero":662 add(tui.Zero)
1519 unmodified lines
modified:src/terminal.go+7 added-3 removed
251 unmodified lines
252 progress int253 hasResultActions bool254 hasFocusActions bool255 hasLoadActions bool256 hasResizeActions bool257 triggerLoad bool258 reading bool259 running bool260 failed *string
272 unmodified lines
533 keymap[e] = toActions(a)534 }535536 add(tui.Invalid, actInvalid)536 add(tui.Resize, actClearScreen)537 add(tui.CtrlA, actBeginningOfLine)538 add(tui.CtrlB, actBackwardChar)539 add(tui.CtrlC, actAbort)540 add(tui.CtrlG, actAbort)
231 unmodified lines
772 startChan: make(chan fitpad, 1),773 killChan: make(chan int),774 serverInputChan: make(chan []*action, 10),775 serverOutputChan: make(chan string),776 eventChan: make(chan tui.Event, 5), // (load + result + zero|one) | (focus) | (GetChar)776 eventChan: make(chan tui.Event, 6), // (load + result + zero|one) | (focus) | (resize) | (GetChar)777 tui: renderer,778 initFunc: func() { renderer.Init() },779 executing: util.NewAtomicBool(false),780 lastAction: actStart,
35 unmodified lines
816 }817 }818 }819820 _, t.hasResizeActions = t.keymap[tui.Resize.AsEvent()]821 _, t.hasResultActions = t.keymap[tui.Result.AsEvent()]822 _, t.hasFocusActions = t.keymap[tui.Focus.AsEvent()]823 _, t.hasLoadActions = t.keymap[tui.Load.AsEvent()]824
2304 unmodified lines
3129 t.redraw()3130 if wasHidden && t.hasPreviewWindow() {3131 refreshPreview(t.previewOpts.command)3132 }3133 if req == reqResize && t.hasResizeActions {3134 t.eventChan <- tui.Resize.AsEvent()3135 }3136 case reqClose:3137 exit(func() int {3138 if t.output() {3139 return exitOk
74 unmodified lines
3214 barrier <- true3215 }3216 select {3217 case event = <-t.eventChan:3214 needBarrier = !event.Is(tui.Load, tui.Result, tui.Focus, tui.One, tui.Zero)3218 needBarrier = !event.Is(tui.Load, tui.Result, tui.Focus, tui.One, tui.Zero, tui.Resize)3219 case serverActions := <-t.serverInputChan:3220 event = tui.Invalid.AsEvent()3221 if t.listenAddr == nil || t.listenAddr.IsLocal() || t.listenUnsafe {3222 actions = serverActions
965 unmodified lines
modified:CHANGELOG.md+9 added-4 removed
1 unmodified line
2=========340.46.0 (WIP)5------6- Added `result` event that is triggered when the filtering for the current query is complete and the result list is ready.6- Added two new events7 - `result` - triggered when the filtering for the current query is complete and the result list is ready8 - `resize` - triggered when the terminal size is changed9- fzf now exports the following environment variables to the child processes10 | Variable | Description |11 | --- | --- |12 | `FZF_LINES` | Number of lines fzf takes up excluding padding and margin |
5 unmodified lines
18 | `FZF_PROMPT` | Prompt string |19 | `FZF_ACTION` | The name of the last action performed |20 - This allows you to write sophisticated transformations like so21 ```sh20 # Dynamically resize preview window21 seq 10000 | fzf --bind 'result:transform:22 # Script to dynamically resize the preview window23 transformer='24 # 1 line for info, another for prompt, and 2 more lines for preview window border25 lines=$(( FZF_LINES - FZF_MATCH_COUNT - 4 ))26 if [[ $FZF_MATCH_COUNT -eq 0 ]]; then27 echo "change-preview-window:hidden"
1 unmodified line
29 echo "change-preview-window:$lines"30 elif [[ $FZF_PREVIEW_LINES -ne 3 ]]; then31 echo "change-preview-window:3"32 fi31 ' --preview 'seq {} 10000' --preview-window up33 '34 seq 10000 | fzf --preview 'seq {} 10000' --preview-window up \35 --bind "result:transform:$transformer" \36 --bind "resize:transform:$transformer"37 ```38 - And we're phasing out `{fzf:prompt}` and `{fzf:action}`39- Changed [mattn/go-runewidth](https://github.com/mattn/go-runewidth) dependency to [rivo/uniseg](https://github.com/rivo/uniseg) for accurate results40 - Set `--ambidouble` if your terminal displays characters with East Asian Width Class Ambiguous (e.g. box-drawing characters for borders) as 2 columns
1818 unmodified lines