Add --border=[bold|double] and --preview-window=border-[bold|double]

pull/3046/head
Junegunn Choi 2 years ago
parent f984aa0d2c
commit 01ae621f11
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -34,6 +34,8 @@ CHANGELOG
- Separator can be disabled by adding `:nosep` to `--info`
- `--info=nosep`
- `--info=inline:nosep`
- Added `--border=bold` and `--border=double` along with
`--preview-window=border-bold` and `--preview-window=border-double`
0.34.0
------

@ -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 "Oct 2022" "fzf 0.35.0" "fzf - a command-line fuzzy finder"
.TH fzf 1 "Nov 2022" "fzf 0.35.0" "fzf - a command-line fuzzy finder"
.SH NAME
fzf - a command-line fuzzy finder
@ -211,6 +211,10 @@ Draw border around the finder
.br
.BR sharp " Border with sharp corners"
.br
.BR bold " Border with bold lines"
.br
.BR double " Border with double lines"
.br
.BR horizontal " Horizontal lines above and below the finder"
.br
.BR vertical " Vertical lines on each side of the finder"
@ -236,6 +240,10 @@ following \fB--border\fR options.
.br
.B * sharp
.br
.B * bold
.br
.B * double
.br
.B * horizontal
.br
.BR "* top" " (up)"
@ -539,6 +547,10 @@ Should be used with one of the following \fB--preview-window\fR options.
.br
.B * border-sharp
.br
.B * border-bold
.br
.B * border-double
.br
.B * border-horizontal
.br
.B * border-top

