2015-12-26 14:30:08 -08:00
|
|
|
package ansiterm
|
|
|
|
|
2016-07-08 17:49:32 -07:00
|
|
|
type groundState struct {
|
|
|
|
baseState
|
2015-12-26 14:30:08 -08:00
|
|
|
}
|
|
|
|
|
2016-07-08 17:49:32 -07:00
|
|
|
func (gs groundState) Handle(b byte) (s state, e error) {
|
2015-12-26 14:30:08 -08:00
|
|
|
gs.parser.context.currentChar = b
|
|
|
|
|
2016-07-08 17:49:32 -07:00
|
|
|
nextState, err := gs.baseState.Handle(b)
|
2015-12-26 14:30:08 -08:00
|
|
|
if nextState != nil || err != nil {
|
|
|
|
return nextState, err
|
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
2016-07-08 17:49:32 -07:00
|
|
|
case sliceContains(printables, b):
|
2015-12-26 14:30:08 -08:00
|
|
|
return gs, gs.parser.print()
|
|
|
|
|
2016-07-08 17:49:32 -07:00
|
|
|
case sliceContains(executors, b):
|
2015-12-26 14:30:08 -08:00
|
|
|
return gs, gs.parser.execute()
|
|
|
|
}
|
|
|
|
|
|
|
|
return gs, nil
|
|
|
|
}
|