diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-01-10 22:41:15 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-01-10 22:41:15 -0500 |
commit | 77a0f68758905faa74407499ff92c90929e27989 (patch) | |
tree | 44edc8d2de572deff60330f609aecab56aa4dea7 /ui/helpers.go | |
parent | db1b2cd53f5dc7bfbfb6ee54ad0bb0882ea2cc03 (diff) | |
download | aerc-77a0f68758905faa74407499ff92c90929e27989.tar.gz |
Make termbox event loop async
Diffstat (limited to 'ui/helpers.go')
-rw-r--r-- | ui/helpers.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ui/helpers.go b/ui/helpers.go new file mode 100644 index 0000000..0b8789e --- /dev/null +++ b/ui/helpers.go @@ -0,0 +1,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++ + } + } +} |