Add toggle-hscroll

This commit is contained in:
Junegunn Choi 2024-12-19 21:01:16 +09:00
parent e60a9a628b
commit ca5e633399
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
5 changed files with 82 additions and 67 deletions

View File

@ -1506,10 +1506,11 @@ A key or an event can be bound to one or more of the following actions.
\fBshow\-preview\fR
\fBtoggle\fR (\fIright\-click\fR)
\fBtoggle\-all\fR (toggle all matches)
\fBtoggle+down\fR \fIctrl\-i (tab)\fR
\fBtoggle\-header\fR
\fBtoggle\-in\fR (\fB\-\-layout=reverse*\fR ? \fBtoggle+up\fR : \fBtoggle+down\fR)
\fBtoggle\-out\fR (\fB\-\-layout=reverse*\fR ? \fBtoggle+down\fR : \fBtoggle+up\fR)
\fBtoggle\-header\fR
\fBtoggle\-hscroll\fR
\fBtoggle\-multi\-line\fR
\fBtoggle\-preview\fR
\fBtoggle\-preview\-wrap\fR
\fBtoggle\-search\fR (toggle search functionality)
@ -1517,6 +1518,7 @@ A key or an event can be bound to one or more of the following actions.
\fBtoggle\-track\fR (toggle global tracking option (\fB\-\-track\fR))
\fBtoggle\-track\-current\fR (toggle tracking of the current item)
\fBtoggle\-wrap\fR \fIctrl\-/\fR \fIalt\-/\fR
\fBtoggle+down\fR \fIctrl\-i (tab)\fR
\fBtoggle+up\fR \fIbtab (shift\-tab)\fR
\fBtrack\-current\fR (track the current item; automatically disabled if focus changes)
\fBtransform(...)\fR (transform states using the output of an external command)

View File

