summaryrefslogtreecommitdiff
path: root/src/tui/light.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-01-22 01:56:29 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-01-22 02:18:19 +0900
commitd51980a3f50dfa8ce43b01a3dce216afb8a0bd8f (patch)
tree6041fc67bd7108153363a155b0c05348e65ee11d /src/tui/light.go
parentc3d73e7ecbe56358949400f5314fee2d6976885a (diff)
downloadfzf-d51980a3f50dfa8ce43b01a3dce216afb8a0bd8f.tar.gz
Add 'transform-border-label' and 'transform-preview-label'
Diffstat (limited to 'src/tui/light.go')
-rw-r--r--src/tui/light.go37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/tui/light.go b/src/tui/light.go
index a336cac0..3ff4ded7 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -719,25 +719,38 @@ func (r *LightRenderer) NewWindow(top int, left int, width int, height int, prev
w.fg = r.theme.Fg.Color
w.bg = r.theme.Bg.Color
}
- w.drawBorder()
+ w.drawBorder(false)
return w
}
-func (w *LightWindow) drawBorder() {
+func (w *LightWindow) DrawHBorder() {
+ w.drawBorder(true)
+}
+
+func (w *LightWindow) drawBorder(onlyHorizontal bool) {
switch w.border.shape {
case BorderRounded, BorderSharp, BorderBold, BorderDouble:
- w.drawBorderAround()
+ w.drawBorderAround(onlyHorizontal)
case BorderHorizontal:
w.drawBorderHorizontal(true, true)
case BorderVertical:
+ if onlyHorizontal {
+ return
+ }
w.drawBorderVertical(true, true)
case BorderTop:
w.drawBorderHorizontal(true, false)
case BorderBottom:
w.drawBorderHorizontal(false, true)
case BorderLeft:
+ if onlyHorizontal {
+ return
+ }
w.drawBorderVertical(true, false)
case BorderRight:
+ if onlyHorizontal {
+ return
+ }
w.drawBorderVertical(false, true)
}
}
@@ -779,23 +792,25 @@ func (w *LightWindow) drawBorderVertical(left, right bool) {
}
}
-func (w *LightWindow) drawBorderAround() {
+func (w *LightWindow) drawBorderAround(onlyHorizontal bool) {
w.Move(0, 0)
color := ColBorder
if w.preview {
color = ColPreviewBorder
}
hw := runewidth.RuneWidth(w.border.horizontal)
- vw := runewidth.RuneWidth(w.border.vertical)
tcw := runewidth.RuneWidth(w.border.topLeft) + runewidth.RuneWidth(w.border.topRight)
bcw := runewidth.RuneWidth(w.border.bottomLeft) + runewidth.RuneWidth(w.border.bottomRight)
rem := (w.width - tcw) % hw
w.CPrint(color, string(w.border.topLeft)+repeat(w.border.horizontal, (w.width-tcw)/hw)+repeat(' ', rem)+string(w.border.topRight))
- for y := 1; y < w.height-1; y++ {
- w.Move(y, 0)
- w.CPrint(color, string(w.border.vertical))
- w.CPrint(color, repeat(' ', w.width-vw*2))
- w.CPrint(color, string(w.border.vertical))
+ if !onlyHorizontal {
+ vw := runewidth.RuneWidth(w.border.vertical)
+ for y := 1; y < w.height-1; y++ {
+ w.Move(y, 0)
+ w.CPrint(color, string(w.border.vertical))
+ w.CPrint(color, repeat(' ', w.width-vw*2))
+ w.CPrint(color, string(w.border.vertical))
+ }
}
w.Move(w.height-1, 0)
rem = (w.width - bcw) % hw
@@ -1040,7 +1055,7 @@ func (w *LightWindow) FinishFill() {
}
func (w *LightWindow) Erase() {
- w.drawBorder()
+ w.drawBorder(false)
// We don't erase the window here to avoid flickering during scroll
w.Move(0, 0)
}