summary refs log tree commit diff stats
path: root/ui/helpers.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-01-11 09:04:18 -0500
committerDrew DeVault <sir@cmpwn.com>2018-01-11 09:04:18 -0500
commit4074445cbb45dc6ec132e67b7eac9f32dcfd53de (patch)
treeabb2348df84e12f0a781a4e0d29509962d01c756 /ui/helpers.go
parentffba56133406027a6a740f9f4454b27134143f0a (diff)
downloadaerc-4074445cbb45dc6ec132e67b7eac9f32dcfd53de.tar.gz
Move worker into account tab
Diffstat (limited to 'ui/helpers.go')
-rw-r--r--ui/helpers.go30
1 files changed, 25 insertions, 5 deletions
diff --git a/ui/helpers.go b/ui/helpers.go
index 0b8789e..f2b2adf 100644
--- a/ui/helpers.go
+++ b/ui/helpers.go
@@ -9,13 +9,33 @@ import (
 func TPrintf(geo *Geometry, ref tb.Cell, format string, a ...interface{}) {
 	str := fmt.Sprintf(format, a...)
 	_geo := *geo
+	newline := func() {
+		// TODO: Abort when out of room?
+		geo.Col = _geo.Col
+		geo.Row++
+	}
 	for _, ch := range str {
-		tb.SetCell(geo.Col, geo.Row, ch, ref.Fg, ref.Bg)
-		geo.Col++
-		if geo.Col == _geo.Col+geo.Width {
-			// TODO: Abort when out of room?
+		switch ch {
+		case '\n':
+			newline()
+		case '\r':
 			geo.Col = _geo.Col
-			geo.Row++
+		default:
+			tb.SetCell(geo.Col, geo.Row, ch, ref.Fg, ref.Bg)
+			geo.Col++
+			if geo.Col == _geo.Col+geo.Width {
+				newline()
+			}
+		}
+	}
+}
+
+func TFill(geo Geometry, ref tb.Cell) {
+	_geo := geo
+	for ; geo.Row < geo.Height; geo.Row++ {
+		for ; geo.Col < geo.Width; geo.Col++ {
+			tb.SetCell(geo.Col, geo.Row, ref.Ch, ref.Fg, ref.Bg)
 		}
+		geo.Col = _geo.Col
 	}
 }