Skip to content
Myr

Fix header window location and size

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

authored by Junegunn Choi · committed by Junegunn Choi · parent fb88565 · Browse files · 2 files+35 added−41 removed
This commit

State

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

Diff stats

2 files+35 added−41 removed

  • other:+35 added−41 removed

2 files+35 added−41 removed

modified:man/man1/fzf.1+1 added-1 removed
929 unmodified lines
930Position of the header label931932.TP933.BI "\-\-header\-lines\-border" [=STYLE]934Display header from \fB--header-lines\fR with a separate border. Pass934Display header from \fB--header\-lines\fR with a separate border. Pass935\fBnone\fR to still separate the header lines but without a border. To combine936two headers, use \fB\-\-no\-header\-lines\-border\fR.937938.SS SCRIPTING
871 unmodified lines
modified:src/terminal.go+34 added-40 removed
2017 unmodified lines
2018 innerWidth,2019 innerHeight-shrink, tui.WindowList, noBorder, true)2020 }20212022 createInnerWindow := func(b tui.Window, shape tui.BorderShape, windowType tui.WindowType) tui.Window {2022 createInnerWindow := func(b tui.Window, shape tui.BorderShape, windowType tui.WindowType, shift int) tui.Window {2023 top := b.Top()2024 left := b.Left()2024 left := b.Left() + shift2025 if shape.HasTop() {2026 top++2027 }2028 if shape.HasLeft() {2029 left += t.borderWidth + 12030 }2031 width := b.Width() - borderColumns(shape, t.borderWidth)2031 width := b.Width() - borderColumns(shape, t.borderWidth) - shift2032 if shape.HasRight() {2033 width++2034 }2035 height := b.Height() - borderLines(shape)
19 unmodified lines
2055 } else {2056 btop = w.Top() + w.Height() + headerBorderHeight + headerLinesHeight2057 }2058 }2059 left := w.Left()2059 shift := 02060 if !t.inputBorderShape.HasLeft() && t.listBorderShape.HasLeft() {2061 left += t.borderWidth + 12061 shift += t.borderWidth + 12062 }2063 width := w.Width()2064 if t.listBorderShape.HasRight() && !t.inputBorderShape.HasRight() {2065 width -= t.borderWidth + 12066 }2063 t.inputBorder = t.tui.NewWindow(2064 btop,2069 left,2070 width,2065 w.Left(),2066 w.Width(),2067 inputBorderHeight, tui.WindowInput, tui.MakeBorderStyle(t.inputBorderShape, t.unicode), true)2072 if left > w.Left() {2068 if shift > 0 && !t.inputBorderShape.Visible() {2069 // Small box on the left to erase the residue2070 // e.g.2071 // fzf --list-border --header-border --bind 'space:change-header(hello),enter:change-header()'2076 t.tui.NewWindow(btop, w.Left(), left-w.Left(), inputBorderHeight, tui.WindowInput, noBorder, false).Erase()2072 t.tui.NewWindow(btop, w.Left(), shift, inputBorderHeight, tui.WindowInput, noBorder, false).Erase()2073 }2078 t.inputWindow = createInnerWindow(t.inputBorder, t.inputBorderShape, tui.WindowInput)2074 t.inputWindow = createInnerWindow(t.inputBorder, t.inputBorderShape, tui.WindowInput, shift)2075 }20762077 // Set up header border2078 if hasHeaderWindow {
10 unmodified lines
2089 } else {2090 btop = w.Top() + w.Height() + headerLinesHeight2091 }2092 }2097 width := w.Width()2098 if t.listBorderShape.HasRight() && !t.headerBorderShape.HasRight() {2099 width -= t.borderWidth + 12100 }21012093 t.headerBorder = t.tui.NewWindow(2094 btop,2095 w.Left(),2105 width,2096 w.Width(),2097 headerBorderHeight, tui.WindowHeader, tui.MakeBorderStyle(t.headerBorderShape, t.unicode), true)2107 t.headerWindow = createInnerWindow(t.headerBorder, t.headerBorderShape, tui.WindowHeader)2098 t.headerWindow = createInnerWindow(t.headerBorder, t.headerBorderShape, tui.WindowHeader, 0)2099 }21002101 // Set up header lines border2102 if hasHeaderLinesWindow {
2 unmodified lines
2105 btop = w.Top() - headerLinesHeight2106 } else {2107 btop = w.Top() + w.Height()2108 }2118 width := w.Width()2119 if t.listBorderShape.HasRight() && !t.headerLinesShape.HasRight() {2120 width -= t.borderWidth + 12121 }2109 t.headerLinesBorder = t.tui.NewWindow(2110 btop,2111 w.Left(),2125 width,2112 w.Width(),2113 headerLinesHeight, tui.WindowHeader, tui.MakeBorderStyle(t.headerLinesShape, t.unicode), true)2127 t.headerLinesWindow = createInnerWindow(t.headerLinesBorder, t.headerLinesShape, tui.WindowHeader)2114 t.headerLinesWindow = createInnerWindow(t.headerLinesBorder, t.headerLinesShape, tui.WindowHeader, 0)2115 }21162117 // Print border label2118 t.printLabel(t.wborder, t.listLabel, t.listLabelOpts, t.listLabelLen, t.listBorderShape, false)
261 unmodified lines
2380 printInfoPrefix()2381 }23822383 if t.infoStyle == infoRight {2397 maxWidth := t.window.Width()2384 maxWidth := t.window.Width() - 12385 if t.reading {2386 // Need space for spinner and a margin column2387 maxWidth -= 22388 }
43 unmodified lines
2432 printInfoPrefix()2433 }2434 }24352449 maxWidth := t.window.Width() - pos2436 maxWidth := t.window.Width() - pos - 12437 if outputPrinter == nil {2438 output = t.trimMessage(output, maxWidth)2439 t.window.CPrint(tui.ColInfo, output)2440 } else {
9 unmodified lines
2450 }2451 return2452 }24532467 fillLength := maxWidth - outputLen - 22454 fillLength := maxWidth - outputLen - 12455 if fillLength > 0 {2456 t.window.CPrint(tui.ColSeparator, " ")2457 printSeparator(fillLength, false)2458 }
92 unmodified lines
2551 colors: colors}25522553 t.printHighlighted(Result{item: item},2554 tui.ColHeader, tui.ColHeader, false, false, line, line, true,2568 func(markerClass) { t.window.Print(indent) }, nil)2555 func(markerClass) int {2556 t.window.Print(indent)2557 return indentSize2558 }, nil)2559 }2560 t.wrap = wrap2561}2562
151 unmodified lines
2714 marker = t.markerMultiLine[2]2715 }2716 return marker2717 }2718 indentSize := t.pointerLen + t.markerLen2719 if current {2729 preTask := func(marker markerClass) {2720 preTask := func(marker markerClass) int {2721 w := t.window.Width() - t.pointerLen2722 if w < 0 {2732 return2723 return indentSize2724 }2725 if len(label) == 0 {2726 t.window.CPrint(tui.ColCurrentCursorEmpty, t.pointerEmpty)2727 } else {2728 t.window.CPrint(tui.ColCurrentCursor, label)2729 }2730 if w-t.markerLen < 0 {2740 return2731 return indentSize2732 }2733 if selected {2734 t.window.CPrint(tui.ColCurrentMarker, markerFor(marker))2735 } else {2736 t.window.CPrint(tui.ColCurrentSelectedEmpty, t.markerEmpty)2737 }2738 return indentSize2739 }2740 finalLineNum = t.printHighlighted(result, tui.ColCurrent, tui.ColCurrentMatch, true, true, line, maxLine, forceRedraw, preTask, postTask)2741 } else {2750 preTask := func(marker markerClass) {2742 preTask := func(marker markerClass) int {2743 w := t.window.Width() - t.pointerLen2744 if w < 0 {2753 return2745 return indentSize2746 }2747 if len(label) == 0 {2748 t.window.CPrint(tui.ColCursorEmpty, t.pointerEmpty)2749 } else {2750 t.window.CPrint(tui.ColCursor, label)2751 }2752 if w-t.markerLen < 0 {2761 return2753 return indentSize2754 }2755 if selected {2756 t.window.CPrint(tui.ColMarker, markerFor(marker))2757 } else {2758 t.window.Print(t.markerEmpty)2759 }2760 return indentSize2761 }2762 var base, match tui.ColorPair2763 if selected {2764 base = tui.ColSelected
48 unmodified lines
2813func (t *Terminal) overflow(runes []rune, max int) bool {2814 return t.displayWidthWithLimit(runes, 0, max) > max2815}28162824func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMatch tui.ColorPair, current bool, match bool, lineNum int, maxLineNum int, forceRedraw bool, preTask func(markerClass), postTask func(int, int, bool, bool)) int {2817func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMatch tui.ColorPair, current bool, match bool, lineNum int, maxLineNum int, forceRedraw bool, preTask func(markerClass) int, postTask func(int, int, bool, bool)) int {2818 var displayWidth int2819 item := result.item2820 matchOffsets := []Offset{}2821 var pos *[]int
120 unmodified lines
2942 actualLineNum = (lineNum - actualLineOffset) + (numItemLines - actualLineOffset) - 12943 }2944 t.move(actualLineNum, 0, forceRedraw && postTask == nil)29452946 indentSize := t.pointerLen + t.markerLen2947 if preTask != nil {2948 var marker markerClass2949 if numItemLines == 1 {2950 if !overflow {
20 unmodified lines
2971 marker = markerMiddle2972 }2973 }29742981 preTask(marker)2975 indentSize = preTask(marker)2976 }29772984 maxWidth := t.window.Width() - (t.pointerLen + t.markerLen + 1)2978 maxWidth := t.window.Width() - (indentSize + 1)2979 wasWrapped := false2980 if wrapped {2981 maxWidth -= t.wrapSignWidth2982 t.window.CPrint(colBase.WithAttr(tui.Dim), t.wrapSign)
3011 unmodified lines