示例#1
0
func Headline(s string) {
	ansiterm.SavePosn()
	ansiterm.MoveToRC(1, 1)
	ansiterm.ClearLine()
	fmt.Printf("%s", s)
	ansiterm.RestorePosn()
}
示例#2
0
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)
}
示例#3
0
文件: watch.go 项目: mmb/boosh
func streamEvents(events <-chan *cloudformation.StackEvent) bool {
	ok := true

	inFlight := make(map[string]Process)

	printedLines := 0

	for ev := range events {
		status := ev.ResourceStatus

		for i := 0; i < printedLines; i++ {
			fmt.Print("\x1b[1A")
			ansiterm.ClearLine()
		}

		process, progress := parseStatus(status)

		if progress == PendingProgress {
			inFlight[ev.LogicalResourceId] = process
		} else {
			delete(inFlight, ev.LogicalResourceId)

			label := process.CompletedLabel()

			if progress == FailedProgress {
				ok = false
				fmt.Printf(ansi.Color("%s: %s (%s)\n", "red"), label, ev.LogicalResourceId, ev.ResourceStatusReason)
			} else {
				fmt.Printf(ansi.Color("%s: %s (%s)\n", "green"), label, ev.LogicalResourceId, ev.PhysicalResourceId)
			}
		}

		printedLines = renderInFlight(inFlight)
	}

	return ok
}