From ce8a745fb4ea6d0725e76d13d97fdf4b7433331d Mon Sep 17 00:00:00 2001 From: Mike <10135646+mikesmithgh@users.noreply.github.com> Date: Sat, 10 Jun 2023 01:48:29 -0400 Subject: Add new border style: 'thinblock' (#3327) Co-authored-by: Junegunn Choi --- src/options.go | 8 ++++++-- src/terminal.go | 10 +++++----- src/tui/light.go | 2 +- src/tui/tcell.go | 10 +++++----- src/tui/tui.go | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/options.go b/src/options.go index 4db34640..69e5db91 100644 --- a/src/options.go +++ b/src/options.go @@ -63,7 +63,7 @@ const usage = `usage: fzf [options] (default: 10) --layout=LAYOUT Choose layout: [default|reverse|reverse-list] --border[=STYLE] Draw border around the finder - [rounded|sharp|bold|block|double|horizontal|vertical| + [rounded|sharp|bold|block|thinblock|double|horizontal|vertical| top|bottom|left|right|none] (default: rounded) --border-label=LABEL Label to print on the border --border-label-pos=COL Position of the border label @@ -546,6 +546,8 @@ func parseBorder(str string, optional bool) tui.BorderShape { return tui.BorderBold case "block": return tui.BorderBlock + case "thinblock": + return tui.BorderThinBlock case "double": return tui.BorderDouble case "horizontal": @@ -566,7 +568,7 @@ func parseBorder(str string, optional bool) tui.BorderShape { if optional && str == "" { return tui.DefaultBorderShape } - errorExit("invalid border style (expected: rounded|sharp|bold|block|double|horizontal|vertical|top|bottom|left|right|none)") + errorExit("invalid border style (expected: rounded|sharp|bold|block|thinblock|double|horizontal|vertical|top|bottom|left|right|none)") } return tui.BorderNone } @@ -1438,6 +1440,8 @@ func parsePreviewWindowImpl(opts *previewOpts, input string, exit func(string)) opts.border = tui.BorderBold case "border-block": opts.border = tui.BorderBlock + case "border-thinblock": + opts.border = tui.BorderThinBlock case "border-double": opts.border = tui.BorderDouble case "noborder", "border-none": diff --git a/src/terminal.go b/src/terminal.go index 3179d929..b60424ba 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -727,7 +727,7 @@ func (t *Terminal) environ() []string { func borderLines(shape tui.BorderShape) int { switch shape { - case tui.BorderHorizontal, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderDouble: + case tui.BorderHorizontal, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble: return 2 case tui.BorderTop, tui.BorderBottom: return 1 @@ -1085,7 +1085,7 @@ func (t *Terminal) adjustMarginAndPadding() (int, int, [4]int, [4]int) { if idx == 3 { extraMargin[idx] += 1 + bw } - case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderDouble: + case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble: extraMargin[idx] += 1 + bw*(idx%2) } marginInt[idx] = sizeSpecToInt(idx, sizeSpec) + extraMargin[idx] @@ -1178,7 +1178,7 @@ func (t *Terminal) resizeWindows(forcePreview bool) { t.border = t.tui.NewWindow( marginInt[0], marginInt[3], width+(1+bw), height, false, tui.MakeBorderStyle(tui.BorderRight, t.unicode)) - case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderDouble: + case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble: t.border = t.tui.NewWindow( marginInt[0]-1, marginInt[3]-(1+bw), width+(1+bw)*2, height+2, false, tui.MakeBorderStyle(t.borderShape, t.unicode)) @@ -1212,7 +1212,7 @@ func (t *Terminal) resizeWindows(forcePreview bool) { } t.pborder = t.tui.NewWindow(y, x, w, h, true, previewBorder) switch previewOpts.border { - case tui.BorderSharp, tui.BorderRounded, tui.BorderBold, tui.BorderBlock, tui.BorderDouble: + case tui.BorderSharp, tui.BorderRounded, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble: pwidth -= (1 + bw) * 2 pheight -= 2 x += 1 + bw @@ -1356,7 +1356,7 @@ func (t *Terminal) printLabel(window tui.Window, render labelPrinter, opts label } switch borderShape { - case tui.BorderHorizontal, tui.BorderTop, tui.BorderBottom, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderDouble: + case tui.BorderHorizontal, tui.BorderTop, tui.BorderBottom, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble: if redrawBorder { window.DrawHBorder() } diff --git a/src/tui/light.go b/src/tui/light.go index 8356eb50..cff59c90 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -757,7 +757,7 @@ func (w *LightWindow) DrawHBorder() { func (w *LightWindow) drawBorder(onlyHorizontal bool) { switch w.border.shape { - case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble: + case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble: w.drawBorderAround(onlyHorizontal) case BorderHorizontal: w.drawBorderHorizontal(true, true) diff --git a/src/tui/tcell.go b/src/tui/tcell.go index f815df07..8f6806d4 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -715,7 +715,7 @@ func (w *TcellWindow) drawBorder(onlyHorizontal bool) { hw := runewidth.RuneWidth(w.borderStyle.top) switch shape { - case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble, BorderHorizontal, BorderTop: + case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble, BorderHorizontal, BorderTop: max := right - 2*hw if shape == BorderHorizontal || shape == BorderTop { max = right - hw @@ -730,7 +730,7 @@ func (w *TcellWindow) drawBorder(onlyHorizontal bool) { } } switch shape { - case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble, BorderHorizontal, BorderBottom: + case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble, BorderHorizontal, BorderBottom: max := right - 2*hw if shape == BorderHorizontal || shape == BorderBottom { max = right - hw @@ -741,13 +741,13 @@ func (w *TcellWindow) drawBorder(onlyHorizontal bool) { } if !onlyHorizontal { switch shape { - case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble, BorderVertical, BorderLeft: + case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble, BorderVertical, BorderLeft: for y := top; y < bot; y++ { _screen.SetContent(left, y, w.borderStyle.left, nil, style) } } switch shape { - case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble, BorderVertical, BorderRight: + case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble, BorderVertical, BorderRight: vw := runewidth.RuneWidth(w.borderStyle.right) for y := top; y < bot; y++ { _screen.SetContent(right-vw, y, w.borderStyle.right, nil, style) @@ -755,7 +755,7 @@ func (w *TcellWindow) drawBorder(onlyHorizontal bool) { } } switch shape { - case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble: + case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble: _screen.SetContent(left, top, w.borderStyle.topLeft, nil, style) _screen.SetContent(right-runewidth.RuneWidth(w.borderStyle.topRight), top, w.borderStyle.topRight, nil, style) _screen.SetContent(left, bot-1, w.borderStyle.bottomLeft, nil, style) diff --git a/src/tui/tui.go b/src/tui/tui.go index 55fbe771..8cfe8d33 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -315,6 +315,7 @@ const ( BorderSharp BorderBold BorderBlock + BorderThinBlock BorderDouble BorderHorizontal BorderVertical @@ -408,6 +409,23 @@ func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle { bottomLeft: '▙', bottomRight: '▟', } + + case BorderThinBlock: + // 🭽▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔🭾 + // ▏ ▕ + // 🭼▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁🭿 + return BorderStyle{ + shape: shape, + top: '▔', + bottom: '▁', + left: '▏', + right: '▕', + topLeft: '🭽', + topRight: '🭾', + bottomLeft: '🭼', + bottomRight: '🭿', + } + case BorderDouble: return BorderStyle{ shape: shape, -- cgit v1.2.3