Add new border style: 'thinblock' (#3327)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Mike · committed by GitHub · parent 3e9efd1 · Browse files · 7 files·+56 added−13 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
Diff stats
7 files+56 added−13 removed
- other:+56 added−13 removed
Provenance
- Commit
ce8a745- Tree
5f8143c- Author
Mike <10135646+mikesmithgh@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
3e9efd1
7 files changed+56 added−13 removed
modified:man/man1/fzf.1+8 added
226 unmodified lines227 .BR bold " Border with bold lines"228 .br229 .BR double " Border with double lines"230 .br231+.BR block " Border using block elements; suitable when using different background colors"232+.br233+.BR thinblock " Border using legacy computing symbols; may not be displayed on some terminals"234+.br235 .BR horizontal " Horizontal lines above and below the finder"236 .br237 .BR vertical " Vertical lines on each side of the finder"238 .br363 unmodified lines602 .B * border-bold603 .br604 .B * border-double605 .br606+.B * border-block607+.br608+.B * border-thinblock609+.br610 .B * border-horizontal611 .br612 .B * border-top613 .br683 unmodified linesmodified:src/tui/light.go+1 added-1 removed
755 unmodified lines756 }757 758 func (w *LightWindow) drawBorder(onlyHorizontal bool) {759 switch w.border.shape {760- case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble:760+ case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble:761 w.drawBorderAround(onlyHorizontal)762 case BorderHorizontal:763 w.drawBorderHorizontal(true, true)764 case BorderVertical:332 unmodified linesmodified:src/tui/tcell.go+5 added-5 removed
713 unmodified lines714 }715 716 hw := runewidth.RuneWidth(w.borderStyle.top)717 switch shape {718- case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble, BorderHorizontal, BorderTop:718+ case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble, BorderHorizontal, BorderTop:719 max := right - 2*hw720 if shape == BorderHorizontal || shape == BorderTop {721 max = right - hw722 }6 unmodified lines729 _screen.SetContent(x, top, w.borderStyle.top, nil, style)730 }731 }732 switch shape {733- case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble, BorderHorizontal, BorderBottom:733+ case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble, BorderHorizontal, BorderBottom:734 max := right - 2*hw735 if shape == BorderHorizontal || shape == BorderBottom {736 max = right - hw737 }2 unmodified lines740 }741 }742 if !onlyHorizontal {743 switch shape {744- case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble, BorderVertical, BorderLeft:744+ case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble, BorderVertical, BorderLeft:745 for y := top; y < bot; y++ {746 _screen.SetContent(left, y, w.borderStyle.left, nil, style)747 }748 }749 switch shape {750- case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble, BorderVertical, BorderRight:750+ case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble, BorderVertical, BorderRight:751 vw := runewidth.RuneWidth(w.borderStyle.right)752 for y := top; y < bot; y++ {753 _screen.SetContent(right-vw, y, w.borderStyle.right, nil, style)754 }755 }756 }757 switch shape {758- case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderDouble:758+ case BorderRounded, BorderSharp, BorderBold, BorderBlock, BorderThinBlock, BorderDouble:759 _screen.SetContent(left, top, w.borderStyle.topLeft, nil, style)760 _screen.SetContent(right-runewidth.RuneWidth(w.borderStyle.topRight), top, w.borderStyle.topRight, nil, style)761 _screen.SetContent(left, bot-1, w.borderStyle.bottomLeft, nil, style)762 _screen.SetContent(right-runewidth.RuneWidth(w.borderStyle.bottomRight), bot-1, w.borderStyle.bottomRight, nil, style)2 unmodified linesmodified:src/tui/tui.go+18 added
313 unmodified lines314 BorderRounded315 BorderSharp316 BorderBold317 BorderBlock318+ BorderThinBlock319 BorderDouble320 BorderHorizontal321 BorderVertical322 BorderTop85 unmodified lines408 topRight: '▜',409 bottomLeft: '▙',410 bottomRight: '▟',411 }412+413+ case BorderThinBlock:414+ // 🭽▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔🭾415+ // ▏ ▕416+ // 🭼▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁🭿417+ return BorderStyle{418+ shape: shape,419+ top: '▔',420+ bottom: '▁',421+ left: '▏',422+ right: '▕',423+ topLeft: '🭽',424+ topRight: '🭾',425+ bottomLeft: '🭼',426+ bottomRight: '🭿',427+ }428+429 case BorderDouble:430 return BorderStyle{431 shape: shape,432 top: '═',358 unmodified linesmodified:src/options.go+6 added-2 removed
61 unmodified lines62 --min-height=HEIGHT Minimum height when --height is given in percent63 (default: 10)64 --layout=LAYOUT Choose layout: [default|reverse|reverse-list]65 --border[=STYLE] Draw border around the finder66- [rounded|sharp|bold|block|double|horizontal|vertical|66+ [rounded|sharp|bold|block|thinblock|double|horizontal|vertical|67 top|bottom|left|right|none] (default: rounded)68 --border-label=LABEL Label to print on the border69 --border-label-pos=COL Position of the border label70 [POSITIVE_INTEGER: columns from left|474 unmodified lines545 case "bold":546 return tui.BorderBold547 case "block":548 return tui.BorderBlock549+ case "thinblock":550+ return tui.BorderThinBlock551 case "double":552 return tui.BorderDouble553 case "horizontal":554 return tui.BorderHorizontal12 unmodified lines567 default:568 if optional && str == "" {569 return tui.DefaultBorderShape570 }569- errorExit("invalid border style (expected: rounded|sharp|bold|block|double|horizontal|vertical|top|bottom|left|right|none)")571+ errorExit("invalid border style (expected: rounded|sharp|bold|block|thinblock|double|horizontal|vertical|top|bottom|left|right|none)")572 }573 return tui.BorderNone574 }575 863 unmodified lines1439 case "border-bold":1440 opts.border = tui.BorderBold1441 case "border-block":1442 opts.border = tui.BorderBlock1443+ case "border-thinblock":1444+ opts.border = tui.BorderThinBlock1445 case "border-double":1446 opts.border = tui.BorderDouble1447 case "noborder", "border-none":1448 opts.border = tui.BorderNone657 unmodified linesmodified:src/terminal.go+5 added-5 removed
725 unmodified lines726 }727 728 func borderLines(shape tui.BorderShape) int {729 switch shape {730- case tui.BorderHorizontal, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderDouble:730+ case tui.BorderHorizontal, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble:731 return 2732 case tui.BorderTop, tui.BorderBottom:733 return 1734 }349 unmodified lines1084 case tui.BorderLeft:1085 if idx == 3 {1086 extraMargin[idx] += 1 + bw1087 }1088- case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderDouble:1088+ case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble:1089 extraMargin[idx] += 1 + bw*(idx%2)1090 }1091 marginInt[idx] = sizeSpecToInt(idx, sizeSpec) + extraMargin[idx]1092 }84 unmodified lines1177 case tui.BorderRight:1178 t.border = t.tui.NewWindow(1179 marginInt[0], marginInt[3], width+(1+bw), height,1180 false, tui.MakeBorderStyle(tui.BorderRight, t.unicode))1181- case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderDouble:1181+ case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble:1182 t.border = t.tui.NewWindow(1183 marginInt[0]-1, marginInt[3]-(1+bw), width+(1+bw)*2, height+2,1184 false, tui.MakeBorderStyle(t.borderShape, t.unicode))1185 }25 unmodified lines1211 previewBorder = tui.MakeBorderStyle(previewOpts.border, t.unicode)1212 }1213 t.pborder = t.tui.NewWindow(y, x, w, h, true, previewBorder)1214 switch previewOpts.border {1215- case tui.BorderSharp, tui.BorderRounded, tui.BorderBold, tui.BorderBlock, tui.BorderDouble:1215+ case tui.BorderSharp, tui.BorderRounded, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble:1216 pwidth -= (1 + bw) * 21217 pheight -= 21218 x += 1 + bw1219 y += 1135 unmodified lines1355 return1356 }1357 1358 switch borderShape {1359- case tui.BorderHorizontal, tui.BorderTop, tui.BorderBottom, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderDouble:1359+ case tui.BorderHorizontal, tui.BorderTop, tui.BorderBottom, tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderBlock, tui.BorderThinBlock, tui.BorderDouble:1360 if redrawBorder {1361 window.DrawHBorder()1362 }1363 if render == nil {2354 unmodified linesmodified:CHANGELOG.md+13 added
1 CHANGELOG2 =========3 4+0.41.25+------6+- Added new border style `thinblock` which uses symbols for legacy computing7+ [one eighth block elements](https://en.wikipedia.org/wiki/Symbols_for_Legacy_Computing)8+ - Similarly to `block`, this style is suitable when using a different9+ background color because the window is completely contained within the border.10+ ```sh11+ fzf --preview 'cat {}' --border thinblock --preview-window border-thinblock \12+ --color border:233,bg:234,separator:235,preview-border:235,preview-bg:23613+ ```14+ - This style may not render correctly depending on the font and the15+ terminal emulator.16+17 0.41.118 ------19 - Fixed a bug where preview window is not updated when `--disabled` is set and20 a reload is triggered by `change:reload` binding1645 unmodified lines