Skip to content
Myr

Border around the header section

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

Close #4159

authored by Junegunn Choi · committed by Junegunn Choi · parent 45fc7b9 · Browse files · 9 files+757 added−292 removed
This commit

State

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

Diff stats

9 files+757 added−292 removed

  • tests:+193 added−14 removed
  • other:+564 added−278 removed

9 files+757 added−292 removed

modified:man/man1/fzf.1+46 added-5 removed
306 unmodified lines
307.B "\-\-reverse"308A synonym for \fB\-\-layout=reverse\fB309310.TP311.BI "\-\-border" [=BORDER_OPT]311.BI "\-\-border" [=STYLE]312Draw border around the finder313314.br315.BR rounded " Border with rounded corners (default)"
71 unmodified lines
387\fB:bottom\fR to put it on the border line on the bottom. The default value388\fB0 (or \fBcenter\fR) will put the label at the center of the border line.389390.TP391.BI "\-\-list\-border" [=STYLE]392Draw border around the list section393394.TP395.BI "\-\-list\-label" [=LABEL]396Label to print on the list border397398.TP399.BI "\-\-list\-label\-pos" [=N[:top|bottom]]400Position of the list label401402.TP403.BI "\-\-input\-border" [=STYLE]404Draw border around the input section405406.TP407.BI "\-\-input\-label" [=LABEL]408Label to print on the input border409410.TP411.BI "\-\-input\-label\-pos" [=N[:top|bottom]]412Position of the input label413414.TP415.BI "\-\-header\-border" [=STYLE]416Draw border around the header section417418.TP419.BI "\-\-header\-label" [=LABEL]420Label to print on the header border421422.TP423.BI "\-\-header\-label\-pos" [=N[:top|bottom]]424Position of the header label425426.TP427.B "\-\-no\-unicode"428Use ASCII characters instead of Unicode drawing characters to draw borders,429the spinner and the horizontal separator.430
167 unmodified lines
598 \fBbg \fRBackground599 \fBlist\-bg \fRList section background600 \fBselected\-bg \fRSelected line background601 \fBpreview\-bg \fRPreview window background566 \fBinput\-bg \fRInput section background602 \fBinput\-bg \fRInput window background (\fB\-\-input\-border\fR)603 \fBheader\-bg \fRHeader window background (\fB\-\-header\-border\fR)604 \fBhl \fRHighlighted substrings605 \fBselected\-hl \fRHighlighted substrings in the selected line606 \fBcurrent\-fg (fg+) \fRText (current line)607 \fBcurrent\-bg (bg+) \fRBackground (current line)
7 unmodified lines
615 \fBscrollbar \fRScrollbar616 \fBseparator \fRHorizontal separator on info line617 \fBpreview\-border \fRBorder around the preview window (\fB\-\-preview\fR)618 \fBpreview\-scrollbar \fRScrollbar582 \fBinput\-border \fRBorder around the input section (\fB\-\-input\-border\fR)619 \fBinput\-border \fRBorder around the input window (\fB\-\-input\-border\fR)620 \fBheader\-border \fRBorder around the header window (\fB\-\-header\-border\fR)621 \fBlabel \fRBorder label (\fB\-\-border\-label\fR, \fB\-\-list\-label\fR, \fB\-\-input\-label\fR, and \fB\-\-preview\-label\fR)622 \fBlist\-label \fRBorder label of the list section (\fB\-\-list\-label\fR)623 \fBpreview\-label \fRBorder label of the preview window (\fB\-\-preview\-label\fR)586 \fBinput\-label \fRBorder label of the input section (\fB\-\-input\-label\fR)624 \fBinput\-label \fRBorder label of the input window (\fB\-\-input\-label\fR)625 \fBheader\-label \fRBorder label of the header window (\fB\-\-header\-label\fR)626 \fBprompt \fRPrompt627 \fBpointer \fRPointer to the current line628 \fBmarker \fRMulti\-select marker629 \fBspinner \fRStreaming input indicator591 \fBheader \fRHeader630 \fBheader (header\-fg) \fRHeader631632.B ANSI COLORS:633 \fB\-1 \fRDefault terminal foreground/background color634 \fB \fR(or the original color of the text)
857 unmodified lines
1492 \fBbeginning\-of\-line\fR \fIctrl\-a home\fR1493 \fBcancel\fR (clear query string if not empty, abort fzf otherwise)1494 \fBchange\-border\-label(...)\fR (change \fB\-\-border\-label\fR to the given string)1495 \fBchange\-header(...)\fR (change header to the given string; doesn't affect \fB\-\-header\-lines\fR)1496 \fBchange\-header\-label(...)\fR (change \fB\-\-header\-label\fR to the given string)1497 \fBchange\-input\-label(...)\fR (change \fB\-\-input\-label\fR to the given string)1498 \fBchange\-list\-label(...)\fR (change \fB\-\-list\-label\fR to the given string)1499 \fBchange\-multi\fR (enable multi-select mode with no limit)1500 \fBchange\-multi(...)\fR (enable multi-select mode with a limit or disable it with 0)
78 unmodified lines
1579 \fBtrack\-current\fR (track the current item; automatically disabled if focus changes)1580 \fBtransform(...)\fR (transform states using the output of an external command)1581 \fBtransform\-border\-label(...)\fR (transform border label using an external command)1582 \fBtransform\-header(...)\fR (transform header using an external command)1583 \fBtransform\-header\-label(...)\fR (transform header label using an external command)1584 \fBtransform\-input\-label(...)\fR (transform input label using an external command)1585 \fBtransform\-list\-label(...)\fR (transform list label using an external command)1586 \fBtransform\-preview\-label(...)\fR (transform preview label using an external command)1587 \fBtransform\-prompt(...)\fR (transform prompt string using an external command)
180 unmodified lines
modified:src/tui/light.go+18 added-2 removed
802 unmodified lines
803 w.bg = r.theme.ListBg.Color804 case WindowInput:805 w.fg = r.theme.Input.Color806 w.bg = r.theme.InputBg.Color807 case WindowHeader:808 w.fg = r.theme.Header.Color809 w.bg = r.theme.HeaderBg.Color810 case WindowPreview:811 w.fg = r.theme.PreviewFg.Color812 w.bg = r.theme.PreviewBg.Color813 }
50 unmodified lines
864 case WindowList:865 color = ColListBorder866 case WindowInput:867 color = ColInputBorder868 case WindowHeader:869 color = ColHeaderBorder870 case WindowPreview:871 color = ColPreviewBorder872 }873 hw := runeWidth(w.border.top)
15 unmodified lines
889 case WindowList:890 color = ColListBorder891 case WindowInput:892 color = ColInputBorder893 case WindowHeader:894 color = ColHeaderBorder895 case WindowPreview:896 color = ColPreviewBorder897 }898 for y := 0; y < w.height; y++ {
17 unmodified lines
916 case WindowList:917 color = ColListBorder918 case WindowInput:919 color = ColInputBorder920 case WindowHeader:921 color = ColHeaderBorder922 case WindowPreview:923 color = ColPreviewBorder924 }925 hw := runeWidth(w.border.top)
52 unmodified lines
978func (w *LightWindow) Y() int {979 return w.posy980}981982func (w *LightWindow) EncloseX(x int) bool {983 return x >= w.left && x < (w.left+w.width)984}985986func (w *LightWindow) EncloseY(y int) bool {987 return y >= w.top && y < (w.top+w.height)988}989990func (w *LightWindow) Enclose(y int, x int) bool {974 return x >= w.left && x < (w.left+w.width) &&975 y >= w.top && y < (w.top+w.height)991 return w.EncloseX(x) && w.EncloseY(y)992}993994func (w *LightWindow) Move(y int, x int) {995 w.posx = x
219 unmodified lines
modified:src/tui/tcell.go+13 added-2 removed
555 unmodified lines
556 normal := ColBorder557 switch windowType {558 case WindowList:559 normal = ColListBorder560 case WindowHeader:561 normal = ColHeaderBorder562 case WindowInput:563 normal = ColInputBorder564 case WindowPreview:565 normal = ColPreviewBorder
28 unmodified lines
594 w.Erase()595 return true596}597598func (w *TcellWindow) EncloseX(x int) bool {599 return x >= w.left && x < (w.left+w.width)600}601602func (w *TcellWindow) EncloseY(y int) bool {603 return y >= w.top && y < (w.top+w.height)604}605606func (w *TcellWindow) Enclose(y int, x int) bool {597 return x >= w.left && x < (w.left+w.width) &&598 y >= w.top && y < (w.top+w.height)607 return w.EncloseX(x) && w.EncloseY(y)608}609610func (w *TcellWindow) Move(y int, x int) {611 w.lastX = x
188 unmodified lines
800 case WindowBase:801 style = ColBorder.style()802 case WindowList:803 style = ColListBorder.style()804 case WindowHeader:805 style = ColHeaderBorder.style()806 case WindowInput:807 style = ColInputBorder.style()808 case WindowPreview:809 style = ColPreviewBorder.style()
54 unmodified lines
modified:src/tui/tui.go+35 added-3 removed
322 unmodified lines
323 Info ColorAttr324 Cursor ColorAttr325 Marker ColorAttr326 Header ColorAttr327 HeaderBg ColorAttr328 HeaderBorder ColorAttr329 HeaderLabel ColorAttr330 Separator ColorAttr331 Scrollbar ColorAttr332 Border ColorAttr333 PreviewBorder ColorAttr
211 unmodified lines
545 WindowBase WindowType = iota546 WindowList547 WindowPreview548 WindowInput549 WindowHeader550)551552type Renderer interface {553 DefaultTheme() *ColorTheme
32 unmodified lines
586 FinishFill()587588 X() int589 Y() int590 EncloseX(x int) bool591 EncloseY(y int) bool592 Enclose(y int, x int) bool593594 Move(y int, x int)595 MoveAndClear(y int, x int)
48 unmodified lines
644 ColCurrentSelectedEmpty ColorPair645 ColSpinner ColorPair646 ColInfo ColorPair647 ColHeader ColorPair648 ColHeaderBorder ColorPair649 ColHeaderLabel ColorPair650 ColSeparator ColorPair651 ColScrollbar ColorPair652 ColBorder ColorPair653 ColPreview ColorPair
44 unmodified lines
698 Scrollbar: ColorAttr{colUndefined, AttrUndefined},699 InputBg: ColorAttr{colUndefined, AttrUndefined},700 InputBorder: ColorAttr{colUndefined, AttrUndefined},701 InputLabel: ColorAttr{colUndefined, AttrUndefined},702 HeaderBg: ColorAttr{colUndefined, AttrUndefined},703 HeaderBorder: ColorAttr{colUndefined, AttrUndefined},704 HeaderLabel: ColorAttr{colUndefined, AttrUndefined},705 }706}707708func NoColorTheme() *ColorTheme {
32 unmodified lines
741 Scrollbar: ColorAttr{colDefault, AttrUndefined},742 InputBg: ColorAttr{colDefault, AttrUndefined},743 InputBorder: ColorAttr{colDefault, AttrUndefined},744 InputLabel: ColorAttr{colDefault, AttrUndefined},745 HeaderBg: ColorAttr{colDefault, AttrUndefined},746 HeaderBorder: ColorAttr{colDefault, AttrUndefined},747 HeaderLabel: ColorAttr{colDefault, AttrUndefined},748 }749}750751func init() {
106 unmodified lines
858 Scrollbar: ColorAttr{colUndefined, AttrUndefined},859 InputBg: ColorAttr{colUndefined, AttrUndefined},860 InputBorder: ColorAttr{colUndefined, AttrUndefined},861 InputLabel: ColorAttr{colUndefined, AttrUndefined},862 HeaderBg: ColorAttr{colUndefined, AttrUndefined},863 HeaderBorder: ColorAttr{colUndefined, AttrUndefined},864 HeaderLabel: ColorAttr{colUndefined, AttrUndefined},865 }866}867851func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool) {868func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool, hasInputWindow bool, hasHeaderWindow bool) {869 if forceBlack {870 theme.Bg = ColorAttr{colBlack, AttrUndefined}871 }872
39 unmodified lines
912 theme.ListBorder = o(theme.Border, theme.ListBorder)913 theme.Separator = o(theme.ListBorder, theme.Separator)914 theme.Scrollbar = o(theme.ListBorder, theme.Scrollbar)915 theme.PreviewScrollbar = o(theme.PreviewBorder, theme.PreviewScrollbar)899 theme.InputBg = o(theme.Bg, o(theme.ListBg, theme.InputBg))916 if hasInputWindow {917 theme.InputBg = o(theme.Bg, theme.InputBg)918 } else {919 // We shouldn't use input-bg if there's no separate input window920 // e.g. fzf --color 'list-bg:green,input-bg:red' --no-input-border921 theme.InputBg = o(theme.Bg, theme.ListBg)922 }923 theme.InputBorder = o(theme.Border, theme.InputBorder)924 theme.InputLabel = o(theme.BorderLabel, theme.InputLabel)925 if hasHeaderWindow {926 theme.HeaderBg = o(theme.Bg, theme.HeaderBg)927 } else {928 theme.HeaderBg = o(theme.Bg, theme.ListBg)929 }930 theme.HeaderBorder = o(theme.Border, theme.HeaderBorder)931 theme.HeaderLabel = o(theme.BorderLabel, theme.HeaderLabel)932933 initPalette(theme)934}935
28 unmodified lines
964 ColCurrentMarker = pair(theme.Marker, theme.DarkBg)965 ColCurrentSelectedEmpty = pair(blank, theme.DarkBg)966 ColSpinner = pair(theme.Spinner, theme.InputBg)967 ColInfo = pair(theme.Info, theme.InputBg)938 ColHeader = pair(theme.Header, theme.ListBg)968 ColSeparator = pair(theme.Separator, theme.InputBg)969 ColScrollbar = pair(theme.Scrollbar, theme.ListBg)970 ColBorder = pair(theme.Border, theme.Bg)971 ColBorderLabel = pair(theme.BorderLabel, theme.Bg)
5 unmodified lines
977 ColListLabel = pair(theme.ListLabel, theme.ListBg)978 ColListBorder = pair(theme.ListBorder, theme.ListBg)979 ColInputBorder = pair(theme.InputBorder, theme.InputBg)980 ColInputLabel = pair(theme.InputLabel, theme.InputBg)981 ColHeader = pair(theme.Header, theme.HeaderBg)982 ColHeaderBorder = pair(theme.HeaderBorder, theme.HeaderBg)983 ColHeaderLabel = pair(theme.HeaderLabel, theme.HeaderBg)984}985986func runeWidth(r rune) int {987 return uniseg.StringWidth(string(r))
1 unmodified line
modified:src/actiontype_string.go+103 added-101 removed
26 unmodified lines
27 _ = x[actChangeBorderLabel-16]28 _ = x[actChangeListLabel-17]29 _ = x[actChangeInputLabel-18]30 _ = x[actChangeHeader-19]31 _ = x[actChangeMulti-20]32 _ = x[actChangePreviewLabel-21]33 _ = x[actChangePrompt-22]34 _ = x[actChangeQuery-23]35 _ = x[actClearScreen-24]36 _ = x[actClearQuery-25]37 _ = x[actClearSelection-26]38 _ = x[actClose-27]39 _ = x[actDeleteChar-28]40 _ = x[actDeleteCharEof-29]41 _ = x[actEndOfLine-30]42 _ = x[actFatal-31]43 _ = x[actForwardChar-32]44 _ = x[actForwardWord-33]45 _ = x[actKillLine-34]46 _ = x[actKillWord-35]47 _ = x[actUnixLineDiscard-36]48 _ = x[actUnixWordRubout-37]49 _ = x[actYank-38]50 _ = x[actBackwardKillWord-39]51 _ = x[actSelectAll-40]52 _ = x[actDeselectAll-41]53 _ = x[actToggle-42]54 _ = x[actToggleSearch-43]55 _ = x[actToggleAll-44]56 _ = x[actToggleDown-45]57 _ = x[actToggleUp-46]58 _ = x[actToggleIn-47]59 _ = x[actToggleOut-48]60 _ = x[actToggleTrack-49]61 _ = x[actToggleTrackCurrent-50]62 _ = x[actToggleHeader-51]63 _ = x[actToggleWrap-52]64 _ = x[actToggleMultiLine-53]65 _ = x[actToggleHscroll-54]66 _ = x[actTrackCurrent-55]67 _ = x[actUntrackCurrent-56]68 _ = x[actDown-57]69 _ = x[actUp-58]70 _ = x[actPageUp-59]71 _ = x[actPageDown-60]72 _ = x[actPosition-61]73 _ = x[actHalfPageUp-62]74 _ = x[actHalfPageDown-63]75 _ = x[actOffsetUp-64]76 _ = x[actOffsetDown-65]77 _ = x[actOffsetMiddle-66]78 _ = x[actJump-67]79 _ = x[actJumpAccept-68]80 _ = x[actPrintQuery-69]81 _ = x[actRefreshPreview-70]82 _ = x[actReplaceQuery-71]83 _ = x[actToggleSort-72]84 _ = x[actShowPreview-73]85 _ = x[actHidePreview-74]86 _ = x[actTogglePreview-75]87 _ = x[actTogglePreviewWrap-76]88 _ = x[actTransform-77]89 _ = x[actTransformBorderLabel-78]90 _ = x[actTransformListLabel-79]91 _ = x[actTransformInputLabel-80]92 _ = x[actTransformHeader-81]93 _ = x[actTransformPreviewLabel-82]94 _ = x[actTransformPrompt-83]95 _ = x[actTransformQuery-84]96 _ = x[actPreview-85]97 _ = x[actChangePreview-86]98 _ = x[actChangePreviewWindow-87]99 _ = x[actPreviewTop-88]100 _ = x[actPreviewBottom-89]101 _ = x[actPreviewUp-90]102 _ = x[actPreviewDown-91]103 _ = x[actPreviewPageUp-92]104 _ = x[actPreviewPageDown-93]105 _ = x[actPreviewHalfPageUp-94]106 _ = x[actPreviewHalfPageDown-95]107 _ = x[actPrevHistory-96]108 _ = x[actPrevSelected-97]109 _ = x[actPrint-98]110 _ = x[actPut-99]111 _ = x[actNextHistory-100]112 _ = x[actNextSelected-101]113 _ = x[actExecute-102]114 _ = x[actExecuteSilent-103]115 _ = x[actExecuteMulti-104]116 _ = x[actSigStop-105]117 _ = x[actFirst-106]118 _ = x[actLast-107]119 _ = x[actReload-108]120 _ = x[actReloadSync-109]121 _ = x[actDisableSearch-110]122 _ = x[actEnableSearch-111]123 _ = x[actSelect-112]124 _ = x[actDeselect-113]125 _ = x[actUnbind-114]126 _ = x[actRebind-115]127 _ = x[actBecome-116]128 _ = x[actShowHeader-117]129 _ = x[actHideHeader-118]31 _ = x[actChangeHeaderLabel-20]32 _ = x[actChangeMulti-21]33 _ = x[actChangePreviewLabel-22]34 _ = x[actChangePrompt-23]35 _ = x[actChangeQuery-24]36 _ = x[actClearScreen-25]37 _ = x[actClearQuery-26]38 _ = x[actClearSelection-27]39 _ = x[actClose-28]40 _ = x[actDeleteChar-29]41 _ = x[actDeleteCharEof-30]42 _ = x[actEndOfLine-31]43 _ = x[actFatal-32]44 _ = x[actForwardChar-33]45 _ = x[actForwardWord-34]46 _ = x[actKillLine-35]47 _ = x[actKillWord-36]48 _ = x[actUnixLineDiscard-37]49 _ = x[actUnixWordRubout-38]50 _ = x[actYank-39]51 _ = x[actBackwardKillWord-40]52 _ = x[actSelectAll-41]53 _ = x[actDeselectAll-42]54 _ = x[actToggle-43]55 _ = x[actToggleSearch-44]56 _ = x[actToggleAll-45]57 _ = x[actToggleDown-46]58 _ = x[actToggleUp-47]59 _ = x[actToggleIn-48]60 _ = x[actToggleOut-49]61 _ = x[actToggleTrack-50]62 _ = x[actToggleTrackCurrent-51]63 _ = x[actToggleHeader-52]64 _ = x[actToggleWrap-53]65 _ = x[actToggleMultiLine-54]66 _ = x[actToggleHscroll-55]67 _ = x[actTrackCurrent-56]68 _ = x[actUntrackCurrent-57]69 _ = x[actDown-58]70 _ = x[actUp-59]71 _ = x[actPageUp-60]72 _ = x[actPageDown-61]73 _ = x[actPosition-62]74 _ = x[actHalfPageUp-63]75 _ = x[actHalfPageDown-64]76 _ = x[actOffsetUp-65]77 _ = x[actOffsetDown-66]78 _ = x[actOffsetMiddle-67]79 _ = x[actJump-68]80 _ = x[actJumpAccept-69]81 _ = x[actPrintQuery-70]82 _ = x[actRefreshPreview-71]83 _ = x[actReplaceQuery-72]84 _ = x[actToggleSort-73]85 _ = x[actShowPreview-74]86 _ = x[actHidePreview-75]87 _ = x[actTogglePreview-76]88 _ = x[actTogglePreviewWrap-77]89 _ = x[actTransform-78]90 _ = x[actTransformBorderLabel-79]91 _ = x[actTransformListLabel-80]92 _ = x[actTransformInputLabel-81]93 _ = x[actTransformHeader-82]94 _ = x[actTransformHeaderLabel-83]95 _ = x[actTransformPreviewLabel-84]96 _ = x[actTransformPrompt-85]97 _ = x[actTransformQuery-86]98 _ = x[actPreview-87]99 _ = x[actChangePreview-88]100 _ = x[actChangePreviewWindow-89]101 _ = x[actPreviewTop-90]102 _ = x[actPreviewBottom-91]103 _ = x[actPreviewUp-92]104 _ = x[actPreviewDown-93]105 _ = x[actPreviewPageUp-94]106 _ = x[actPreviewPageDown-95]107 _ = x[actPreviewHalfPageUp-96]108 _ = x[actPreviewHalfPageDown-97]109 _ = x[actPrevHistory-98]110 _ = x[actPrevSelected-99]111 _ = x[actPrint-100]112 _ = x[actPut-101]113 _ = x[actNextHistory-102]114 _ = x[actNextSelected-103]115 _ = x[actExecute-104]116 _ = x[actExecuteSilent-105]117 _ = x[actExecuteMulti-106]118 _ = x[actSigStop-107]119 _ = x[actFirst-108]120 _ = x[actLast-109]121 _ = x[actReload-110]122 _ = x[actReloadSync-111]123 _ = x[actDisableSearch-112]124 _ = x[actEnableSearch-113]125 _ = x[actSelect-114]126 _ = x[actDeselect-115]127 _ = x[actUnbind-116]128 _ = x[actRebind-117]129 _ = x[actBecome-118]130 _ = x[actShowHeader-119]131 _ = x[actHideHeader-120]132}133132const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeListLabelactChangeInputLabelactChangeHeaderactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactToggleHscrollactTrackCurrentactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformListLabelactTransformInputLabelactTransformHeaderactTransformPreviewLabelactTransformPromptactTransformQueryactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactBecomeactShowHeaderactHideHeader"134const _actionType_name = "actIgnoreactStartactClickactInvalidactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactCancelactChangeBorderLabelactChangeListLabelactChangeInputLabelactChangeHeaderactChangeHeaderLabelactChangeMultiactChangePreviewLabelactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactKillLineactKillWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleMultiLineactToggleHscrollactTrackCurrentactUntrackCurrentactDownactUpactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTransformactTransformBorderLabelactTransformListLabelactTransformInputLabelactTransformHeaderactTransformHeaderLabelactTransformPreviewLabelactTransformPromptactTransformQueryactPreviewactChangePreviewactChangePreviewWindowactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactBecomeactShowHeaderactHideHeader"135134var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 42, 50, 68, 76, 85, 102, 123, 138, 159, 183, 198, 207, 227, 245, 264, 279, 293, 314, 329, 343, 357, 370, 387, 395, 408, 424, 436, 444, 458, 472, 483, 494, 512, 529, 536, 555, 567, 581, 590, 605, 617, 630, 641, 652, 664, 678, 699, 714, 727, 745, 761, 776, 793, 800, 805, 814, 825, 836, 849, 864, 875, 888, 903, 910, 923, 936, 953, 968, 981, 995, 1009, 1025, 1045, 1057, 1080, 1101, 1123, 1141, 1165, 1183, 1200, 1210, 1226, 1248, 1261, 1277, 1289, 1303, 1319, 1337, 1357, 1379, 1393, 1408, 1416, 1422, 1436, 1451, 1461, 1477, 1492, 1502, 1510, 1517, 1526, 1539, 1555, 1570, 1579, 1590, 1599, 1608, 1617, 1630, 1643}136var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 42, 50, 68, 76, 85, 102, 123, 138, 159, 183, 198, 207, 227, 245, 264, 279, 299, 313, 334, 349, 363, 377, 390, 407, 415, 428, 444, 456, 464, 478, 492, 503, 514, 532, 549, 556, 575, 587, 601, 610, 625, 637, 650, 661, 672, 684, 698, 719, 734, 747, 765, 781, 796, 813, 820, 825, 834, 845, 856, 869, 884, 895, 908, 923, 930, 943, 956, 973, 988, 1001, 1015, 1029, 1045, 1065, 1077, 1100, 1121, 1143, 1161, 1184, 1208, 1226, 1243, 1253, 1269, 1291, 1304, 1320, 1332, 1346, 1362, 1380, 1400, 1422, 1436, 1451, 1459, 1465, 1479, 1494, 1504, 1520, 1535, 1545, 1553, 1560, 1569, 1582, 1598, 1613, 1622, 1633, 1642, 1651, 1660, 1673, 1686}137138func (i actionType) String() string {139 if i < 0 || i >= actionType(len(_actionType_index)-1) {140 return "actionType(" + strconv.FormatInt(int64(i), 10) + ")"
3 unmodified lines
modified:src/options.go+145 added-100 removed
101 unmodified lines
102 --input-label-pos=COL Position of the input label103 [POSITIVE_INTEGER: columns from left|104 NEGATIVE_INTEGER: columns from right][:bottom]105 (default: 0 or center)106 --header-border[=STYLE] Draw border around the header section107 [rounded|sharp|bold|block|thinblock|double|horizontal|vertical|108 top|bottom|left|right|none] (default: rounded)109 --header-label=LABEL Label to print on the header border110 --header-label-pos=COL Position of the header label111 [POSITIVE_INTEGER: columns from left|112 NEGATIVE_INTEGER: columns from right][:bottom]113 (default: 0 or center)114 --margin=MARGIN Screen margin (TRBL | TB,RL | T,RL,B | T,R,B,L)115 --padding=PADDING Padding inside border (TRBL | TB,RL | T,RL,B | T,R,B,L)116 --info=STYLE Finder info style117 [default|right|hidden|inline[-right][:PREFIX]]
356 unmodified lines
474}475476// Options stores the values of command-line options477type Options struct {470 Input chan string471 Output chan string472 NoWinpty bool473 Tmux *tmuxOptions474 ForceTtyIn bool475 ProxyScript string476 Bash bool477 Zsh bool478 Fish bool479 Man bool480 Fuzzy bool481 FuzzyAlgo algo.Algo482 Scheme string483 Extended bool484 Phony bool485 Case Case486 Normalize bool487 Nth []Range488 WithNth []Range489 Delimiter Delimiter490 Sort int491 Track trackOption492 Tac bool493 Tail int494 Criteria []criterion495 Multi int496 Ansi bool497 Mouse bool498 Theme *tui.ColorTheme499 Black bool500 Bold bool501 Height heightSpec502 MinHeight int503 Layout layoutType504 Cycle bool505 Wrap bool506 WrapSign *string507 MultiLine bool508 CursorLine bool509 KeepRight bool510 Hscroll bool511 HscrollOff int512 ScrollOff int513 FileWord bool514 InfoStyle infoStyle515 InfoPrefix string516 InfoCommand string517 Separator *string518 JumpLabels string519 Prompt string520 Pointer *string521 Marker *string522 MarkerMulti *[3]string523 Query string524 Select1 bool525 Exit0 bool526 Filter *string527 ToggleSort bool528 Expect map[tui.Event]string529 Keymap map[tui.Event][]*action530 Preview previewOpts531 PrintQuery bool532 ReadZero bool533 Printer func(string)534 PrintSep string535 Sync bool536 History *History537 Header []string538 HeaderLines int539 HeaderFirst bool540 Gap int541 Ellipsis *string542 Scrollbar *string543 Margin [4]sizeSpec544 Padding [4]sizeSpec545 BorderShape tui.BorderShape546 ListBorderShape tui.BorderShape547 InputBorderShape tui.BorderShape548 InputLabel labelOpts549 BorderLabel labelOpts550 ListLabel labelOpts551 PreviewLabel labelOpts552 Unicode bool553 Ambidouble bool554 Tabstop int555 WithShell string556 ListenAddr *listenAddress557 Unsafe bool558 ClearOnExit bool559 WalkerOpts walkerOpts560 WalkerRoot []string561 WalkerSkip []string562 Version bool563 Help bool564 CPUProfile string565 MEMProfile string566 BlockProfile string567 MutexProfile string478 Input chan string479 Output chan string480 NoWinpty bool481 Tmux *tmuxOptions482 ForceTtyIn bool483 ProxyScript string484 Bash bool485 Zsh bool486 Fish bool487 Man bool488 Fuzzy bool489 FuzzyAlgo algo.Algo490 Scheme string491 Extended bool492 Phony bool493 Case Case494 Normalize bool495 Nth []Range496 WithNth []Range497 Delimiter Delimiter498 Sort int499 Track trackOption500 Tac bool501 Tail int502 Criteria []criterion503 Multi int504 Ansi bool505 Mouse bool506 Theme *tui.ColorTheme507 Black bool508 Bold bool509 Height heightSpec510 MinHeight int511 Layout layoutType512 Cycle bool513 Wrap bool514 WrapSign *string515 MultiLine bool516 CursorLine bool517 KeepRight bool518 Hscroll bool519 HscrollOff int520 ScrollOff int521 FileWord bool522 InfoStyle infoStyle523 InfoPrefix string524 InfoCommand string525 Separator *string526 JumpLabels string527 Prompt string528 Pointer *string529 Marker *string530 MarkerMulti *[3]string531 Query string532 Select1 bool533 Exit0 bool534 Filter *string535 ToggleSort bool536 Expect map[tui.Event]string537 Keymap map[tui.Event][]*action538 Preview previewOpts539 PrintQuery bool540 ReadZero bool541 Printer func(string)542 PrintSep string543 Sync bool544 History *History545 Header []string546 HeaderLines int547 HeaderFirst bool548 Gap int549 Ellipsis *string550 Scrollbar *string551 Margin [4]sizeSpec552 Padding [4]sizeSpec553 BorderShape tui.BorderShape554 ListBorderShape tui.BorderShape555 InputBorderShape tui.BorderShape556 HeaderBorderShape tui.BorderShape557 InputLabel labelOpts558 HeaderLabel labelOpts559 BorderLabel labelOpts560 ListLabel labelOpts561 PreviewLabel labelOpts562 Unicode bool563 Ambidouble bool564 Tabstop int565 WithShell string566 ListenAddr *listenAddress567 Unsafe bool568 ClearOnExit bool569 WalkerOpts walkerOpts570 WalkerRoot []string571 WalkerSkip []string572 Version bool573 Help bool574 CPUProfile string575 MEMProfile string576 BlockProfile string577 MutexProfile string578}579580func filterNonEmpty(input []string) []string {581 output := make([]string, 0, len(input))
678 unmodified lines
1260 case "input-border":1261 mergeAttr(&theme.InputBorder)1262 case "input-label":1263 mergeAttr(&theme.InputLabel)1264 case "header-border":1265 mergeAttr(&theme.HeaderBorder)1266 case "header-label":1267 mergeAttr(&theme.HeaderLabel)1268 case "spinner":1269 mergeAttr(&theme.Spinner)1270 case "info":1271 mergeAttr(&theme.Info)1272 case "pointer":1273 mergeAttr(&theme.Cursor)1274 case "marker":1275 mergeAttr(&theme.Marker)1262 case "header":1276 case "header", "header-fg":1277 mergeAttr(&theme.Header)1278 case "header-bg":1279 mergeAttr(&theme.HeaderBg)1280 default:1281 fail()1282 }1283 }
45 unmodified lines
1329)13301331func init() {1332 executeRegexp = regexp.MustCompile(1317 `(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform)-(?:header|query|prompt|border-label|list-label|preview-label|input-label)|transform|change-(?:preview-window|preview|multi)|(?:re|un)bind|pos|put|print)`)1333 `(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform)-(?:query|prompt|(?:border|list|preview|input|header)-label|header)|transform|change-(?:preview-window|preview|multi)|(?:re|un)bind|pos|put|print)`)1334 splitRegexp = regexp.MustCompile("[,:]+")1335 actionNameRegexp = regexp.MustCompile("(?i)^[a-z-]+")1336}1337
357 unmodified lines
1695 case "change-preview-label":1696 return actChangePreviewLabel1697 case "change-input-label":1698 return actChangeInputLabel1699 case "change-header-label":1700 return actChangeHeaderLabel1701 case "change-preview-window":1702 return actChangePreviewWindow1703 case "change-preview":1704 return actChangePreview
24 unmodified lines
1729 case "transform-preview-label":1730 return actTransformPreviewLabel1731 case "transform-input-label":1732 return actTransformInputLabel1733 case "transform-header-label":1734 return actTransformHeaderLabel1735 case "transform-header":1736 return actTransformHeader1737 case "transform-prompt":1738 return actTransformPrompt
822 unmodified lines
2561 }2562 if err := parseLabelPosition(&opts.ListLabel, pos); err != nil {2563 return err2564 }2565 case "--no-header-border":2566 opts.HeaderBorderShape = tui.BorderNone2567 case "--header-border":2568 hasArg, arg := optionalNextString(allArgs, &i)2569 if opts.HeaderBorderShape, err = parseBorder(arg, !hasArg); err != nil {2570 return err2571 }2572 case "--no-header-label":2573 opts.HeaderLabel.label = ""2574 case "--header-label":2575 if opts.HeaderLabel.label, err = nextString(allArgs, &i, "header label required"); err != nil {2576 return err2577 }2578 case "--header-label-pos":2579 pos, err := nextString(allArgs, &i, "header label position required (positive or negative integer or 'center')")2580 if err != nil {2581 return err2582 }2583 if err := parseLabelPosition(&opts.HeaderLabel, pos); err != nil {2584 return err2585 }2586 case "--no-input-border":2587 opts.InputBorderShape = tui.BorderNone2588 case "--input-border":2589 hasArg, arg := optionalNextString(allArgs, &i)
453 unmodified lines
3043 if opts.InputBorderShape == tui.BorderUndefined {3044 opts.InputBorderShape = tui.BorderNone3045 }30463047 if opts.HeaderBorderShape == tui.BorderUndefined {3048 opts.HeaderBorderShape = tui.BorderNone3049 }30503051 if opts.Pointer == nil {3052 defaultPointer := "▌"3053 if !opts.Unicode {3054 defaultPointer = ">"
201 unmodified lines
modified:src/terminal.go+190 added-64 removed
178 unmodified lines
179 other bool180}181182func (t *Terminal) markEmptyLine(line int) {183 if t.window != t.inputWindow {183 if t.window != t.inputWindow && t.window != t.headerWindow {184 t.prevLines[line] = itemLine{valid: true, firstLine: line, empty: true}185 }186}187188func (t *Terminal) markOtherLine(line int) {189 if t.window != t.inputWindow {189 if t.window != t.inputWindow && t.window != t.headerWindow {190 t.prevLines[line] = itemLine{valid: true, firstLine: line, other: true}191 }192}193
54 unmodified lines
248 previewLabelOpts labelOpts249 inputLabel labelPrinter250 inputLabelLen int251 inputLabelOpts labelOpts252 headerLabel labelPrinter253 headerLabelLen int254 headerLabelOpts labelOpts255 pointer string256 pointerLen int257 pointerEmpty string258 marker string
50 unmodified lines
309 listenUnsafe bool310 borderShape tui.BorderShape311 listBorderShape tui.BorderShape312 inputBorderShape tui.BorderShape313 headerBorderShape tui.BorderShape314 listLabel labelPrinter315 listLabelLen int316 listLabelOpts labelOpts317 cleanExit bool
2 unmodified lines
320 border tui.Window321 window tui.Window322 inputWindow tui.Window323 inputBorder tui.Window324 headerWindow tui.Window325 headerBorder tui.Window326 wborder tui.Window327 pborder tui.Window328 pwindow tui.Window329 borderWidth int
81 unmodified lines
411 reqReinit412 reqFullRedraw413 reqResize414 reqRedrawInputLabel415 reqRedrawHeaderLabel416 reqRedrawListLabel417 reqRedrawBorderLabel418 reqRedrawPreviewLabel419 reqClose
36 unmodified lines
456 actChangeBorderLabel457 actChangeListLabel458 actChangeInputLabel459 actChangeHeader460 actChangeHeaderLabel461 actChangeMulti462 actChangePreviewLabel463 actChangePrompt464 actChangeQuery
54 unmodified lines
519 actTransformBorderLabel520 actTransformListLabel521 actTransformInputLabel522 actTransformHeader523 actTransformHeaderLabel524 actTransformPreviewLabel525 actTransformPrompt526 actTransformQuery527 actPreview
327 unmodified lines
855 listenUnsafe: opts.Unsafe,856 borderShape: opts.BorderShape,857 listBorderShape: opts.ListBorderShape,858 inputBorderShape: opts.InputBorderShape,859 headerBorderShape: opts.HeaderBorderShape,860 borderWidth: 1,861 listLabel: nil,862 listLabelOpts: opts.ListLabel,863 borderLabel: nil,
1 unmodified line
865 previewLabel: nil,866 previewLabelOpts: opts.PreviewLabel,867 inputLabel: nil,868 inputLabelOpts: opts.InputLabel,869 headerLabel: nil,870 headerLabelOpts: opts.HeaderLabel,871 cleanExit: opts.ClearOnExit,872 executor: executor,873 paused: opts.Phony,874 cycle: opts.Cycle,
46 unmodified lines
921 lastAction: actStart,922 lastFocus: minItem.Index()}923924 // This should be called before accessing tui.Color*913 tui.InitTheme(opts.Theme, renderer.DefaultTheme(), opts.Black)925 tui.InitTheme(opts.Theme, renderer.DefaultTheme(), opts.Black, opts.InputBorderShape.Visible(), opts.HeaderBorderShape.Visible())926927 t.prompt, t.promptLen = t.parsePrompt(opts.Prompt)928 // Pre-calculated empty pointer and marker signs929 t.pointerEmpty = strings.Repeat(" ", t.pointerLen)
1 unmodified line
931 t.listLabel, t.listLabelLen = t.ansiLabelPrinter(opts.ListLabel.label, &tui.ColListLabel, false)932 t.borderLabel, t.borderLabelLen = t.ansiLabelPrinter(opts.BorderLabel.label, &tui.ColBorderLabel, false)933 t.previewLabel, t.previewLabelLen = t.ansiLabelPrinter(opts.PreviewLabel.label, &tui.ColPreviewLabel, false)934 t.inputLabel, t.inputLabelLen = t.ansiLabelPrinter(opts.InputLabel.label, &tui.ColInputLabel, false)935 t.headerLabel, t.headerLabelLen = t.ansiLabelPrinter(opts.HeaderLabel.label, &tui.ColHeaderLabel, false)936937 // Disable separator by default if input border is set938 if opts.Separator == nil && !t.inputBorderShape.Visible() || opts.Separator != nil && len(*opts.Separator) > 0 {939 bar := "─"
136 unmodified lines
1076 }1077 return len(t.header0) + t.headerLines1078}10791080func (t *Terminal) visibleHeaderLinesInList() int {1081 if t.headerWindow != nil {1082 return 01083 }1084 return t.visibleHeaderLines()1085}10861087// Extra number of lines needed to display fzf1088func (t *Terminal) extraLines() int {1089 extra := t.visibleHeaderLines() + 11090 if t.inputBorderShape.Visible() {
76 unmodified lines
1167}11681169// Temporarily switch 'window' so that we can use the existing windows with1170// a different window1151func (t *Terminal) withInputWindow(f func()) {1171func (t *Terminal) withWindow(w tui.Window, f func()) {1172 prevWindow := t.window1153 if t.inputWindow != nil {1154 t.window = t.inputWindow1173 if w != nil {1174 t.window = w1175 }1176 f()1177 t.window = prevWindow1178}
24 unmodified lines
1203 }1204 output := func() {1205 wrap := t.wrap1206 t.wrap = false1187 t.withInputWindow(func() {1207 t.withWindow(t.inputWindow, func() {1208 line := t.promptLine()1209 t.printHighlighted(1210 Result{item: item}, tui.ColPrompt, tui.ColPrompt, false, false, line, line, true, nil, nil)1211 })
412 unmodified lines
1624 }1625 if t.wborder != nil {1626 t.wborder = nil1627 }1628 if t.headerWindow != nil {1629 t.headerWindow = nil1630 }1631 if t.headerBorder != nil {1632 t.headerBorder = nil1633 }1634 if t.inputWindow != nil {1635 t.inputWindow = nil1636 }1637 if t.inputBorder != nil {
38 unmodified lines
1676 width -= paddingInt[1] + paddingInt[3]1677 height -= paddingInt[0] + paddingInt[2]16781679 // Adjust position and size of the list window if input border is set1654 inputWindowHeight := 01680 inputBorderHeight := 01681 availableLines := height1682 shift := 01683 shrink := 01658 hasInputWindow := t.inputBorderShape.Visible()1684 hasInputWindow := t.inputBorderShape.Visible() || t.headerBorderShape.Visible()1685 if hasInputWindow {1660 inputWindowHeight = 21686 inputWindowHeight := 21687 if t.noSeparatorLine() {1688 inputWindowHeight--1689 }1664 inputBorderHeight = borderLines(t.inputBorderShape) + inputWindowHeight1690 inputBorderHeight = util.Min(availableLines, borderLines(t.inputBorderShape)+inputWindowHeight)1691 if t.layout == layoutReverse {1692 shift = inputBorderHeight1693 shrink = inputBorderHeight1694 } else {1669 shift = 01695 shrink = inputBorderHeight1696 }1697 availableLines -= inputBorderHeight1698 }16991700 // Adjust position and size of the list window if header border is set1701 hasHeaderWindow := t.visibleHeaderLines() > 0 && (t.headerBorderShape.Visible() || t.inputBorderShape.Visible())1702 headerBorderHeight := 01703 if hasHeaderWindow {1704 headerWindowHeight := t.visibleHeaderLines()1705 headerBorderHeight = util.Min(availableLines, borderLines(t.headerBorderShape)+headerWindowHeight)1706 if t.layout == layoutReverse {1707 shift += headerBorderHeight1708 shrink += headerBorderHeight1709 } else {1710 shrink += headerBorderHeight1711 }1712 availableLines -= headerBorderHeight1713 }17141715 // Set up list border1716 hasListBorder := t.listBorderShape.Visible()1717 innerWidth := width1718 innerHeight := height1719 innerMarginInt := marginInt
50 unmodified lines
1770 if len(t.scrollbar) > 0 && !previewOpts.border.HasRight() {1771 // Need a column to show scrollbar1772 pwidth -= 11773 }1732 pwidth = util.Max(0, pwidth)1733 pheight = util.Max(0, pheight)1774 t.pwindow = t.tui.NewWindow(y, x, pwidth, pheight, tui.WindowPreview, noBorder, true)1775 if !hadPreviewWindow {1776 t.pwindow.Erase()1777 }
21 unmodified lines
1799 }1800 if previewOpts.hidden {1801 return1802 }18031804 maxPreviewLines := availableLines1805 if t.wborder != nil {1806 maxPreviewLines -= t.wborder.Height()1807 } else {1808 maxPreviewLines -= util.Max(0, innerHeight-pheight-shrink)1809 }1810 pheight = util.Min(pheight, maxPreviewLines)1811 if previewOpts.position == posUp {1812 innerBorderFn(marginInt[0]+pheight, marginInt[3], width, height-pheight)1813 t.window = t.tui.NewWindow(1814 innerMarginInt[0]+pheight+shift, innerMarginInt[3], innerWidth, innerHeight-pheight-shrink, tui.WindowList, noBorder, true)
105 unmodified lines
1920 innerWidth,1921 innerHeight-shrink, tui.WindowList, noBorder, true)1922 }19231876 // Set up input border1877 if hasInputWindow {1878 w := t.wborder1879 if t.wborder == nil {1880 w = t.window1881 }1882 if t.layout == layoutReverse {1883 t.inputBorder = t.tui.NewWindow(1884 w.Top()-shrink,1885 w.Left(),1886 w.Width(),1887 util.Min(shrink, screenHeight), tui.WindowInput, tui.MakeBorderStyle(t.inputBorderShape, t.unicode), true)1888 } else {1889 t.inputBorder = t.tui.NewWindow(1890 w.Top()+w.Height(),1891 w.Left(),1892 w.Width(),1893 util.Min(shrink, screenHeight), tui.WindowInput, tui.MakeBorderStyle(t.inputBorderShape, t.unicode), true)1894 }1895 top := t.inputBorder.Top()1896 left := t.inputBorder.Left()1897 if t.inputBorderShape.HasTop() {1924 createInnerWindow := func(b tui.Window, shape tui.BorderShape, windowType tui.WindowType) tui.Window {1925 top := b.Top()1926 left := b.Left()1927 if shape.HasTop() {1928 top++1929 }1900 if t.inputBorderShape.HasLeft() {1930 if shape.HasLeft() {1931 left += t.borderWidth + 11932 }1903 width := t.inputBorder.Width() - borderColumns(t.inputBorderShape, t.borderWidth)1904 if t.inputBorderShape.HasRight() {1933 width := b.Width() - borderColumns(shape, t.borderWidth)1934 if shape.HasRight() {1935 width++1936 }1907 t.inputWindow = t.tui.NewWindow(1908 top,1909 left,1910 width,1911 t.inputBorder.Height()-borderLines(t.inputBorderShape),1912 tui.WindowInput, noBorder, true)1937 height := b.Height() - borderLines(shape)1938 return t.tui.NewWindow(top, left, width, height, windowType, noBorder, true)1939 }19401941 // Set up input border1942 w := t.wborder1943 if t.wborder == nil {1944 w = t.window1945 }1946 if hasInputWindow {1947 var btop int1948 if hasHeaderWindow && t.headerFirst {1949 if t.layout == layoutReverse {1950 btop = w.Top() - inputBorderHeight1951 } else {1952 btop = w.Top() + w.Height()1953 }1954 } else {1955 if t.layout == layoutReverse {1956 btop = w.Top() - shrink1957 } else {1958 btop = w.Top() + w.Height() + headerBorderHeight1959 }1960 }1961 t.inputBorder = t.tui.NewWindow(1962 btop,1963 w.Left(),1964 w.Width(),1965 inputBorderHeight, tui.WindowInput, tui.MakeBorderStyle(t.inputBorderShape, t.unicode), true)1966 t.inputWindow = createInnerWindow(t.inputBorder, t.inputBorderShape, tui.WindowInput)1967 }19681969 // Set up header border1970 if hasHeaderWindow {1971 var btop int1972 if hasInputWindow && t.headerFirst {1973 if t.layout == layoutReverse {1974 btop = w.Top() - shrink1975 } else {1976 btop = w.Top() + w.Height() + inputBorderHeight1977 }1978 } else {1979 if t.layout == layoutReverse {1980 btop = w.Top() - headerBorderHeight1981 } else {1982 btop = w.Top() + w.Height()1983 }1984 }1985 t.headerBorder = t.tui.NewWindow(1986 btop,1987 w.Left(),1988 w.Width(),1989 headerBorderHeight, tui.WindowHeader, tui.MakeBorderStyle(t.headerBorderShape, t.unicode), true)1990 t.headerWindow = createInnerWindow(t.headerBorder, t.headerBorderShape, tui.WindowHeader)1991 }19921993 // Print border label1994 t.printLabel(t.wborder, t.listLabel, t.listLabelOpts, t.listLabelLen, t.listBorderShape, false)1995 t.printLabel(t.border, t.borderLabel, t.borderLabelOpts, t.borderLabelLen, t.borderShape, false)1996 t.printLabel(t.pborder, t.previewLabel, t.previewLabelOpts, t.previewLabelLen, t.activePreviewOpts.border, false)1997 t.printLabel(t.inputBorder, t.inputLabel, t.inputLabelOpts, t.inputLabelLen, t.inputBorderShape, false)1998 t.printLabel(t.headerBorder, t.headerLabel, t.headerLabelOpts, t.headerLabelLen, t.headerBorderShape, false)1999}20002001func (t *Terminal) printLabel(window tui.Window, render labelPrinter, opts labelOpts, length int, borderShape tui.BorderShape, redrawBorder bool) {2002 if window == nil {
35 unmodified lines
2038 switch t.layout {2039 case layoutDefault:2040 y = h - y - 12041 case layoutReverseList:1963 n := 2 + t.visibleHeaderLines()2042 n := 2 + t.visibleHeaderLinesInList()2043 if t.noSeparatorLine() {2044 n--2045 }2046 if y < n {
45 unmodified lines
2092 }2093 if !t.noSeparatorLine() {2094 max--2095 }2017 return util.Min(t.visibleHeaderLines(), max)2096 return util.Min(t.visibleHeaderLinesInList(), max)2097 }2098 return 02099}2100
36 unmodified lines
2137 return string(runes) + strings.Repeat(".", util.Constrain(maxWidth, 0, 2))2138}21392140func (t *Terminal) printInfo() {2062 t.withInputWindow(func() {2063 t.printInfoImpl()2064 })2141 t.withWindow(t.inputWindow, func() { t.printInfoImpl() })2142}21432144func (t *Terminal) printInfoImpl() {2145 if t.window.Width() <= 1 || t.window.Height() == 0 {
188 unmodified lines
2334 }2335}23362337func (t *Terminal) printHeader() {2338 headerLines := t.visibleHeaderLines()2339 if t.headerBorderShape.Visible() && (t.headerWindow == nil && headerLines > 0 || t.headerWindow != nil && headerLines != t.headerWindow.Height()) {2340 t.resizeWindows(false, true)2341 t.printList()2342 t.printPrompt()2343 t.printInfo()2344 t.printPreview()2345 }2346 t.withWindow(t.headerWindow, func() { t.printHeaderImpl() })2347}23482349func (t *Terminal) printHeaderImpl() {2350 if t.visibleHeaderLines() == 0 {2351 return2352 }2353 max := t.window.Height()2265 if t.inputWindow == nil && t.headerFirst {2354 if t.inputWindow == nil && t.headerWindow == nil && t.headerFirst {2355 max--2356 if !t.noSeparatorLine() {2357 max--2358 }
5 unmodified lines
2364 needReverse = true2365 }2366 // Wrapping is not supported for header2367 wrap := t.wrap2368 indent := strings.Repeat(" ", t.pointerLen+t.markerLen)2369 t.wrap = false2370 for idx, lineStr := range append(append([]string{}, t.header0...), t.header...) {2371 line := idx2372 if needReverse && idx < len(t.header0) {2373 line = len(t.header0) - idx - 12374 }2285 if t.inputWindow == nil && !t.headerFirst {2375 if t.inputWindow == nil && t.headerWindow == nil && !t.headerFirst {2376 line++2377 if !t.noSeparatorLine() {2378 line++2379 }
8 unmodified lines
2388 colors: colors}23892390 t.printHighlighted(Result{item: item},2391 tui.ColHeader, tui.ColHeader, false, false, line, line, true,2302 func(markerClass) { t.window.Print(strings.Repeat(" ", t.pointerLen+t.markerLen)) }, nil)2392 func(markerClass) { t.window.Print(indent) }, nil)2393 }2394 t.wrap = wrap2395}2396
19 unmodified lines
2416 maxy := t.maxItems() - 12417 count := t.merger.Length() - t.offset24182419 // Start line2330 startLine := t.promptLines() + t.visibleHeaderLines()2420 startLine := t.promptLines() + t.visibleHeaderLinesInList()2421 maxy += startLine24222423 barRange := [2]int{startLine + barStart, startLine + barStart + barLength}2424 for line, itemCount := startLine, 0; line <= maxy; line, itemCount = line+1, itemCount+1 {
851 unmodified lines
32763277func (t *Terminal) flush() {3278 t.placeCursor()3279 if !t.suppress {3190 windows := make([]tui.Window, 0, 7)3280 windows := make([]tui.Window, 0, 9)3281 if t.border != nil {3282 windows = append(windows, t.border)3283 }3284 if t.pborder != nil {
7 unmodified lines
3292 }3293 if t.window != nil {3294 windows = append(windows, t.window)3295 }3296 if t.headerBorder != nil {3297 windows = append(windows, t.headerBorder)3298 }3299 if t.headerWindow != nil {3300 windows = append(windows, t.headerWindow)3301 }3302 if t.inputBorder != nil {3303 windows = append(windows, t.inputBorder)3304 }3305 if t.inputWindow != nil {
899 unmodified lines
4205 t.previewBox.Set(reqPreviewReady, nil)4206 }4207 case reqRedrawInputLabel:4208 t.printLabel(t.inputBorder, t.inputLabel, t.inputLabelOpts, t.inputLabelLen, t.inputBorderShape, true)4209 case reqRedrawHeaderLabel:4210 t.printLabel(t.headerBorder, t.headerLabel, t.headerLabelOpts, t.headerLabelLen, t.headerBorderShape, true)4211 case reqRedrawListLabel:4212 t.printLabel(t.wborder, t.listLabel, t.listLabelOpts, t.listLabelLen, t.listBorderShape, true)4213 case reqRedrawBorderLabel:4214 t.printLabel(t.border, t.borderLabel, t.borderLabelOpts, t.borderLabelLen, t.borderShape, true)
375 unmodified lines
4590 req(reqHeader, reqList, reqPrompt, reqInfo)4591 } else {4592 req(reqHeader)4593 }4594 case actChangeHeaderLabel:4595 t.headerLabelOpts.label = a.a4596 if t.headerBorder != nil {4597 t.headerLabel, t.headerLabelLen = t.ansiLabelPrinter(a.a, &tui.ColHeaderLabel, false)4598 req(reqRedrawHeaderLabel)4599 }4600 case actChangeInputLabel:4601 t.inputLabelOpts.label = a.a4602 if t.inputBorder != nil {4603 t.inputLabel, t.inputLabelLen = t.ansiLabelPrinter(a.a, &tui.ColInputLabel, false)
21 unmodified lines
4625 body := t.executeCommand(a.a, false, true, true, false, "")4626 if actions, err := parseSingleActionList(strings.Trim(body, "\r\n")); err == nil {4627 return doActions(actions)4628 }4629 case actTransformHeaderLabel:4630 label := t.executeCommand(a.a, false, true, true, true, "")4631 t.headerLabelOpts.label = label4632 if t.headerBorder != nil {4633 t.headerLabel, t.headerLabelLen = t.ansiLabelPrinter(label, &tui.ColHeaderLabel, false)4634 req(reqRedrawHeaderLabel)4635 }4636 case actTransformInputLabel:4637 label := t.executeCommand(a.a, false, true, true, true, "")4638 t.inputLabelOpts.label = label4639 if t.inputBorder != nil {
498 unmodified lines
5138 switch t.activePreviewOpts.position {5139 case posUp:5140 if t.pborder.Enclose(my, mx) && my == t.pborder.Top()+t.pborder.Height()-1 {5141 pborderDragging = 05031 } else if t.listBorderShape.HasTop() && t.wborder.Enclose(my, mx) && my == t.wborder.Top() {5142 } else if t.listBorderShape.HasTop() && t.pborder.EncloseX(mx) && my == t.wborder.Top() {5143 pborderDragging = 15144 }5145 case posDown:5146 if t.pborder.Enclose(my, mx) && my == t.pborder.Top() {5147 pborderDragging = 05037 } else if t.listBorderShape.HasBottom() && t.wborder.Enclose(my, mx) && my == t.wborder.Top()+t.wborder.Height()-1 {5148 } else if t.listBorderShape.HasBottom() && t.pborder.EncloseX(mx) && my == t.wborder.Top()+t.wborder.Height()-1 {5149 pborderDragging = 15150 }5151 case posLeft:5152 if t.pborder.Enclose(my, mx) && mx == t.pborder.Left()+t.pborder.Width()-1 {5153 pborderDragging = 05043 } else if t.listBorderShape.HasLeft() && t.wborder.Enclose(my, mx) && mx == t.wborder.Left() {5154 } else if t.listBorderShape.HasLeft() && t.pborder.EncloseY(my) && mx == t.wborder.Left() {5155 pborderDragging = 15156 }5157 case posRight:5158 if t.pborder.Enclose(my, mx) && mx == t.pborder.Left() {5159 pborderDragging = 05049 } else if t.listBorderShape.HasRight() && t.wborder.Enclose(my, mx) && mx == t.wborder.Left()+t.wborder.Width()-1 {5160 } else if t.listBorderShape.HasRight() && t.pborder.EncloseY(my) && mx == t.wborder.Left()+t.wborder.Width()-1 {5161 pborderDragging = 15162 }5163 }5164 }
48 unmodified lines
5213 }5214 break5215 }52165217 // Inside the header window5218 // TODO: Should we trigger this on mouse up instead?5219 // Should we still trigger it when the position has changed from the down event?5220 if t.headerVisible && t.headerWindow != nil && t.headerWindow.Enclose(my, mx) {5221 mx -= t.headerWindow.Left() + t.pointerLen + t.markerLen5222 my -= t.headerWindow.Top()5223 if mx < 0 {5224 break5225 }5226 t.clickHeaderLine = my + 15227 t.clickHeaderColumn = mx + 15228 return doActions(actionsFor(tui.ClickHeader))5229 }52305231 // Ignored5232 if !t.window.Enclose(my, mx) && !barDragging {5233 break5234 }52355236 // Translate coordinates5237 mx -= t.window.Left()5238 my -= t.window.Top()5114 min := t.promptLines() + t.visibleHeaderLines()5239 min := t.promptLines() + t.visibleHeaderLinesInList()5240 h := t.window.Height()5241 switch t.layout {5242 case layoutDefault:5243 my = h - my - 1
60 unmodified lines
5304 evt = tui.SLeftClick5305 }5306 }5307 return doActions(actionsFor(evt))5183 } else if t.headerVisible {5308 } else if t.headerVisible && t.headerWindow == nil {5309 // Header5310 // TODO: Should we trigger this on mouse up instead?5185 numLines := t.visibleHeaderLines()5311 numLines := t.visibleHeaderLinesInList()5312 lineOffset := 05313 if t.inputWindow == nil && !t.headerFirst {5314 // offset for info line5315 if t.noSeparatorLine() {
2 unmodified lines
5318 lineOffset = 25319 }5320 }5321 my -= lineOffset5196 mx -= 2 // offset gutter5322 mx -= t.pointerLen + t.markerLen5323 if my >= 0 && my < numLines && mx >= 0 {5324 if t.layout == layoutReverse {5325 t.clickHeaderLine = my + 15326 } else {
323 unmodified lines
5650}56515652// Number of item lines in the list window5653func (t *Terminal) maxItems() int {5528 max := t.window.Height() - t.visibleHeaderLines() - t.promptLines()5654 max := t.window.Height() - t.visibleHeaderLinesInList() - t.promptLines()5655 return util.Max(max, 0)5656}56575658func (t *Terminal) dumpItem(i *Item) StatusItem {
65 unmodified lines
modified:test/test_go.rb+193 added-14 removed
3483 unmodified lines
3484 BLOCK3485 tmux.until { assert_block(block, _1) }3486 end34873488 def test_input_border_and_label_header_first3489 tmux.send_keys %(seq 100 | #{FZF} --border rounded --input-border bold --input-label input --input-label-pos 2 --header-lines 3 --query 1 --padding 1,2 --header-first), :Enter3490 block = <<~BLOCK3491 │ 113492 │ > 103493 │ ┏input━━━━━3494 │ ┃ 19/973495 │ ┃ > 13496 │ ┗━━━━━━━━━━3497 │ 33498 │ 23499 │ 13500 │3501 ╰──────────────3502 BLOCK3503 tmux.until { assert_block(block, _1) }3504 end35053506 def test_list_input_border_and_label3507 tmux.send_keys %(3508 seq 100 | #{FZF} --border rounded --list-border double --input-border bold --list-label-pos 2:bottom --input-label-pos 2 --header-lines 3 --query 1 --padding 1,2 \3509 --bind 'start:transform-input-label(echo INPUT)+transform-list-label(echo LIST)' \
1 unmodified line
3511 ).strip, :Enter3512 block = <<~BLOCK3513 │ ║ 113514 │ ║ > 103497 │ ║ 33498 │ ║ 23499 │ ║ 13500 │ ╚LIST═════3501 │ ┏INPUT━━━━3515 │ ╚LIST══════3516 │ 33517 │ 23518 │ 13519 │ ┏INPUT━━━━━3520 │ ┃ 19/973521 │ ┃ > 13504 │ ┗━━━━━━━━━3522 │ ┗━━━━━━━━━━3523 │3506 ╰─────────────3524 ╰──────────────3525 BLOCK3526 tmux.until { assert_block(block, _1) }3527 tmux.send_keys :Space3528 block = <<~BLOCK3529 │ ║ 113530 │ ║ > 103513 │ ║ 33514 │ ║ 23515 │ ║ 13516 │ ╚ list ═══3517 │ ┏ input ━━3531 │ ╚ list ════3532 │ 33533 │ 23534 │ 13535 │ ┏ input ━━━3536 │ ┃ 19/973537 │ ┃ > 13520 │ ┗━━━━━━━━━3538 │ ┗━━━━━━━━━━3539 │3522 ╰─────────────3540 ╰──────────────3541 BLOCK3542 tmux.until { assert_block(block, _1) }3543 end35443545 def test_list_input_border_and_label_header_first3546 tmux.send_keys %(3547 seq 100 | #{FZF} --border rounded --list-border double --input-border bold --list-label-pos 2:bottom --input-label-pos 2 --header-lines 3 --query 1 --padding 1,2 \3548 --bind 'start:transform-input-label(echo INPUT)+transform-list-label(echo LIST)' \3549 --bind 'space:change-input-label( input )+change-list-label( list )' --header-first3550 ).strip, :Enter3551 block = <<~BLOCK3552 │ ║ 113553 │ ║ > 103554 │ ╚LIST══════3555 │ ┏INPUT━━━━━3556 │ ┃ 19/973557 │ ┃ > 13558 │ ┗━━━━━━━━━━3559 │ 33560 │ 23561 │ 13562 │3563 ╰──────────────3564 BLOCK3565 tmux.until { assert_block(block, _1) }3566 tmux.send_keys :Space3567 block = <<~BLOCK3568 │ ║ 113569 │ ║ > 103570 │ ╚ list ════3571 │ ┏ input ━━━3572 │ ┃ 19/973573 │ ┃ > 13574 │ ┗━━━━━━━━━━3575 │ 33576 │ 23577 │ 13578 │3579 ╰──────────────3580 BLOCK3581 tmux.until { assert_block(block, _1) }3582 end35833584 def test_header_border_and_label3585 tmux.send_keys %(seq 100 | #{FZF} --border rounded --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2), :Enter3586 block = <<~BLOCK3587 │ 123588 │ 113589 │ > 103590 │ ┌────────3591 │ │ 33592 │ │ 23593 │ │ 13594 │ └header──3595 │ 19/97 ─3596 │ > 13597 │3598 ╰────────────3599 BLOCK3600 tmux.until { assert_block(block, _1) }3601 end36023603 def test_header_border_and_label_header_first3604 tmux.send_keys %(seq 100 | #{FZF} --border rounded --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --header-first), :Enter3605 block = <<~BLOCK3606 │ 123607 │ 113608 │ > 103609 │ 19/97 ─3610 │ > 13611 │ ┌────────3612 │ │ 33613 │ │ 23614 │ │ 13615 │ └header──3616 │3617 ╰────────────3618 BLOCK3619 tmux.until { assert_block(block, _1) }3620 end36213622 def test_header_border_and_label_with_list_border3623 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2), :Enter3624 block = <<~BLOCK3625 │ ║ 123626 │ ║ 113627 │ ║ > 103628 │ ╚list════3629 │ ┌────────3630 │ │ 33631 │ │ 23632 │ │ 13633 │ └header──3634 │ 19/97 ─3635 │ > 13636 │3637 ╰────────────3638 BLOCK3639 tmux.until { assert_block(block, _1) }3640 end36413642 def test_header_border_and_label_with_list_border_header_first3643 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --header-first), :Enter3644 block = <<~BLOCK3645 │ ║ 123646 │ ║ 113647 │ ║ > 103648 │ ╚list════3649 │ 19/97 ─3650 │ > 13651 │ ┌────────3652 │ │ 33653 │ │ 23654 │ │ 13655 │ └header──3656 │3657 ╰────────────3658 BLOCK3659 tmux.until { assert_block(block, _1) }3660 end36613662 def test_all_borders3663 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --input-border bold --input-label input --input-label-pos 2:bottom), :Enter3664 block = <<~BLOCK3665 │ ║ 123666 │ ║ 113667 │ ║ > 103668 │ ╚list══════3669 │ ┌──────────3670 │ │ 33671 │ │ 23672 │ │ 13673 │ └header────3674 │ ┏━━━━━━━━━━3675 │ ┃ 19/973676 │ ┃ > 13677 │ ┗input━━━━━3678 │3679 ╰──────────────3680 BLOCK3681 tmux.until { assert_block(block, _1) }3682 end36833684 def test_all_borders_header_first3685 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --input-border bold --input-label input --input-label-pos 2:bottom --header-first), :Enter3686 block = <<~BLOCK3687 │ ║ 123688 │ ║ 113689 │ ║ > 103690 │ ╚list══════3691 │ ┏━━━━━━━━━━3692 │ ┃ 19/973693 │ ┃ > 13694 │ ┗input━━━━━3695 │ ┌──────────3696 │ │ 33697 │ │ 23698 │ │ 13699 │ └header────3700 │3701 ╰──────────────3702 BLOCK3703 tmux.until { assert_block(block, _1) }3704 end3705end37063707module TestShell3708 def setup
537 unmodified lines
modified:CHANGELOG.md+14 added-1 removed
14 unmodified lines
15 - `list-label`16 - Actions17 - `change-list-label`18 - `transform-list-label`19- Border and label for the input section (prompt and info)19- Border and label for the input section (prompt line and info line)20 - Options21 - `--input-border[=STYLE]`22 - `--input-label=LABEL`23 - `--input-label-pos=COL[:bottom]`
4 unmodified lines
28 - `input-label`29 - Actions30 - `change-input-label`31 - `transform-input-label`32- Border and label for the header section33 - Options34 - `--header-border[=STYLE]`35 - `--header-label=LABEL`36 - `--header-label-pos=COL[:bottom]`37 - Colors38 - `header-fg` (`header`)39 - `header-bg`40 - `header-border`41 - `header-label`42 - Actions43 - `change-header-label`44 - `transform-header-label`45- Added `--preview-border[=STYLE]` as short for `--preview-window=border[-STYLE]`46- You can specify `border-native` to `--tmux` so that native tmux border is used instead of `--border`. This can be useful if you start a different program from inside the popup.47 ```sh48 fzf --tmux border-native --bind 'enter:execute:less {}'
2333 unmodified lines