Skip to content

Commit

Permalink
feat(cellbuf): distinguish between Clear and Redraw
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Feb 5, 2025
1 parent dee611f commit dbe08ae
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cellbuf/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,19 @@ func (s *Screen) Cell(x int, y int) *Cell {
return s.newbuf.Cell(x, y)
}

// Clear implements Window.
func (s *Screen) Clear() bool {
// Redraw forces a full redraw of the screen.
func (s *Screen) Redraw() {
s.clear = true
}

// Clear clears the screen with blank cells. This is a convenience method for
// [Screen.Fill] with a nil cell.
func (s *Screen) Clear() bool {
return s.ClearRect(s.newbuf.Bounds())
}

// ClearRect implements Window.
// ClearRect clears the given rectangle with blank cells. This is a convenience
// method for [Screen.FillRect] with a nil cell.
func (s *Screen) ClearRect(r Rectangle) bool {
return s.FillRect(nil, r)
}
Expand Down Expand Up @@ -1440,7 +1446,7 @@ func (s *Screen) SetContentRect(str string, rect Rectangle) {
str = strings.ReplaceAll(str, "\n", "\r\n")
// We're using [Screen.Fill] instead of [Screen.Clear] to avoid force
// clearing the screen using [ansi.EraseEntireScreen] which is slow.
s.FillRect(nil, rect)
s.ClearRect(rect)
s.printString(rect.Min.X, rect.Min.Y, rect.Dx(), rect.Dy(), str, true, "")
}

Expand Down

0 comments on commit dbe08ae

Please sign in to comment.