aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/Azure/go-ansiterm/ground_state.go
blob: 52451e94693a136f15109c9ca99fa6347ac1d5a8 (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
package ansiterm

type groundState struct {
	baseState
}

func (gs groundState) Handle(b byte) (s state, e error) {
	gs.parser.context.currentChar = b

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

	switch {
	case sliceContains(printables, b):
		return gs, gs.parser.print()

	case sliceContains(executors, b):
		return gs, gs.parser.execute()
	}

	return gs, nil
}