Пример #1
0
func (s *Snake) Show() {
	// erase tail
	ansiterm.MoveToRC(s.tail.row, s.tail.col)
	fmt.Printf(" ")
	// print body
	for _, rib := range s.body {
		ansiterm.MoveToRC(rib.row, rib.col)
		fmt.Printf("s")
	}
}
Пример #2
0
func Headline(s string) {
	ansiterm.SavePosn()
	ansiterm.MoveToRC(1, 1)
	ansiterm.ClearLine()
	fmt.Printf("%s", s)
	ansiterm.RestorePosn()
}
Пример #3
0
func test_1() {
	const pauseSec = 2
	fmt.Printf("Test_001\n")
	ansiterm.ResetTerm(ansiterm.NORMAL)
	defer ansiterm.ClearPage()

	ansiterm.ClearPage()
	Headline("this headline should be on row 1")
	StatusUpdate("one")
	pause(pauseSec)

	ansiterm.MoveToRC(3, 1)
	Headline("erase page and print Test on third line")
	StatusUpdate("two")
	fmt.Printf("Test\r")
	pause(pauseSec)

	Headline("erase first 3 chars on third line")
	StatusUpdate("three")
	ansiterm.Erase(3)
	pause(pauseSec)

	Headline("print Best on third line")
	StatusUpdate("four")
	fmt.Printf("Best\r")
	pause(pauseSec)

	Headline("erase entire third line")
	StatusUpdate("five")
	ansiterm.ClearLine()
	pause(pauseSec)

	Headline("print Rest on third line")
	StatusUpdate("six")
	fmt.Printf("Rest\r")
	pause(pauseSec)

	Headline("move to 10,10 and print a msg")
	StatusUpdate("seven")
	ansiterm.MoveToRC(10, 10)
	fmt.Printf("x at 10,10")
	pause(pauseSec)
}
Пример #4
0
func StatusUpdate(s string) {
	const (
		row      = 12
		col      = 4
		fieldlen = 10
	)
	ansiterm.SavePosn()
	ansiterm.MoveToRC(row, col)
	ansiterm.Erase(fieldlen)
	fmt.Printf("%s", s)
	ansiterm.RestorePosn()
}
Пример #5
0
func test_2() {
	const pauseSec time.Duration = 5
	ansiterm.ClearPage()
	ansiterm.MoveToRC(9, 20)
	fmt.Printf("In a few seconds program will print 1000 X chars")
	ansiterm.MoveToRC(10, 20)
	fmt.Printf("This is slowed by forcing a 10 ms sleep per loop")
	pause(pauseSec)
	ansiterm.ClearPage()
	for i := 0; i < 1000; i++ {
		row := int(rand.Int31n(25))
		col := int(rand.Int31n(80))
		ansiterm.MoveToRC(row, col)
		time.Sleep(time.Duration(0.01 * float64(time.Second)))
		fmt.Printf("X")
	}
	pause(pauseSec)
	ansiterm.ClearPage()
	ansiterm.MoveToRC(9, 20)
	fmt.Printf("In a few seconds program will print 1000 X chars")
	ansiterm.MoveToRC(10, 20)
	fmt.Printf("using the same program at FULL speed - don't blink...")
	pause(pauseSec)
	ansiterm.ClearPage()
	for i := 0; i < 1000; i++ {
		row := int(rand.Int31n(25))
		col := int(rand.Int31n(80))
		ansiterm.MoveToRC(row, col)
		fmt.Printf("X")
	}
	pause(pauseSec)
	ansiterm.ClearPage()
}
Пример #6
0
// leaves cursor at end of last field updated
func (f *SensorField) Show(s string) {
	ansiterm.MoveToRC(f.DataField.Row, f.DataField.Col)
	ansiterm.Erase(len(f.DataField.Tag) + len(f.DataField.Data))
	f.DataField.Data = s
	fmt.Printf("%s%s", f.DataField.Tag, f.DataField.Data)
}