Profpatsch/users/Profpatsch/avt-go/cmd/smoke/main.go
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main

import (
	avt "avt-go"
	"fmt"
)

func main() {
	vt := avt.New(10, 4)
	changes := vt.FeedStr("hello\r\nworld")
	fmt.Printf("changed lines: %v\n", changes.Lines)
	fmt.Printf("text: %v\n", vt.Text())
	cursor := vt.Cursor()
	fmt.Printf("cursor: col=%d row=%d visible=%v\n", cursor.Col, cursor.Row, cursor.Visible)

	dump := vt.Dump()
	vt2 := avt.New(10, 4)
	vt2.FeedStr(dump)
	fmt.Printf("after dump replay text: %v\n", vt2.Text())

	// Test ANSI colors
	vt3 := avt.New(20, 4)
	vt3.FeedStr("\x1b[31mred\x1b[0m normal")
	for _, line := range vt3.View() {
		fmt.Printf("cells: ")
		for _, c := range line.Cells {
			if c.Char() != ' ' {
				fmt.Printf("%c(fg=%v) ", c.Char(), c.Pen().Foreground)
			}
		}
		fmt.Println()
	}

	// Test resize
	vt4 := avt.New(4, 2)
	vt4.FeedStr("")
	resizeChanges := vt4.Resize(4, 3)
	fmt.Printf("resize changed lines: %v\n", resizeChanges.Lines)
	cols, rows := vt4.Size()
	fmt.Printf("new size: %dx%d\n", cols, rows)
}