コード例 #1
0
ファイル: ansidemo5.go プロジェクト: hotei/ansiterm
func main() {

	//test color/additional functions here
	ansiterm.ResetTerm(ansiterm.NORMAL)
	ansiterm.ClearPage()

	ansiterm.MoveToXY(10, 10)
	sleepOne()

	ansiterm.HideCursor()
	sleepOne()

	ansiterm.SetFGColor(5)
	fmt.Printf("TEST MOVE HIDDEN CURSOR / OUT IN PURPLE")
	sleepOne()

	ansiterm.MoveToXY(10, 12)
	ansiterm.SetColorBright()
	fmt.Printf("BRIGHT COLORS")
	sleepOne()

	ansiterm.MoveToXY(10, 14)
	ansiterm.SetColorNormal()
	fmt.Printf("NORMAL COLORS AGAIN")
	sleepOne()

	ansiterm.ShowCursor()
	sleepOne()

	ansiterm.ResetTerm(ansiterm.NORMAL)
}
コード例 #2
0
ファイル: ansidemo4.go プロジェクト: mmb/boosh
func main() {
	ansiterm.ResetTerm(0)
	ansiterm.ClearPage()
	initFields()
	startSensors()
	runfor = 1
	done := time.After(time.Duration(runfor) * time.Minute)
	fmt.Printf("This demo will stop after %d minutes\n", runfor)

L1:
	for {
		select {
		case t := <-temp.Ch:
			temp.Show(fmt.Sprintf("%d", t))
		case t := <-clock.Ch:
			clock.Show(fmt.Sprintf("%d", t))
		case t := <-seekerrs.Ch:
			seekerrs.Show(fmt.Sprintf("%d", t))

		// note: label is required else it 'breaks' the select, not the for
		case _ = <-done:
			break L1
		}
	}
	if false {
		os.Exit(0)
	}
	ansiterm.ClearPage()
}
コード例 #3
0
ファイル: ansidemo3.go プロジェクト: hotei/ansiterm
func main() {
	ansiterm.ResetTerm(0)
	ansiterm.ClearPage()
	//	ansiterm.MoveToRC(13,13)
	//	ansiterm.QueryPosn()  hangs
	//	os.Exit(0)
	ansiterm.HideCursor()
	defer ansiterm.ShowCursor()
	setupForm()
	startSensors()
	runfor = 1
	prog := make(chan int)
	// prompt, row,col,barWidth,listen chan, alldone
	go progressBar("Progress: ", 20, 20, 50, prog, 60*runfor)
	done := time.After(time.Duration(runfor) * time.Minute) // set up a timeout channel
	fmt.Printf("This demo will stop after %d minute(s)\n", runfor)
	time.Sleep(2 * time.Second)
L1:
	for {
		select {
		case t := <-sensors[0]:
			g_Form.UpdateMsg("temp", fmt.Sprintf("%5d", t))
		case t := <-sensors[1]:
			g_Form.UpdateMsg("seekerr", fmt.Sprintf("%5d", t))
		case t := <-sensors[2]:
			g_Form.UpdateMsg("time", fmt.Sprintf("%5d", t))
			g_Form.UpdateMsg("progress", fmt.Sprintf("%5d", t))
			prog <- t
			g_Form.Draw()
		// note: label is required else it 'breaks' the select, not the for
		case _ = <-done:
			break L1
		}
	}
	if true { // optional wrapup stats
		ansiterm.ClearPage()
		ansiterm.ResetTerm(ansiterm.NORMAL)
		fmt.Printf("<done>\n")
	}
}
コード例 #4
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)
}