uiterm: call uiDraw methods when View properties change

This commit is contained in:
Tim Cooper
2014-12-06 22:34:32 -04:00
parent 634e28f2d3
commit 0019ea7cb8
4 changed files with 14 additions and 1 deletions

View File

@@ -31,18 +31,21 @@ func (t *Textview) uiSetBounds(x0, y0, x1, y1 int) {
t.x1 = x1
t.y1 = y1
t.updateParsedLines()
t.uiDraw()
}
func (t *Textview) ScrollUp() {
if newLine := t.CurrentLine + 1; newLine < len(t.parsedLines) {
t.CurrentLine = newLine
}
t.uiDraw()
}
func (t *Textview) ScrollDown() {
if newLine := t.CurrentLine - 1; newLine >= 0 {
t.CurrentLine = newLine
}
t.uiDraw()
}
func (t *Textview) ScrollTop() {
@@ -51,10 +54,12 @@ func (t *Textview) ScrollTop() {
} else {
t.CurrentLine = 0
}
t.uiDraw()
}
func (t *Textview) ScrollBottom() {
t.CurrentLine = 0
t.uiDraw()
}
func (t *Textview) updateParsedLines() {
@@ -94,12 +99,14 @@ func (t *Textview) updateParsedLines() {
func (t *Textview) AddLine(line string) {
t.Lines = append(t.Lines, line)
t.updateParsedLines()
t.uiDraw()
}
func (t *Textview) Clear() {
t.Lines = nil
t.CurrentLine = 0
t.parsedLines = nil
t.uiDraw()
}
func (t *Textview) uiDraw() {