2017-02-15 01:34:05 +00:00
|
|
|
package ansiterm
|
|
|
|
|
|
|
|
type escapeIntermediateState struct {
|
|
|
|
baseState
|
|
|
|
}
|
|
|
|
|
|
|
|
func (escState escapeIntermediateState) Handle(b byte) (s state, e error) {
|
2018-09-14 03:00:31 +00:00
|
|
|
escState.parser.logf("escapeIntermediateState::Handle %#x", b)
|
2017-02-15 01:34:05 +00:00
|
|
|
nextState, err := escState.baseState.Handle(b)
|
|
|
|
if nextState != nil || err != nil {
|
|
|
|
return nextState, err
|
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case sliceContains(intermeds, b):
|
|
|
|
return escState, escState.parser.collectInter()
|
|
|
|
case sliceContains(executors, b):
|
|
|
|
return escState, escState.parser.execute()
|
|
|
|
case sliceContains(escapeIntermediateToGroundBytes, b):
|
|
|
|
return escState.parser.ground, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return escState, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (escState escapeIntermediateState) Transition(s state) error {
|
2018-09-14 03:00:31 +00:00
|
|
|
escState.parser.logf("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
|
2017-02-15 01:34:05 +00:00
|
|
|
escState.baseState.Transition(s)
|
|
|
|
|
|
|
|
switch s {
|
|
|
|
case escState.parser.ground:
|
|
|
|
return escState.parser.escDispatch()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|