summaryrefslogtreecommitdiff
path: root/tui/draw.go
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2025-02-01 14:19:23 -0600
committercitrons <citrons@mondecitronne.com>2025-02-01 16:06:42 -0600
commit874c492e5c471d4ee9bde1638dc675999b8b1f51 (patch)
tree58b36160437b945c35b73749a5decb9f903d59c0 /tui/draw.go
parent75e781cf2cc88f7a775f99998224c658550c198f (diff)
renaming/refactoring
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 {