summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-10-25 21:43:53 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-10-25 21:43:53 +0900
commit9b946f2b7a39f9b552f8f4788c3e1a7bb4182bc4 (patch)
tree588f829abfcf9c3ee101b8f8b104849e29e8af48
parent11841f688bd12e56c11dc2ae71911a1e25213951 (diff)
Fix preview window of tcell renderer
-rw-r--r--src/tui/tcell.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/tui/tcell.go b/src/tui/tcell.go
index e37b5ef8..0ad1488f 100644
--- a/src/tui/tcell.go
+++ b/src/tui/tcell.go
@@ -515,8 +515,9 @@ func (w *TcellWindow) CPrint(pair ColorPair, text string) {
w.printString(text, pair)
}
-func (w *TcellWindow) fillString(text string, pair ColorPair, a Attr) FillReturn {
+func (w *TcellWindow) fillString(text string, pair ColorPair) FillReturn {
lx := 0
+ a := pair.Attr()
var style tcell.Style
if w.color {
@@ -558,12 +559,17 @@ func (w *TcellWindow) fillString(text string, pair ColorPair, a Attr) FillReturn
}
}
w.lastX += lx
+ if w.lastX == w.width {
+ w.lastY++
+ w.lastX = 0
+ return FillNextLine
+ }
return FillContinue
}
func (w *TcellWindow) Fill(str string) FillReturn {
- return w.fillString(str, w.normal, 0)
+ return w.fillString(str, w.normal)
}
func (w *TcellWindow) CFill(fg Color, bg Color, a Attr, str string) FillReturn {
@@ -573,7 +579,7 @@ func (w *TcellWindow) CFill(fg Color, bg Color, a Attr, str string) FillReturn {
if bg == colDefault {
bg = w.normal.Bg()
}
- return w.fillString(str, NewColorPair(fg, bg, a), a)
+ return w.fillString(str, NewColorPair(fg, bg, a))
}
func (w *TcellWindow) drawBorder() {