From 4074445cbb45dc6ec132e67b7eac9f32dcfd53de Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 11 Jan 2018 09:04:18 -0500 Subject: Move worker into account tab --- ui/helpers.go | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'ui/helpers.go') 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 } } -- cgit 1.4.1-2-gfad0