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

This commit is contained in:
Junegunn Choi 2022-11-06 14:38:31 +09:00
parent f984aa0d2c
commit 01ae621f11
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
7 changed files with 75 additions and 30 deletions

View File

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

View File

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

View File

@ -509,6 +509,10 @@ func parseBorder(str string, optional bool) tui.BorderShape {
return tui.BorderRounded return tui.BorderRounded
case "sharp": case "sharp":
return tui.BorderSharp return tui.BorderSharp
case "bold":
return tui.BorderBold
case "double":
return tui.BorderDouble
case "horizontal": case "horizontal":
return tui.BorderHorizontal return tui.BorderHorizontal
case "vertical": case "vertical":
@ -527,7 +531,7 @@ func parseBorder(str string, optional bool) tui.BorderShape {
if optional && str == "" { if optional && str == "" {
return tui.BorderRounded 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 return tui.BorderNone
} }
@ -1308,6 +1312,10 @@ func parsePreviewWindow(opts *previewOpts, input string) {
opts.border = tui.BorderRounded opts.border = tui.BorderRounded
case "sharp", "border-sharp": case "sharp", "border-sharp":
opts.border = tui.BorderSharp opts.border = tui.BorderSharp
case "border-bold":
opts.border = tui.BorderBold
case "border-double":
opts.border = tui.BorderDouble
case "noborder", "border-none": case "noborder", "border-none":
opts.border = tui.BorderNone opts.border = tui.BorderNone
case "border-horizontal": case "border-horizontal":

View File

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

View File

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

View File

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

View File

@ -294,6 +294,8 @@ const (
BorderNone BorderShape = iota BorderNone BorderShape = iota
BorderRounded BorderRounded
BorderSharp BorderSharp
BorderBold
BorderDouble
BorderHorizontal BorderHorizontal
BorderVertical BorderVertical
BorderTop BorderTop
@ -315,18 +317,19 @@ type BorderStyle struct {
type BorderCharacter int type BorderCharacter int
func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle { func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle {
if unicode { if !unicode {
if shape == BorderRounded { return BorderStyle{
return BorderStyle{ shape: shape,
shape: shape, horizontal: '-',
horizontal: '─', vertical: '|',
vertical: '│', topLeft: '+',
topLeft: '╭', topRight: '+',
topRight: '╮', bottomLeft: '+',
bottomLeft: '╰', bottomRight: '+',
bottomRight: '╯',
}
} }
}
switch shape {
case BorderSharp:
return BorderStyle{ return BorderStyle{
shape: shape, shape: shape,
horizontal: '─', horizontal: '─',
@ -336,15 +339,35 @@ func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle {
bottomLeft: '└', bottomLeft: '└',
bottomRight: '┘', 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{ return BorderStyle{
shape: shape, shape: shape,
horizontal: '-', horizontal: '',
vertical: '|', vertical: '',
topLeft: '+', topLeft: '',
topRight: '+', topRight: '',
bottomLeft: '+', bottomLeft: '',
bottomRight: '+', bottomRight: '',
} }
} }