From 0019ea7cb8873d954fcfeb631881ca85dbbd23ff Mon Sep 17 00:00:00 2001 From: Tim Cooper Date: Sat, 6 Dec 2014 22:34:32 -0400 Subject: [PATCH] uiterm: call uiDraw methods when View properties change --- uiterm/label.go | 1 + uiterm/textbox.go | 2 ++ uiterm/textview.go | 7 +++++++ uiterm/tree.go | 5 ++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/uiterm/label.go b/uiterm/label.go index 39394ff..648d07e 100644 --- a/uiterm/label.go +++ b/uiterm/label.go @@ -27,6 +27,7 @@ func (l *Label) uiSetBounds(x0, y0, x1, y1 int) { l.y0 = y0 l.x1 = x1 l.y1 = y1 + l.uiDraw() } func (l *Label) uiDraw() { diff --git a/uiterm/textbox.go b/uiterm/textbox.go index 60c7ab2..d2233ab 100644 --- a/uiterm/textbox.go +++ b/uiterm/textbox.go @@ -25,6 +25,7 @@ func (t *Textbox) uiInitialize(ui *Ui) { func (t *Textbox) uiSetActive(active bool) { t.active = active + t.uiDraw() } func (t *Textbox) uiSetBounds(x0, y0, x1, y1 int) { @@ -32,6 +33,7 @@ func (t *Textbox) uiSetBounds(x0, y0, x1, y1 int) { t.y0 = y0 t.x1 = x1 t.y1 = y1 + t.uiDraw() } func (t *Textbox) uiDraw() { diff --git a/uiterm/textview.go b/uiterm/textview.go index f9cd0a9..945081e 100644 --- a/uiterm/textview.go +++ b/uiterm/textview.go @@ -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() { diff --git a/uiterm/tree.go b/uiterm/tree.go index ed6f45a..907b1ec 100644 --- a/uiterm/tree.go +++ b/uiterm/tree.go @@ -50,6 +50,7 @@ func (t *Tree) uiInitialize(ui *Ui) { func (t *Tree) uiSetActive(active bool) { t.active = active + t.uiDraw() } func (t *Tree) uiSetBounds(x0, y0, x1, y1 int) { @@ -57,6 +58,7 @@ func (t *Tree) uiSetBounds(x0, y0, x1, y1 int) { t.y0 = y0 t.x1 = x1 t.y1 = y1 + t.uiDraw() } func (t *Tree) Rebuild() { @@ -74,6 +76,7 @@ func (t *Tree) Rebuild() { } t.lines = lines t.activeLine = bounded(t.activeLine, 0, len(t.lines)-1) + t.uiDraw() } func (t *Tree) rebuild_rec(parent TreeItem, level int) []renderedTreeItem { @@ -142,7 +145,7 @@ func (t *Tree) uiKeyEvent(mod Modifier, key Key) { t.Listener(t.ui, t, t.lines[t.activeLine].Item) } } - t.ui.Refresh() + t.uiDraw() } func (t *Tree) uiCharacterEvent(ch rune) { -- 2.39.2