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