2015-04-16 21:01:37 +00:00
|
|
|
package ansiterm
|
|
|
|
|
2016-04-25 22:55:12 +00:00
|
|
|
type escapeIntermediateState struct {
|
|
|
|
baseState
|
2015-04-16 21:01:37 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 22:55:12 +00:00
|
|
|
func (escState escapeIntermediateState) Handle(b byte) (s state, e error) {
|
|
|
|
logger.Infof("escapeIntermediateState::Handle %#x", b)
|
|
|
|
nextState, err := escState.baseState.Handle(b)
|
2015-04-16 21:01:37 +00:00
|
|
|
if nextState != nil || err != nil {
|
|
|
|
return nextState, err
|
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
2016-04-25 22:55:12 +00:00
|
|
|
case sliceContains(intermeds, b):
|
2015-04-16 21:01:37 +00:00
|
|
|
return escState, escState.parser.collectInter()
|
2016-04-25 22:55:12 +00:00
|
|
|
case sliceContains(executors, b):
|
2015-04-16 21:01:37 +00:00
|
|
|
return escState, escState.parser.execute()
|
2016-04-25 22:55:12 +00:00
|
|
|
case sliceContains(escapeIntermediateToGroundBytes, b):
|
|
|
|
return escState.parser.ground, nil
|
2015-04-16 21:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return escState, nil
|
|
|
|
}
|
|
|
|
|
2016-04-25 22:55:12 +00:00
|
|
|
func (escState escapeIntermediateState) Transition(s state) error {
|
|
|
|
logger.Infof("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
|
|
|
|
escState.baseState.Transition(s)
|
2015-04-16 21:01:37 +00:00
|
|
|
|
|
|
|
switch s {
|
2016-04-25 22:55:12 +00:00
|
|
|
case escState.parser.ground:
|
2015-04-16 21:01:37 +00:00
|
|
|
return escState.parser.escDispatch()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|