From b6add2a25777b20e416cb84473f6d1632b73715d Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 5 May 2024 17:09:00 +0900 Subject: [PATCH] Fix rendering of preview window border of tcell renderer (sleep 1; find .) | go run -tags tcell main.go --bind 'space:change-preview-window(60%|70%|80%|90%|border-left|border-right|border-vertical|border-top|border-horizontal|border-bottom|border-sharp|border-double|border-block|hidden|left|up|down|right|up|down|)' \ --preview 'cat {}' --color bg:red,preview-bg:blue \ --border --margin 3 --- src/tui/tcell.go | 6 +++++- src/tui/tui.go | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/tui/tcell.go b/src/tui/tcell.go index af0902cb..9b8f8620 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -561,7 +561,11 @@ func fill(x, y, w, h int, n ColorPair, r rune) { } func (w *TcellWindow) Erase() { - fill(w.left-1, w.top, w.width+1, w.height-1, w.normal, ' ') + if w.borderStyle.shape.HasLeft() { + fill(w.left-1, w.top, w.width, w.height-1, w.normal, ' ') + } else { + fill(w.left, w.top, w.width-1, w.height-1, w.normal, ' ') + } w.drawBorder(false) } diff --git a/src/tui/tui.go b/src/tui/tui.go index aec80fcd..7fad8f48 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -368,6 +368,14 @@ const ( BorderRight ) +func (s BorderShape) HasLeft() bool { + switch s { + case BorderNone, BorderRight, BorderTop, BorderBottom, BorderHorizontal: // No Left + return false + } + return true +} + func (s BorderShape) HasRight() bool { switch s { case BorderNone, BorderLeft, BorderTop, BorderBottom, BorderHorizontal: // No right