Fix regression where tcell renderer not clearing the preview window

This commit is contained in:
Junegunn Choi 2023-11-02 21:00:07 +09:00
parent 21ab64e962
commit d0466fa777
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
4 changed files with 18 additions and 3 deletions

View File

@ -1942,9 +1942,14 @@ func (t *Terminal) renderPreviewArea(unchanged bool) {
t.pwindow.MoveAndClear(0, 0) // Clear scroll offset display
} else {
t.previewed.filled = false
// We don't erase the window here to avoid flickering during scroll
t.pwindow.DrawBorder()
t.pwindow.Move(0, 0)
// We don't erase the window here to avoid flickering during scroll.
// However, tcell renderer uses double-buffering technique and there's no
// flickering. So we just erase the window and make the rest of the code
// simpler.
if !t.pwindow.EraseMaybe() {
t.pwindow.DrawBorder()
t.pwindow.Move(0, 0)
}
}
height := t.pwindow.Height()

View File

@ -1109,3 +1109,7 @@ func (w *LightWindow) Erase() {
w.FinishFill()
w.Move(0, 0)
}
func (w *LightWindow) EraseMaybe() bool {
return false
}

View File

@ -555,6 +555,11 @@ func (w *TcellWindow) Erase() {
fill(w.left-1, w.top, w.width+1, w.height-1, w.normal, ' ')
}
func (w *TcellWindow) EraseMaybe() bool {
w.Erase()
return true
}
func (w *TcellWindow) Enclose(y int, x int) bool {
return x >= w.left && x < (w.left+w.width) &&
y >= w.top && y < (w.top+w.height)

View File

@ -526,6 +526,7 @@ type Window interface {
Fill(text string) FillReturn
CFill(fg Color, bg Color, attr Attr, text string) FillReturn
Erase()
EraseMaybe() bool
}
type FullscreenRenderer struct {