Add toggle-multi-line action

This commit is contained in:
Junegunn Choi 2024-12-19 20:51:49 +09:00
parent 0167691941
commit e60a9a628b
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
4 changed files with 76 additions and 65 deletions

View File

@ -59,73 +59,74 @@ func _() {
_ = x[actToggleTrackCurrent-48] _ = x[actToggleTrackCurrent-48]
_ = x[actToggleHeader-49] _ = x[actToggleHeader-49]
_ = x[actToggleWrap-50] _ = x[actToggleWrap-50]
_ = x[actTrackCurrent-51] _ = x[actToggleMultiLine-51]
_ = x[actUntrackCurrent-52] _ = x[actTrackCurrent-52]
_ = x[actDown-53] _ = x[actUntrackCurrent-53]
_ = x[actUp-54] _ = x[actDown-54]
_ = x[actPageUp-55] _ = x[actUp-55]
_ = x[actPageDown-56] _ = x[actPageUp-56]
_ = x[actPosition-57] _ = x[actPageDown-57]
_ = x[actHalfPageUp-58] _ = x[actPosition-58]
_ = x[actHalfPageDown-59] _ = x[actHalfPageUp-59]
_ = x[actOffsetUp-60] _ = x[actHalfPageDown-60]
_ = x[actOffsetDown-61] _ = x[actOffsetUp-61]
_ = x[actOffsetMiddle-62] _ = x[actOffsetDown-62]
_ = x[actJump-63] _ = x[actOffsetMiddle-63]
_ = x[actJumpAccept-64] _ = x[actJump-64]
_ = x[actPrintQuery-65] _ = x[actJumpAccept-65]
_ = x[actRefreshPreview-66] _ = x[actPrintQuery-66]
_ = x[actReplaceQuery-67] _ = x[actRefreshPreview-67]
_ = x[actToggleSort-68] _ = x[actReplaceQuery-68]
_ = x[actShowPreview-69] _ = x[actToggleSort-69]
_ = x[actHidePreview-70] _ = x[actShowPreview-70]
_ = x[actTogglePreview-71] _ = x[actHidePreview-71]
_ = x[actTogglePreviewWrap-72] _ = x[actTogglePreview-72]
_ = x[actTransform-73] _ = x[actTogglePreviewWrap-73]
_ = x[actTransformBorderLabel-74] _ = x[actTransform-74]
_ = x[actTransformHeader-75] _ = x[actTransformBorderLabel-75]
_ = x[actTransformPreviewLabel-76] _ = x[actTransformHeader-76]
_ = x[actTransformPrompt-77] _ = x[actTransformPreviewLabel-77]
_ = x[actTransformQuery-78] _ = x[actTransformPrompt-78]
_ = x[actPreview-79] _ = x[actTransformQuery-79]
_ = x[actChangePreview-80] _ = x[actPreview-80]
_ = x[actChangePreviewWindow-81] _ = x[actChangePreview-81]
_ = x[actPreviewTop-82] _ = x[actChangePreviewWindow-82]
_ = x[actPreviewBottom-83] _ = x[actPreviewTop-83]
_ = x[actPreviewUp-84] _ = x[actPreviewBottom-84]
_ = x[actPreviewDown-85] _ = x[actPreviewUp-85]
_ = x[actPreviewPageUp-86] _ = x[actPreviewDown-86]
_ = x[actPreviewPageDown-87] _ = x[actPreviewPageUp-87]
_ = x[actPreviewHalfPageUp-88] _ = x[actPreviewPageDown-88]
_ = x[actPreviewHalfPageDown-89] _ = x[actPreviewHalfPageUp-89]
_ = x[actPrevHistory-90] _ = x[actPreviewHalfPageDown-90]
_ = x[actPrevSelected-91] _ = x[actPrevHistory-91]
_ = x[actPrint-92] _ = x[actPrevSelected-92]
_ = x[actPut-93] _ = x[actPrint-93]
_ = x[actNextHistory-94] _ = x[actPut-94]
_ = x[actNextSelected-95] _ = x[actNextHistory-95]
_ = x[actExecute-96] _ = x[actNextSelected-96]
_ = x[actExecuteSilent-97] _ = x[actExecute-97]
_ = x[actExecuteMulti-98] _ = x[actExecuteSilent-98]
_ = x[actSigStop-99] _ = x[actExecuteMulti-99]
_ = x[actFirst-100] _ = x[actSigStop-100]
_ = x[actLast-101] _ = x[actFirst-101]
_ = x[actReload-102] _ = x[actLast-102]
_ = x[actReloadSync-103] _ = x[actReload-103]
_ = x[actDisableSearch-104] _ = x[actReloadSync-104]
_ = x[actEnableSearch-105] _ = x[actDisableSearch-105]
_ = x[actSelect-106] _ = x[actEnableSearch-106]
_ = x[actDeselect-107] _ = x[actSelect-107]
_ = x[actUnbind-108] _ = x[actDeselect-108]
_ = x[actRebind-109] _ = x[actUnbind-109]
_ = x[actBecome-110] _ = x[actRebind-110]
_ = x[actShowHeader-111] _ = x[actBecome-111]
_ = x[actHideHeader-112] _ = x[actShowHeader-112]
_ = x[actHideHeader-113]
} }
const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeHeaderactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactTrackCurrentactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformHeaderactTransformPreviewLabelactTransformPromptactTransformQueryactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactBecomeactShowHeaderactHideHeader" const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeHeaderactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactTrackCurrentactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformHeaderactTransformPreviewLabelactTransformPromptactTransformQueryactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactBecomeactShowHeaderactHideHeader"
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, 705, 722, 729, 734, 743, 754, 765, 778, 793, 804, 817, 832, 839, 852, 865, 882, 897, 910, 924, 938, 954, 974, 986, 1009, 1027, 1051, 1069, 1086, 1096, 1112, 1134, 1147, 1163, 1175, 1189, 1205, 1223, 1243, 1265, 1279, 1294, 1302, 1308, 1322, 1337, 1347, 1363, 1378, 1388, 1396, 1403, 1412, 1425, 1441, 1456, 1465, 1476, 1485, 1494, 1503, 1516, 1529} 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}
func (i actionType) String() string { func (i actionType) String() string {
if i < 0 || i >= actionType(len(_actionType_index)-1) { if i < 0 || i >= actionType(len(_actionType_index)-1) {

View File

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

View File

@ -463,6 +463,7 @@ const (
actToggleTrackCurrent actToggleTrackCurrent
actToggleHeader actToggleHeader
actToggleWrap actToggleWrap
actToggleMultiLine
actTrackCurrent actTrackCurrent
actUntrackCurrent actUntrackCurrent
actDown actDown
@ -4639,6 +4640,9 @@ func (t *Terminal) Loop() error {
case actToggleWrap: case actToggleWrap:
t.wrap = !t.wrap t.wrap = !t.wrap
req(reqList, reqHeader) req(reqList, reqHeader)
case actToggleMultiLine:
t.multiLine = !t.multiLine
req(reqList)
case actTrackCurrent: case actTrackCurrent:
if t.track == trackDisabled { if t.track == trackDisabled {
t.track = trackCurrent t.track = trackCurrent

View File

@ -2133,7 +2133,11 @@ class TestGoFZF < TestBase
end end
def test_keep_right def test_keep_right
tmux.send_keys "seq 10000 | #{FZF} --read0 --keep-right --no-multi-line", :Enter tmux.send_keys "seq 10000 | #{FZF} --read0 --keep-right --no-multi-line --bind space:toggle-multi-line", :Enter
tmux.until { |lines| assert lines.any_include?('9999␊10000') }
tmux.send_keys :Space
tmux.until { |lines| assert lines.any_include?('> 1') }
tmux.send_keys :Space
tmux.until { |lines| assert lines.any_include?('9999␊10000') } tmux.until { |lines| assert lines.any_include?('9999␊10000') }
end end