Add 'offset-middle' action

This commit is contained in:
Junegunn Choi 2024-06-17 18:34:10 +09:00
parent 59943cbb48
commit e2401aca68
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
5 changed files with 66 additions and 55 deletions

View File

@ -1,7 +1,7 @@
CHANGELOG
=========
0.53.1
0.54.0
------
- Better cache management and improved rendering for `--tail`
- Improved `--sync` behavior
@ -15,8 +15,9 @@ CHANGELOG
```sh
fzf --listen --sync --bind 'focus:transform-header:curl -s localhost:$FZF_PORT?limit=0 | jq .'
```
- Fixed crash when using `--tiebreak=end` with very long items
- Added `offset-middle` action to place the current item is in the middle of the screen
- Fixed mouse support on Windows
- Fixed crash when using `--tiebreak=end` with very long items
- zsh 5.0 compatibility (thanks to @LangLangBart)
- Fixed `--walker-skip` to also skip symlinks to directories
- Fixed `result` event not fired when input stream is not complete

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 "Jun 2024" "fzf 0.53.0" "fzf - a command-line fuzzy finder"
.TH fzf 1 "Jun 2024" "fzf 0.54.0" "fzf - a command-line fuzzy finder"
.SH NAME
fzf - a command-line fuzzy finder
@ -1437,6 +1437,7 @@ A key or an event can be bound to one or more of the following actions.
\fBhide-preview\fR
\fBoffset-down\fR (similar to CTRL-E of Vim)
\fBoffset-up\fR (similar to CTRL-Y of Vim)
\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)

View File

