2015-04-16 17:01:37 -04:00
|
|
|
package ansiterm
|
|
|
|
|
2016-04-25 18:55:12 -04:00
|
|
|
type groundState struct {
|
|
|
|
baseState
|
2015-04-16 17:01:37 -04:00
|
|
|
}
|
|
|
|
|
2016-04-25 18:55:12 -04:00
|
|
|
func (gs groundState) Handle(b byte) (s state, e error) {
|
2015-04-16 17:01:37 -04:00
|
|
|
gs.parser.context.currentChar = b
|
|
|
|
|
2016-04-25 18:55:12 -04:00
|
|
|
nextState, err := gs.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(printables, b):
|
2015-04-16 17:01:37 -04:00
|
|
|
return gs, gs.parser.print()
|
|
|
|
|
2016-04-25 18:55:12 -04:00
|
|
|
case sliceContains(executors, b):
|
2015-04-16 17:01:37 -04:00
|
|
|
return gs, gs.parser.execute()
|
|
|
|
}
|
|
|
|
|
|
|
|
return gs, nil
|
|
|
|
}
|