~ghost08/tcell-term

6e45f37bcba53a257a2cde1197a94cd188a75016 — Tim Culverhouse 1 year, 3 months ago 74164f6
cell: add dirty methods and prop

To enable preventing drawing every cell, even if it hasn't changed

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
1 files changed, 18 insertions(+), 2 deletions(-)

M termutil/cell.go
M termutil/cell.go => termutil/cell.go +18 -2
@@ 5,8 5,9 @@ import (
)

type Cell struct {
	r    MeasuredRune
	attr tcell.Style
	r     MeasuredRune
	attr  tcell.Style
	dirty bool
}

func (cell *Cell) Rune() MeasuredRune {


@@ 53,11 54,26 @@ func (cell *Cell) Bg() tcell.Color {
}
*/

func (cell *Cell) Dirty() bool {
	return cell.dirty
}

func (cell *Cell) SetDirty(d bool) {
	cell.dirty = d
}

func (cell *Cell) erase(bgColour tcell.Color) {
	cell.setRune(MeasuredRune{Rune: 0})
	cell.attr = cell.attr.Background(bgColour)
	cell.SetDirty(true)
}

func (cell *Cell) setRune(r MeasuredRune) {
	cell.r = r
	cell.SetDirty(true)
}

func (cell *Cell) setStyle(s tcell.Style) {
	cell.attr = s
	cell.SetDirty(true)
}