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