~ghost08/tcell-term

210932f67bd2c70c03ccda672eeed77f5a942604 — Tim Culverhouse 2 years ago bf5e983
perf: only redraw cell if dirty

Use cell.Dirty to decide if redrawing cell or leaving as is.

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

M terminal.go
M terminal.go => terminal.go +6 -6
@@ 104,16 104,16 @@ func (t *Terminal) HandleEvent(e tcell.Event) bool {
}

func (t *Terminal) Draw() {
	t.view.Clear()
	buf := t.term.GetActiveBuffer()
	for viewY := int(buf.ViewHeight()) - 1; viewY >= 0; viewY-- {
		for viewX := uint16(0); viewX < buf.ViewWidth(); viewX++ {
	w, h := t.view.Size()
	for viewY := 0; viewY < h; viewY++ {
		for viewX := uint16(0); viewX < uint16(w); viewX++ {
			cell := buf.GetCell(viewX, uint16(viewY))
			if cell == nil {
				// s.SetContent(int(viewX+X), viewY+int(Y), ' ', nil, tcell.StyleDefault.Background(tcell.ColorBlack))
				continue
				t.view.SetContent(int(viewX), viewY, ' ', nil, tcell.StyleDefault)
			} else if cell.Dirty() {
				t.view.SetContent(int(viewX), viewY, cell.Rune().Rune, nil, cell.Style())
			}
			t.view.SetContent(int(viewX), viewY, cell.Rune().Rune, nil, cell.Style())
		}
	}
	if buf.IsCursorVisible() {