csi_param_state.go 854 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package ansiterm
  2. type csiParamState struct {
  3. baseState
  4. }
  5. func (csiState csiParamState) Handle(b byte) (s state, e error) {
  6. csiState.parser.logf("CsiParam::Handle %#x", b)
  7. nextState, err := csiState.baseState.Handle(b)
  8. if nextState != nil || err != nil {
  9. return nextState, err
  10. }
  11. switch {
  12. case sliceContains(alphabetics, b):
  13. return csiState.parser.ground, nil
  14. case sliceContains(csiCollectables, b):
  15. csiState.parser.collectParam()
  16. return csiState, nil
  17. case sliceContains(executors, b):
  18. return csiState, csiState.parser.execute()
  19. }
  20. return csiState, nil
  21. }
  22. func (csiState csiParamState) Transition(s state) error {
  23. csiState.parser.logf("CsiParam::Transition %s --> %s", csiState.Name(), s.Name())
  24. csiState.baseState.Transition(s)
  25. switch s {
  26. case csiState.parser.ground:
  27. return csiState.parser.csiDispatch()
  28. }
  29. return nil
  30. }