File: csi_param_state.go

package info (click to toggle)
golang-github-azure-go-ansiterm 0.0~git20160622.0.fa152c5-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 252 kB
  • sloc: makefile: 2
file content (38 lines) | stat: -rw-r--r-- 838 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package ansiterm

type csiParamState struct {
	baseState
}

func (csiState csiParamState) Handle(b byte) (s state, e error) {
	logger.Infof("CsiParam::Handle %#x", b)

	nextState, err := csiState.baseState.Handle(b)
	if nextState != nil || err != nil {
		return nextState, err
	}

	switch {
	case sliceContains(alphabetics, b):
		return csiState.parser.ground, nil
	case sliceContains(csiCollectables, b):
		csiState.parser.collectParam()
		return csiState, nil
	case sliceContains(executors, b):
		return csiState, csiState.parser.execute()
	}

	return csiState, nil
}

func (csiState csiParamState) Transition(s state) error {
	logger.Infof("CsiParam::Transition %s --> %s", csiState.Name(), s.Name())
	csiState.baseState.Transition(s)

	switch s {
	case csiState.parser.ground:
		return csiState.parser.csiDispatch()
	}

	return nil
}