@ -69,61 +69,62 @@ func _() {
_ = x[actHalfPageDown-58]
_ = x[actOffsetUp-59]
_ = x[actOffsetDown-60]
_ = x[actJump-61]
_ = x[actJumpAccept-62]
_ = x[actPrintQuery-63]
_ = x[actRefreshPreview-64]
_ = x[actReplaceQuery-65]
_ = x[actToggleSort-66]
_ = x[actShowPreview-67]
_ = x[actHidePreview-68]
_ = x[actTogglePreview-69]
_ = x[actTogglePreviewWrap-70]
_ = x[actTransform-71]
_ = x[actTransformBorderLabel-72]
_ = x[actTransformHeader-73]
_ = x[actTransformPreviewLabel-74]
_ = x[actTransformPrompt-75]
_ = x[actTransformQuery-76]
_ = x[actPreview-77]
_ = x[actChangePreview-78]
_ = x[actChangePreviewWindow-79]
_ = x[actPreviewTop-80]
_ = x[actPreviewBottom-81]
_ = x[actPreviewUp-82]
_ = x[actPreviewDown-83]
_ = x[actPreviewPageUp-84]
_ = x[actPreviewPageDown-85]
_ = x[actPreviewHalfPageUp-86]
_ = x[actPreviewHalfPageDown-87]
_ = x[actPrevHistory-88]
_ = x[actPrevSelected-89]
_ = x[actPrint-90]
_ = x[actPut-91]
_ = x[actNextHistory-92]
_ = x[actNextSelected-93]
_ = x[actExecute-94]
_ = x[actExecuteSilent-95]
_ = x[actExecuteMulti-96]
_ = x[actSigStop-97]
_ = x[actFirst-98]
_ = x[actLast-99]
_ = x[actReload-100]
_ = x[actReloadSync-101]
_ = x[actDisableSearch-102]
_ = x[actEnableSearch-103]
_ = x[actSelect-104]
_ = x[actDeselect-105]
_ = x[actUnbind-106]
_ = x[actRebind-107]
_ = x[actBecome-108]
_ = x[actShowHeader-109]
_ = x[actHideHeader-110]
_ = x[actOffsetMiddle-61]
_ = x[actJump-62]
_ = x[actJumpAccept-63]
_ = x[actPrintQuery-64]
_ = x[actRefreshPreview-65]
_ = x[actReplaceQuery-66]
_ = x[actToggleSort-67]
_ = x[actShowPreview-68]
_ = x[actHidePreview-69]
_ = x[actTogglePreview-70]
_ = x[actTogglePreviewWrap-71]
_ = x[actTransform-72]
_ = x[actTransformBorderLabel-73]
_ = x[actTransformHeader-74]
_ = x[actTransformPreviewLabel-75]
_ = x[actTransformPrompt-76]
_ = x[actTransformQuery-77]
_ = x[actPreview-78]
_ = x[actChangePreview-79]
_ = x[actChangePreviewWindow-80]
_ = x[actPreviewTop-81]
_ = x[actPreviewBottom-82]
_ = x[actPreviewUp-83]
_ = x[actPreviewDown-84]
_ = x[actPreviewPageUp-85]
_ = x[actPreviewPageDown-86]
_ = x[actPreviewHalfPageUp-87]
_ = x[actPreviewHalfPageDown-88]
_ = x[actPrevHistory-89]
_ = x[actPrevSelected-90]
_ = x[actPrint-91]
_ = x[actPut-92]
_ = x[actNextHistory-93]
_ = x[actNextSelected-94]
_ = x[actExecute-95]
_ = x[actExecuteSilent-96]
_ = x[actExecuteMulti-97]
_ = x[actSigStop-98]
_ = x[actFirst-99]
_ = x[actLast-100]
_ = x[actReload-101]
_ = x[actReloadSync-102]
_ = x[actDisableSearch-103]
_ = x[actEnableSearch-104]
_ = x[actSelect-105]
_ = x[actDeselect-106]
_ = x[actUnbind-107]
_ = x[actRebind-108]
_ = x[actBecome-109]
_ = x[actShowHeader-110]
_ = x[actHideHeader-111]
}
const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeHeaderactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactTrackCurrentactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformHeaderactTransformPreviewLabelactTransformPromptactTransformQueryactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactBecomeactShowHeaderactHideHeader"
const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeHeaderactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactTrackCurrentactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformHeaderactTransformPreviewLabelactTransformPromptactTransformQueryactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactBecomeactShowHeaderactHideHeader"
var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 42, 50, 68, 76, 85, 102, 123, 138, 159, 183, 198, 207, 227, 242, 256, 277, 292, 306, 320, 333, 350, 358, 371, 387, 399, 407, 421, 435, 446, 457, 475, 492, 499, 518, 530, 544, 553, 568, 580, 593, 604, 615, 627, 641, 662, 677, 692, 709, 716, 721, 730, 741, 752, 765, 780, 791, 804, 811, 824, 837, 854, 869, 882, 896, 910, 926, 946, 958, 981, 999, 1023, 1041, 1058, 1068, 1084, 1106, 1119, 1135, 1147, 1161, 1177, 1195, 1215, 1237, 1251, 1266, 1274, 1280, 1294, 1309, 1319, 1335, 1350, 1360, 1368, 1375, 1384, 1397, 1413, 1428, 1437, 1448, 1457, 1466, 1475, 1488, 1501}
var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 42, 50, 68, 76, 85, 102, 123, 138, 159, 183, 198, 207, 227, 242, 256, 277, 292, 306, 320, 333, 350, 358, 371, 387, 399, 407, 421, 435, 446, 457, 475, 492, 499, 518, 530, 544, 553, 568, 580, 593, 604, 615, 627, 641, 662, 677, 692, 709, 716, 721, 730, 741, 752, 765, 780, 791, 804, 819, 826, 839, 852, 869, 884, 897, 911, 925, 941, 961, 973, 996, 1014, 1038, 1056, 1073, 1083, 1099, 1121, 1134, 1150, 1162, 1176, 1192, 1210, 1230, 1252, 1266, 1281, 1289, 1295, 1309, 1324, 1334, 1350, 1365, 1375, 1383, 1390, 1399, 1412, 1428, 1443, 1452, 1463, 1472, 1481, 1490, 1503, 1516}
func (i actionType) String() string {
if i < 0 || i >= actionType(len(_actionType_index)-1) {

View File

@ -1419,6 +1419,8 @@ func parseActionList(masked string, original string, prevActions []*action, putA
appendAction(actOffsetUp)
case "offset-down":
appendAction(actOffsetDown)
case "offset-middle":
appendAction(actOffsetMiddle)
case "preview-top":
appendAction(actPreviewTop)
case "preview-bottom":

View File

@ -451,6 +451,7 @@ const (
actHalfPageDown
actOffsetUp
actOffsetDown
actOffsetMiddle
actJump
actJumpAccept // XXX Deprecated in favor of jump:accept binding
actPrintQuery // XXX Deprecated (not very useful, just use --print-query)
@ -4199,6 +4200,11 @@ func (t *Terminal) Loop() error {
t.vmove(diff, false)
}
req(reqList)
case actOffsetMiddle:
soff := t.scrollOff
t.scrollOff = t.window.Height()
t.constrain()
t.scrollOff = soff
case actJump:
t.jumping = jumpEnabled
req(reqJump)