Skip to content

Commit

Permalink
fixes #576 Intermittent screen flashes
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Dec 30, 2022
1 parent 44c298f commit a642547
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
11 changes: 6 additions & 5 deletions screen.go
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
12 changes: 0 additions & 12 deletions tscreen.go
Expand Up @@ -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) {
Expand Down

0 comments on commit a642547

Please sign in to comment.