From a6425479225cdcc46be7f1560b49b8dc4e3bdec2 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 30 Dec 2022 14:55:11 -0800 Subject: [PATCH] fixes #576 Intermittent screen flashes --- screen.go | 11 ++++++----- tscreen.go | 12 ------------ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/screen.go b/screen.go index 43c3a54..5598a8c 100644 --- a/screen.go +++ b/screen.go @@ -24,12 +24,13 @@ type Screen interface { // Fini finalizes the screen also releasing resources. Fini() - // Clear erases the screen. The contents of any screen buffers - // will also be cleared. This has the logical effect of - // filling the screen with spaces, using the global default style. + // Clear logically erases the screen. + // This is effectively a short-cut for Fill(' ', StyleDefault). Clear() // Fill fills the screen with the given character and style. + // The effect of filling the screen is not visible until Show + // is called (or Sync). Fill(rune, Style) // SetCell is an older API, and will be removed. Please use @@ -42,7 +43,7 @@ type Screen interface { // and may not actually be what is displayed, but rather are what will // be displayed if Show() or Sync() is called. The width is the width // in screen cells; most often this will be 1, but some East Asian - // characters require two cells. + // characters and emoji require two cells. GetContent(x, y int) (primary rune, combining []rune, style Style, width int) // SetContent sets the contents of the given cell location. If @@ -54,7 +55,7 @@ type Screen interface { // // The results are not displayed until Show() or Sync() is called. // - // Note that wide (East Asian full width) runes occupy two cells, + // Note that wide (East Asian full width and emoji) runes occupy two cells, // and attempts to place character at next cell to the right will have // undefined effects. Wide runes that are printed in the // last column will be replaced with a single width space on output. diff --git a/tscreen.go b/tscreen.go index c3fe7be..e07dea4 100644 --- a/tscreen.go +++ b/tscreen.go @@ -575,18 +575,6 @@ 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) {