From 2886f06977579276d0c1a8273d29d5bdad23d628 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 15 Nov 2019 18:27:08 +0900 Subject: [PATCH] Fix --preview-window noborder with non-default background color --- src/terminal.go | 6 +++--- src/tui/tui.go | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/terminal.go b/src/terminal.go index 13b932e..4cd507a 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -624,9 +624,9 @@ func (t *Terminal) resizeWindows() { noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode) if previewVisible { createPreviewWindow := func(y int, x int, w int, h int) { - previewBorder := noBorder - if t.preview.border { - previewBorder = tui.MakeBorderStyle(tui.BorderAround, t.unicode) + previewBorder := tui.MakeBorderStyle(tui.BorderAround, t.unicode) + if !t.preview.border { + previewBorder = tui.MakeTransparentBorder() } t.pborder = t.tui.NewWindow(y, x, w, h, previewBorder) pwidth := w - 4 diff --git a/src/tui/tui.go b/src/tui/tui.go index de1d4b5..5a2e8d1 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -221,6 +221,8 @@ type BorderStyle struct { bottomRight rune } +type BorderCharacter int + func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle { if unicode { return BorderStyle{ @@ -244,6 +246,17 @@ func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle { } } +func MakeTransparentBorder() BorderStyle { + return BorderStyle{ + shape: BorderAround, + horizontal: ' ', + vertical: ' ', + topLeft: ' ', + topRight: ' ', + bottomLeft: ' ', + bottomRight: ' '} +} + type Renderer interface { Init() Pause(clear bool)