summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-01-16 19:34:28 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-01-16 19:34:28 +0900
commit8b299a29c7024a0578c950bb9d1fbdb58fe4ac6c (patch)
tree3a8d2c1168f775cc739de3ca4c9f928c2ea83bb5 /src
parent3109b865d202c73c7065a3142b7ed317ce9b9382 (diff)
downloadfzf-8b299a29c7024a0578c950bb9d1fbdb58fe4ac6c.tar.gz
Fix rendering of double-column borders
Diffstat (limited to 'src')
-rw-r--r--src/terminal.go10
-rw-r--r--src/tui/tcell.go20
2 files changed, 22 insertions, 8 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 41b24f4e..b21aca73 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1064,6 +1064,7 @@ func (t *Terminal) resizeWindows(forcePreview bool) {
// Reset preview version so that full redraw occurs
t.previewed.version = 0
+ bw := t.borderWidth
switch t.borderShape {
case tui.BorderHorizontal:
t.border = t.tui.NewWindow(
@@ -1071,7 +1072,7 @@ func (t *Terminal) resizeWindows(forcePreview bool) {
false, tui.MakeBorderStyle(tui.BorderHorizontal, t.unicode))
case tui.BorderVertical:
t.border = t.tui.NewWindow(
- marginInt[0], marginInt[3]-2, width+4, height,
+ marginInt[0], marginInt[3]-(1+bw), width+(1+bw)*2, height,
false, tui.MakeBorderStyle(tui.BorderVertical, t.unicode))
case tui.BorderTop:
t.border = t.tui.NewWindow(
@@ -1083,15 +1084,15 @@ func (t *Terminal) resizeWindows(forcePreview bool) {
false, tui.MakeBorderStyle(tui.BorderBottom, t.unicode))
case tui.BorderLeft:
t.border = t.tui.NewWindow(
- marginInt[0], marginInt[3]-2, width+2, height,
+ marginInt[0], marginInt[3]-(1+bw), width+(1+bw), height,
false, tui.MakeBorderStyle(tui.BorderLeft, t.unicode))
case tui.BorderRight:
t.border = t.tui.NewWindow(
- marginInt[0], marginInt[3], width+2, height,
+ marginInt[0], marginInt[3], width+(1+bw), height,
false, tui.MakeBorderStyle(tui.BorderRight, t.unicode))
case tui.BorderRounded, tui.BorderSharp, tui.BorderBold, tui.BorderDouble:
t.border = t.tui.NewWindow(
- marginInt[0]-1, marginInt[3]-2, width+4, height+2,
+ marginInt[0]-1, marginInt[3]-(1+bw), width+(1+bw)*2, height+2,
false, tui.MakeBorderStyle(t.borderShape, t.unicode))
}
@@ -1112,7 +1113,6 @@ func (t *Terminal) resizeWindows(forcePreview bool) {
return
}
hasThreshold := previewOpts.threshold > 0 && previewOpts.alternative != nil
- bw := t.borderWidth
createPreviewWindow := func(y int, x int, w int, h int) {
pwidth := w
pheight := h
diff --git a/src/tui/tcell.go b/src/tui/tcell.go
index f1f18e24..366cb775 100644
--- a/src/tui/tcell.go
+++ b/src/tui/tcell.go
@@ -695,13 +695,26 @@ func (w *TcellWindow) drawBorder() {
hw := runewidth.RuneWidth(w.borderStyle.horizontal)
switch shape {
case BorderRounded, BorderSharp, BorderBold, BorderDouble, BorderHorizontal, BorderTop:
- for x := left; x <= right-hw; x += hw {
+ max := right - 2*hw
+ if shape == BorderHorizontal || shape == BorderTop {
+ max = right - hw
+ }
+ // tcell has an issue displaying two overlapping wide runes
+ // e.g. SetContent( HH )
+ // SetContent( TR )
+ // ==================
+ // ( HH ) => TR is ignored
+ for x := left; x <= max; x += hw {
_screen.SetContent(x, top, w.borderStyle.horizontal, nil, style)
}
}
switch shape {
case BorderRounded, BorderSharp, BorderBold, BorderDouble, BorderHorizontal, BorderBottom:
- for x := left; x <= right-hw; x += hw {
+ max := right - 2*hw
+ if shape == BorderHorizontal || shape == BorderBottom {
+ max = right - hw
+ }
+ for x := left; x <= max; x += hw {
_screen.SetContent(x, bot-1, w.borderStyle.horizontal, nil, style)
}
}
@@ -713,8 +726,9 @@ func (w *TcellWindow) drawBorder() {
}
switch shape {
case BorderRounded, BorderSharp, BorderBold, BorderDouble, BorderVertical, BorderRight:
+ vw := runewidth.RuneWidth(w.borderStyle.vertical)
for y := top; y < bot; y++ {
- _screen.SetContent(right-hw, y, w.borderStyle.vertical, nil, style)
+ _screen.SetContent(right-vw, y, w.borderStyle.vertical, nil, style)
}
}
switch shape {