@ -60,73 +60,74 @@ func _() {
_ = x[actToggleHeader-49]
_ = x[actToggleWrap-50]
_ = x[actToggleMultiLine-51]
_ = x[actTrackCurrent-52]
_ = x[actUntrackCurrent-53]
_ = x[actDown-54]
_ = x[actUp-55]
_ = x[actPageUp-56]
_ = x[actPageDown-57]
_ = x[actPosition-58]
_ = x[actHalfPageUp-59]
_ = x[actHalfPageDown-60]
_ = x[actOffsetUp-61]
_ = x[actOffsetDown-62]
_ = x[actOffsetMiddle-63]
_ = x[actJump-64]
_ = x[actJumpAccept-65]
_ = x[actPrintQuery-66]
_ = x[actRefreshPreview-67]
_ = x[actReplaceQuery-68]
_ = x[actToggleSort-69]
_ = x[actShowPreview-70]
_ = x[actHidePreview-71]
_ = x[actTogglePreview-72]
_ = x[actTogglePreviewWrap-73]
_ = x[actTransform-74]
_ = x[actTransformBorderLabel-75]
_ = x[actTransformHeader-76]
_ = x[actTransformPreviewLabel-77]
_ = x[actTransformPrompt-78]
_ = x[actTransformQuery-79]
_ = x[actPreview-80]
_ = x[actChangePreview-81]
_ = x[actChangePreviewWindow-82]
_ = x[actPreviewTop-83]
_ = x[actPreviewBottom-84]
_ = x[actPreviewUp-85]
_ = x[actPreviewDown-86]
_ = x[actPreviewPageUp-87]
_ = x[actPreviewPageDown-88]
_ = x[actPreviewHalfPageUp-89]
_ = x[actPreviewHalfPageDown-90]
_ = x[actPrevHistory-91]
_ = x[actPrevSelected-92]
_ = x[actPrint-93]
_ = x[actPut-94]
_ = x[actNextHistory-95]
_ = x[actNextSelected-96]
_ = x[actExecute-97]
_ = x[actExecuteSilent-98]
_ = x[actExecuteMulti-99]
_ = x[actSigStop-100]
_ = x[actFirst-101]
_ = x[actLast-102]
_ = x[actReload-103]
_ = x[actReloadSync-104]
_ = x[actDisableSearch-105]
_ = x[actEnableSearch-106]
_ = x[actSelect-107]
_ = x[actDeselect-108]
_ = x[actUnbind-109]
_ = x[actRebind-110]
_ = x[actBecome-111]
_ = x[actShowHeader-112]
_ = x[actHideHeader-113]
_ = x[actToggleHscroll-52]
_ = x[actTrackCurrent-53]
_ = x[actUntrackCurrent-54]
_ = x[actDown-55]
_ = x[actUp-56]
_ = x[actPageUp-57]
_ = x[actPageDown-58]
_ = x[actPosition-59]
_ = x[actHalfPageUp-60]
_ = x[actHalfPageDown-61]
_ = x[actOffsetUp-62]
_ = x[actOffsetDown-63]
_ = x[actOffsetMiddle-64]
_ = x[actJump-65]
_ = x[actJumpAccept-66]
_ = x[actPrintQuery-67]
_ = x[actRefreshPreview-68]
_ = x[actReplaceQuery-69]
_ = x[actToggleSort-70]
_ = x[actShowPreview-71]
_ = x[actHidePreview-72]
_ = x[actTogglePreview-73]
_ = x[actTogglePreviewWrap-74]
_ = x[actTransform-75]
_ = x[actTransformBorderLabel-76]
_ = x[actTransformHeader-77]
_ = x[actTransformPreviewLabel-78]
_ = x[actTransformPrompt-79]
_ = x[actTransformQuery-80]
_ = x[actPreview-81]
_ = x[actChangePreview-82]
_ = x[actChangePreviewWindow-83]
_ = x[actPreviewTop-84]
_ = x[actPreviewBottom-85]
_ = x[actPreviewUp-86]
_ = x[actPreviewDown-87]
_ = x[actPreviewPageUp-88]
_ = x[actPreviewPageDown-89]
_ = x[actPreviewHalfPageUp-90]
_ = x[actPreviewHalfPageDown-91]
_ = x[actPrevHistory-92]
_ = x[actPrevSelected-93]
_ = x[actPrint-94]
_ = x[actPut-95]
_ = x[actNextHistory-96]
_ = x[actNextSelected-97]
_ = x[actExecute-98]
_ = x[actExecuteSilent-99]
_ = x[actExecuteMulti-100]
_ = x[actSigStop-101]
_ = x[actFirst-102]
_ = x[actLast-103]
_ = x[actReload-104]
_ = x[actReloadSync-105]
_ = x[actDisableSearch-106]
_ = x[actEnableSearch-107]
_ = x[actSelect-108]
_ = x[actDeselect-109]
_ = x[actUnbind-110]
_ = x[actRebind-111]
_ = x[actBecome-112]
_ = x[actShowHeader-113]
_ = x[actHideHeader-114]
}
const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeHeaderactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactTrackCurrentactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformHeaderactTransformPreviewLabelactTransformPromptactTransformQueryactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactBecomeactShowHeaderactHideHeader"
const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeHeaderactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactToggleHscrollactTrackCurrentactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformHeaderactTransformPreviewLabelactTransformPromptactTransformQueryactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactBecomeactShowHeaderactHideHeader"
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, 690, 708, 723, 740, 747, 752, 761, 772, 783, 796, 811, 822, 835, 850, 857, 870, 883, 900, 915, 928, 942, 956, 972, 992, 1004, 1027, 1045, 1069, 1087, 1104, 1114, 1130, 1152, 1165, 1181, 1193, 1207, 1223, 1241, 1261, 1283, 1297, 1312, 1320, 1326, 1340, 1355, 1365, 1381, 1396, 1406, 1414, 1421, 1430, 1443, 1459, 1474, 1483, 1494, 1503, 1512, 1521, 1534, 1547}
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, 690, 708, 724, 739, 756, 763, 768, 777, 788, 799, 812, 827, 838, 851, 866, 873, 886, 899, 916, 931, 944, 958, 972, 988, 1008, 1020, 1043, 1061, 1085, 1103, 1120, 1130, 1146, 1168, 1181, 1197, 1209, 1223, 1239, 1257, 1277, 1299, 1313, 1328, 1336, 1342, 1356, 1371, 1381, 1397, 1412, 1422, 1430, 1437, 1446, 1459, 1475, 1490, 1499, 1510, 1519, 1528, 1537, 1550, 1563}
func (i actionType) String() string {
if i < 0 || i >= actionType(len(_actionType_index)-1) {

View File

@ -1433,6 +1433,8 @@ func parseActionList(masked string, original string, prevActions []*action, putA
appendAction(actToggleWrap)
case "toggle-multi-line":
appendAction(actToggleMultiLine)
case "toggle-hscroll":
appendAction(actToggleHscroll)
case "show-header":
appendAction(actShowHeader)
case "hide-header":

View File

@ -464,6 +464,7 @@ const (
actToggleHeader
actToggleWrap
actToggleMultiLine
actToggleHscroll
actTrackCurrent
actUntrackCurrent
actDown
@ -4643,6 +4644,11 @@ func (t *Terminal) Loop() error {
case actToggleMultiLine:
t.multiLine = !t.multiLine
req(reqList)
case actToggleHscroll:
// Force re-rendering of the list
t.prevLines = make([]itemLine, len(t.prevLines))
t.hscroll = !t.hscroll
req(reqList)
case actTrackCurrent:
if t.track == trackDisabled {
t.track = trackCurrent

View File

@ -1442,10 +1442,14 @@ class TestGoFZF < TestBase
writelines(['=' * 10_000 + '0123456789'])
[0, 3, 6].each do |off|
tmux.prepare
tmux.send_keys "#{FZF} --hscroll-off=#{off} -q 0 < #{tempname}", :Enter
tmux.send_keys "#{FZF} --hscroll-off=#{off} -q 0 --bind space:toggle-hscroll < #{tempname}", :Enter
tmux.until { |lines| assert lines[-3]&.end_with?((0..off).to_a.join + '··') }
tmux.send_keys '9'
tmux.until { |lines| assert lines[-3]&.end_with?('789') }
tmux.send_keys :Space
tmux.until { |lines| assert lines[-3]&.end_with?('=··') }
tmux.send_keys :Space
tmux.until { |lines| assert lines[-3]&.end_with?('789') }
tmux.send_keys :Enter
end
end