~ghost08/tcell-term

922b568b6ced31b40aece05a4726431644a46c10 — Tim Culverhouse 1 year, 2 months ago 6e45f37
cells: set dirty when cell changes

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

M termutil/buffer.go
M termutil/line.go
M termutil/buffer.go => termutil/buffer.go +6 -1
@@ 130,6 130,7 @@ func (buffer *Buffer) areaScrollDown(lines uint16) {
		i--
		if i >= top+uint64(lines) {
			buffer.lines[i] = buffer.lines[i-uint64(lines)]
			buffer.lines[i].setDirty(true)
		} else {
			buffer.lines[i] = newLine()
		}


@@ 144,6 145,7 @@ func (buffer *Buffer) areaScrollUp(lines uint16) {
		from := i + uint64(lines)
		if from < bottom {
			buffer.lines[i] = buffer.lines[from]
			buffer.lines[i].setDirty(true)
		} else {
			buffer.lines[i] = newLine()
		}


@@ 372,6 374,9 @@ func (buffer *Buffer) index() {
		if uint64(len(buffer.lines)) > maxLines {
			copy(buffer.lines, buffer.lines[uint64(len(buffer.lines))-maxLines:])
			buffer.lines = buffer.lines[:maxLines]
			for _, line := range buffer.lines {
				line.setDirty(true)
			}
		}
	}
	buffer.cursorPosition.Line++


@@ 783,7 788,7 @@ func (buffer *Buffer) defaultCell(applyEffects bool) Cell {
		attr = attr.Underline(false)
		attr = attr.Dim(false)
	}
	return Cell{attr: attr}
	return Cell{attr: attr, dirty: true}
}

func (buffer *Buffer) IsNewLineMode() bool {

M termutil/line.go => termutil/line.go +8 -0
@@ 30,6 30,12 @@ func (line *Line) append(cells ...Cell) {
	line.cells = append(line.cells, cells...)
}

func (line *Line) setDirty(d bool) {
	for _, cell := range line.cells {
		cell.SetDirty(d)
	}
}

func (line *Line) shrink(width uint16) {
	if line.Len() <= width {
		return


@@ 40,6 46,7 @@ func (line *Line) shrink(width uint16) {
		if cell.r.Rune == 0 && remove > 0 {
			remove--
		} else {
			cell.SetDirty(true)
			cells = append(cells, cell)
		}
	}


@@ 54,6 61,7 @@ func (line *Line) wrap(width uint16) []Line {
	current.wrapped = line.wrapped

	for _, cell := range line.cells {
		cell.SetDirty(true)
		if len(current.cells) == int(width) {
			output = append(output, current)
			current = newLine()