summaryrefslogtreecommitdiff
path: root/tui/draw.go
diff options
context:
space:
mode:
Diffstat (limited to 'tui/draw.go')
-rw-r--r--tui/draw.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/tui/draw.go b/tui/draw.go
index 01dfc83..2005f1a 100644
--- a/tui/draw.go
+++ b/tui/draw.go
@@ -26,30 +26,32 @@ type surface map[pos]char
type screen struct {
front surface
back surface
- prevSize Dims
+ prevSize ScreenSize
writer *bufio.Writer
cursor pos
}
-var terminfo *termfo.Terminfo
+var (
+ terminfo *termfo.Terminfo
+ scr screen
+)
-var scr screen
func init() {
scr.writer = bufio.NewWriterSize(os.Stdout, 50000)
Clear()
}
-type Dims struct {
+type ScreenSize struct {
Width int
Height int
}
-func Size() Dims {
+func Size() ScreenSize {
w, h, _ := term.GetSize(0)
- return Dims {w, h}
+ return ScreenSize {w, h}
}
-func Write(x int, y int, text string, style Style) int {
+func WriteAt(x int, y int, text string, style Style) int {
width := 0
g := uniseg.NewGraphemes(text)
for g.Next() {
@@ -107,15 +109,15 @@ func End() {
if saved == nil {
return
}
- if term.Restore(0, saved) != nil {
- return
- }
- saved = nil
os.Stdout.WriteString(
terminfo.Get(caps.ClearScreen) +
terminfo.Get(caps.XM, 0) +
terminfo.Get(caps.ExitCaMode),
)
+ if term.Restore(0, saved) != nil {
+ return
+ }
+ saved = nil
}
func writeCursor(x int, y int) error {