aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/Azure/go-ansiterm/escape_intermediate_state.go
blob: 1c719db9e48cdd8462d2c26b45b11d0460d0b5b4 (plain)
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
package ansiterm

type escapeIntermediateState struct {
	baseState
}

func (escState escapeIntermediateState) Handle(b byte) (s state, e error) {
	escState.parser.logf("escapeIntermediateState::Handle %#x", b)
	nextState, err := escState.baseState.Handle(b)
	if nextState != nil || err != nil {
		return nextState, err
	}

	switch {
	case sliceContains(intermeds, b):
		return escState, escState.parser.collectInter()
	case sliceContains(executors, b):
		return escState, escState.parser.execute()
	case sliceContains(escapeIntermediateToGroundBytes, b):
		return escState.parser.ground, nil
	}

	return escState, nil
}

func (escState escapeIntermediateState) Transition(s state) error {
	escState.parser.logf("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
	escState.baseState.Transition(s)

	switch s {
	case escState.parser.ground:
		return escState.parser.escDispatch()
	}

	return nil
}