mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-04-04 17:15:55 +00:00
* 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
99 lines
1.8 KiB
Go
99 lines
1.8 KiB
Go
package ansiterm
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
func parseParams(bytes []byte) ([]string, error) {
|
|
paramBuff := make([]byte, 0, 0)
|
|
params := []string{}
|
|
|
|
for _, v := range bytes {
|
|
if v == ';' {
|
|
if len(paramBuff) > 0 {
|
|
// Completed parameter, append it to the list
|
|
s := string(paramBuff)
|
|
params = append(params, s)
|
|
paramBuff = make([]byte, 0, 0)
|
|
}
|
|
} else {
|
|
paramBuff = append(paramBuff, v)
|
|
}
|
|
}
|
|
|
|
// Last parameter may not be terminated with ';'
|
|
if len(paramBuff) > 0 {
|
|
s := string(paramBuff)
|
|
params = append(params, s)
|
|
}
|
|
|
|
return params, nil
|
|
}
|
|
|
|
func parseCmd(context ansiContext) (string, error) {
|
|
return string(context.currentChar), nil
|
|
}
|
|
|
|
func getInt(params []string, dflt int) int {
|
|
i := getInts(params, 1, dflt)[0]
|
|
return i
|
|
}
|
|
|
|
func getInts(params []string, minCount int, dflt int) []int {
|
|
ints := []int{}
|
|
|
|
for _, v := range params {
|
|
i, _ := strconv.Atoi(v)
|
|
// Zero is mapped to the default value in VT100.
|
|
if i == 0 {
|
|
i = dflt
|
|
}
|
|
ints = append(ints, i)
|
|
}
|
|
|
|
if len(ints) < minCount {
|
|
remaining := minCount - len(ints)
|
|
for i := 0; i < remaining; i++ {
|
|
ints = append(ints, dflt)
|
|
}
|
|
}
|
|
|
|
return ints
|
|
}
|
|
|
|
func (ap *AnsiParser) modeDispatch(param string, set bool) error {
|
|
switch param {
|
|
case "?3":
|
|
return ap.eventHandler.DECCOLM(set)
|
|
case "?6":
|
|
return ap.eventHandler.DECOM(set)
|
|
case "?25":
|
|
return ap.eventHandler.DECTCEM(set)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (ap *AnsiParser) hDispatch(params []string) error {
|
|
if len(params) == 1 {
|
|
return ap.modeDispatch(params[0], true)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (ap *AnsiParser) lDispatch(params []string) error {
|
|
if len(params) == 1 {
|
|
return ap.modeDispatch(params[0], false)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func getEraseParam(params []string) int {
|
|
param := getInt(params, 0)
|
|
if param < 0 || 3 < param {
|
|
param = 0
|
|
}
|
|
|
|
return param
|
|
}
|