예제 #1
0
파일: ansidemo2.go 프로젝트: hotei/ansiterm
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
파일: ansidemo1.go 프로젝트: hotei/ansiterm
func Headline(s string) {
	ansiterm.SavePosn()
	ansiterm.MoveToRC(1, 1)
	ansiterm.ClearLine()
	fmt.Printf("%s", s)
	ansiterm.RestorePosn()
}
예제 #3
0
파일: ansidemo1.go 프로젝트: hotei/ansiterm
func test_1() {
	const pauseSec = 5
	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
파일: ansidemo1.go 프로젝트: hotei/ansiterm
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
파일: ansidemo1.go 프로젝트: hotei/ansiterm
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
파일: ansidemo4.go 프로젝트: mmb/boosh
// 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)
}