コード例 #1
0
ファイル: box_example.go プロジェクト: huhoo/vulcand
func main() {
	tm.Clear()

	// Create Box with 30% width of current screen, and height of 20 lines
	box := tm.NewBox(30|tm.PCT, 20, 0)

	// Add some content to the box
	// Note that you can add ANY content, even tables
	fmt.Fprint(box, "Some box content")

	// Move Box to approx center of the screen
	tm.Print(tm.MoveTo(box.String(), 40|tm.PCT, 40|tm.PCT))

	tm.Flush()
}
コード例 #2
0
ファイル: file_output_example.go プロジェクト: huhoo/vulcand
func main() {
	f, err := os.Create("box.txt")
	if err != nil {
		panic("Unable to create box file!")
	}
	defer f.Close()

	// Tell tm to use the file we just opened, not stdout
	tm.Output = bufio.NewWriter(f)

	// More or less stolen from the box example
	tm.Clear()
	box := tm.NewBox(30|tm.PCT, 20, 0)
	fmt.Fprint(box, "Some box content")
	tm.Print(tm.MoveTo(box.String(), 40|tm.PCT, 40|tm.PCT))
	tm.Flush()

	fmt.Println("Now view the contents of 'box.txt' in an ansi-capable terminal")
}