* 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
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package ansiterm
|
|
|
|
type escapeState struct {
|
|
baseState
|
|
}
|
|
|
|
func (escState escapeState) Handle(b byte) (s state, e error) {
|
|
escState.parser.logf("escapeState::Handle %#x", b)
|
|
nextState, err := escState.baseState.Handle(b)
|
|
if nextState != nil || err != nil {
|
|
return nextState, err
|
|
}
|
|
|
|
switch {
|
|
case b == ANSI_ESCAPE_SECONDARY:
|
|
return escState.parser.csiEntry, nil
|
|
case b == ANSI_OSC_STRING_ENTRY:
|
|
return escState.parser.oscString, nil
|
|
case sliceContains(executors, b):
|
|
return escState, escState.parser.execute()
|
|
case sliceContains(escapeToGroundBytes, b):
|
|
return escState.parser.ground, nil
|
|
case sliceContains(intermeds, b):
|
|
return escState.parser.escapeIntermediate, nil
|
|
}
|
|
|
|
return escState, nil
|
|
}
|
|
|
|
func (escState escapeState) Transition(s state) error {
|
|
escState.parser.logf("Escape::Transition %s --> %s", escState.Name(), s.Name())
|
|
escState.baseState.Transition(s)
|
|
|
|
switch s {
|
|
case escState.parser.ground:
|
|
return escState.parser.escDispatch()
|
|
case escState.parser.escapeIntermediate:
|
|
return escState.parser.collectInter()
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (escState escapeState) Enter() error {
|
|
escState.parser.clear()
|
|
return nil
|
|
}
|