@ -509,6 +509,10 @@ func parseBorder(str string, optional bool) tui.BorderShape {
return tui.BorderRounded
case "sharp":
return tui.BorderSharp
case "bold":
return tui.BorderBold
case "double":
return tui.BorderDouble
case "horizontal":
return tui.BorderHorizontal
case "vertical":
@ -527,7 +531,7 @@ func parseBorder(str string, optional bool) tui.BorderShape {
if optional && str == "" {
return tui.BorderRounded
}
errorExit("invalid border style (expected: rounded|sharp|horizontal|vertical|top|bottom|left|right|none)")
errorExit("invalid border style (expected: rounded|sharp|bold|double|horizontal|vertical|top|bottom|left|right|none)")
}
return tui.BorderNone
}
@ -1308,6 +1312,10 @@ func parsePreviewWindow(opts *previewOpts, input string) {
opts.border = tui.BorderRounded
case "sharp", "border-sharp":
opts.border = tui.BorderSharp
case "border-bold":
opts.border = tui.BorderBold
case "border-double":
opts.border = tui.BorderDouble
case "noborder", "border-none":
opts.border = tui.BorderNone
case "border-horizontal":

@ -605,7 +605,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
func borderLines(shape tui.BorderShape) int {
switch shape {
case tui.BorderHorizontal, tui.BorderRounded, tui.BorderSharp:
case tui.BorderHorizontal, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderDouble:
return 2
case tui.BorderTop, tui.BorderBottom:
return 1
@ -847,7 +847,7 @@ func (t *Terminal) adjustMarginAndPadding() (int, int, [4]int, [4]int) {
if idx == 3 {
extraMargin[idx] += 2
}
case tui.BorderRounded, tui.BorderSharp:
case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderDouble:
extraMargin[idx] += 1 + idx%2
}
marginInt[idx] = sizeSpecToInt(idx, sizeSpec) + extraMargin[idx]
@ -939,7 +939,7 @@ func (t *Terminal) resizeWindows() {
t.border = t.tui.NewWindow(
marginInt[0], marginInt[3], width+2, height,
false, tui.MakeBorderStyle(tui.BorderRight, t.unicode))
case tui.BorderRounded, tui.BorderSharp:
case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderDouble:
t.border = t.tui.NewWindow(
marginInt[0]-1, marginInt[3]-2, width+4, height+2,
false, tui.MakeBorderStyle(t.borderShape, t.unicode))
@ -969,7 +969,7 @@ func (t *Terminal) resizeWindows() {
}
t.pborder = t.tui.NewWindow(y, x, w, h, true, previewBorder)
switch previewOpts.border {
case tui.BorderSharp, tui.BorderRounded:
case tui.BorderSharp, tui.BorderRounded, tui.BorderBold, tui.BorderDouble:
pwidth -= 4
pheight -= 2
x += 2
@ -1057,7 +1057,7 @@ func (t *Terminal) resizeWindows() {
}
switch borderShape {
case tui.BorderHorizontal, tui.BorderTop, tui.BorderBottom, tui.BorderRounded, tui.BorderSharp:
case tui.BorderHorizontal, tui.BorderTop, tui.BorderBottom, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderDouble:
var col int
if opts.column == 0 {
col = util.Max(0, (window.Width()-length)/2)

@ -712,7 +712,7 @@ func (r *LightRenderer) NewWindow(top int, left int, width int, height int, prev
func (w *LightWindow) drawBorder() {
switch w.border.shape {
case BorderRounded, BorderSharp:
case BorderRounded, BorderSharp, BorderBold, BorderDouble:
w.drawBorderAround()
case BorderHorizontal:
w.drawBorderHorizontal(true, true)

@ -705,31 +705,31 @@ func (w *TcellWindow) drawBorder() {
}
switch shape {
case BorderRounded, BorderSharp, BorderHorizontal, BorderTop:
case BorderRounded, BorderSharp, BorderBold, BorderDouble, BorderHorizontal, BorderTop:
for x := left; x < right; x++ {
_screen.SetContent(x, top, w.borderStyle.horizontal, nil, style)
}
}
switch shape {
case BorderRounded, BorderSharp, BorderHorizontal, BorderBottom:
case BorderRounded, BorderSharp, BorderBold, BorderDouble, BorderHorizontal, BorderBottom:
for x := left; x < right; x++ {
_screen.SetContent(x, bot-1, w.borderStyle.horizontal, nil, style)
}
}
switch shape {
case BorderRounded, BorderSharp, BorderVertical, BorderLeft:
case BorderRounded, BorderSharp, BorderBold, BorderDouble, BorderVertical, BorderLeft:
for y := top; y < bot; y++ {
_screen.SetContent(left, y, w.borderStyle.vertical, nil, style)
}
}
switch shape {
case BorderRounded, BorderSharp, BorderVertical, BorderRight:
case BorderRounded, BorderSharp, BorderBold, BorderDouble, BorderVertical, BorderRight:
for y := top; y < bot; y++ {
_screen.SetContent(right-1, y, w.borderStyle.vertical, nil, style)
}
}
switch shape {
case BorderRounded, BorderSharp:
case BorderRounded, BorderSharp, BorderBold, BorderDouble:
_screen.SetContent(left, top, w.borderStyle.topLeft, nil, style)
_screen.SetContent(right-1, top, w.borderStyle.topRight, nil, style)
_screen.SetContent(left, bot-1, w.borderStyle.bottomLeft, nil, style)

@ -294,6 +294,8 @@ const (
BorderNone BorderShape = iota
BorderRounded
BorderSharp
BorderBold
BorderDouble
BorderHorizontal
BorderVertical
BorderTop
@ -315,18 +317,19 @@ type BorderStyle struct {
type BorderCharacter int
func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle {
if unicode {
if shape == BorderRounded {
return BorderStyle{
shape: shape,
horizontal: '─',
vertical: '│',
topLeft: '╭',
topRight: '╮',
bottomLeft: '╰',
bottomRight: '╯',
}
if !unicode {
return BorderStyle{
shape: shape,
horizontal: '-',
vertical: '|',
topLeft: '+',
topRight: '+',
bottomLeft: '+',
bottomRight: '+',
}
}
switch shape {
case BorderSharp:
return BorderStyle{
shape: shape,
horizontal: '─',
@ -336,15 +339,35 @@ func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle {
bottomLeft: '└',
bottomRight: '┘',
}
case BorderBold:
return BorderStyle{
shape: shape,
horizontal: '━',
vertical: '┃',
topLeft: '┏',
topRight: '┓',
bottomLeft: '┗',
bottomRight: '┛',
}
case BorderDouble:
return BorderStyle{
shape: shape,
horizontal: '═',
vertical: '║',
topLeft: '╔',
topRight: '╗',
bottomLeft: '╚',
bottomRight: '╝',
}
}
return BorderStyle{
shape: shape,
horizontal: '-',
vertical: '|',
topLeft: '+',
topRight: '+',
bottomLeft: '+',
bottomRight: '+',
horizontal: '',
vertical: '',
topLeft: '',
topRight: '',
bottomLeft: '',
bottomRight: '',
}
}

Loading…
Cancel
Save