aboutsummaryrefslogtreecommitdiffstats
path: root/ui/helpers.go
blob: 0b8789e98ed030363d665fd60b2025e142a7ca8e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package ui

import (
	"fmt"

	tb "github.com/nsf/termbox-go"
)

func TPrintf(geo *Geometry, ref tb.Cell, format string, a ...interface{}) {
	str := fmt.Sprintf(format, a...)
	_geo := *geo
	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?
			geo.Col = _geo.Col
			geo.Row++
		}
	}
}