fixes #485 Optimize screen.Clear() (#491)

This commit is contained in:
Garrett D'Amore 2021-10-10 22:40:26 -07:00 committed by GitHub
parent 761abf6821
commit 62f5502f7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 7 deletions

View File

@ -358,7 +358,6 @@ func (t *tScreen) prepareCursorStyles() {
CursorStyleSteadyUnderline: "\x1b[4 q",
CursorStyleBlinkingBar: "\x1b[5 q",
CursorStyleSteadyBar: "\x1b[6 q",
}
}
}
@ -549,6 +548,18 @@ func (t *tScreen) SetStyle(style Style) {
func (t *tScreen) Clear() {
t.Fill(' ', t.style)
t.Lock()
t.clear = true
w, h := t.cells.Size()
// because we are going to clear (see t.clear) in the next cycle,
// let's also unmark the dirty bit so that we don't waste cycles
// drawing things that are already dealt with via the clear escape sequence.
for row := 0; row < h; row++ {
for col := 0; col < w; col++ {
t.cells.SetDirty(col, row, false)
}
}
t.Unlock()
}
func (t *tScreen) Fill(r rune, style Style) {