diff options
Diffstat (limited to 'ui/helpers.go')
-rw-r--r-- | ui/helpers.go | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/ui/helpers.go b/ui/helpers.go index 0b8789e9..f2b2adff 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 } } |