go-ethereum/vendor/github.com/morikuni/aec/aec.go
Rafael Matias 388d8ccd9f
PoC: Network simulation framework (#1555)
* simv2: wip

* simulation: exec adapter start/stop

* simulation: add node status to exec adapter

* simulation: initial simulation code

* simulation: exec adapter, configure path to executable

* simulation: initial docker adapter

* simulation: wip kubernetes adapter

* simulation: kubernetes adapter proxy

* simulation: implement GetAll/StartAll/StopAll

* simulation: kuberentes adapter - set env vars and resource limits

* simulation: discovery test

* simulation: remove port definitions within docker adapter

* simulation: simplify wait for healthy loop

* simulation: get nat ip addr from interface

* simulation: pull docker images automatically

* simulation: NodeStatus -> NodeInfo

* simulation: move discovery test to example dir

* simulation: example snapshot usage

* simulation: add goclient specific simulation

* simulation: add peer connections to snapshot

* simulation: close rpc client

* simulation: don't export kubernetes proxy server

* simulation: merge simulation code

* simulation: don't export nodemap

* simulation: rename SimulationSnapshot -> Snapshot

* simulation: linting fixes

* simulation: add k8s available helper func

* simulation: vendor

* simulation: fix 'no non-test Go files' when building

* simulation: remove errors from interface methods where non were returned

* simulation: run getHealthInfo check in parallel
2019-07-24 17:00:13 +02:00

137 lines
2.4 KiB
Go

package aec
import "fmt"
// EraseMode is listed in a variable EraseModes.
type EraseMode uint
var (
// EraseModes is a list of EraseMode.
EraseModes struct {
// All erase all.
All EraseMode
// Head erase to head.
Head EraseMode
// Tail erase to tail.
Tail EraseMode
}
// Save saves the cursor position.
Save ANSI
// Restore restores the cursor position.
Restore ANSI
// Hide hides the cursor.
Hide ANSI
// Show shows the cursor.
Show ANSI
// Report reports the cursor position.
Report ANSI
)
// Up moves up the cursor.
func Up(n uint) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dA", n))
}
// Down moves down the cursor.
func Down(n uint) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dB", n))
}
// Right moves right the cursor.
func Right(n uint) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dC", n))
}
// Left moves left the cursor.
func Left(n uint) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dD", n))
}
// NextLine moves down the cursor to head of a line.
func NextLine(n uint) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dE", n))
}
// PreviousLine moves up the cursor to head of a line.
func PreviousLine(n uint) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dF", n))
}
// Column set the cursor position to a given column.
func Column(col uint) ANSI {
return newAnsi(fmt.Sprintf(esc+"%dG", col))
}
// Position set the cursor position to a given absolute position.
func Position(row, col uint) ANSI {
return newAnsi(fmt.Sprintf(esc+"%d;%dH", row, col))
}
// EraseDisplay erases display by given EraseMode.
func EraseDisplay(m EraseMode) ANSI {
return newAnsi(fmt.Sprintf(esc+"%dJ", m))
}
// EraseLine erases lines by given EraseMode.
func EraseLine(m EraseMode) ANSI {
return newAnsi(fmt.Sprintf(esc+"%dK", m))
}
// ScrollUp scrolls up the page.
func ScrollUp(n int) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dS", n))
}
// ScrollDown scrolls down the page.
func ScrollDown(n int) ANSI {
if n == 0 {
return empty
}
return newAnsi(fmt.Sprintf(esc+"%dT", n))
}
func init() {
EraseModes = struct {
All EraseMode
Head EraseMode
Tail EraseMode
}{
Tail: 0,
Head: 1,
All: 2,
}
Save = newAnsi(esc + "s")
Restore = newAnsi(esc + "u")
Hide = newAnsi(esc + "?25l")
Show = newAnsi(esc + "?25h")
Report = newAnsi(esc + "6n")
}