File: escape_state.go

package info (click to toggle)
kubernetes 1.20.5%2Breally1.20.2-1.1%2Bdeb12u1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 268,944 kB
  • sloc: sh: 29,129; asm: 11,883; makefile: 1,770; ansic: 995; sed: 440; python: 405
file content (47 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download | duplicates (3)
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
39
40
41
42
43
44
45
46
47
package ansiterm

type escapeState struct {
	baseState
}

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

	switch {
	case b == ANSI_ESCAPE_SECONDARY:
		return escState.parser.csiEntry, nil
	case b == ANSI_OSC_STRING_ENTRY:
		return escState.parser.oscString, nil
	case sliceContains(executors, b):
		return escState, escState.parser.execute()
	case sliceContains(escapeToGroundBytes, b):
		return escState.parser.ground, nil
	case sliceContains(intermeds, b):
		return escState.parser.escapeIntermediate, nil
	}

	return escState, nil
}

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

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

	return nil
}

func (escState escapeState) Enter() error {
	escState.parser.clear()
	return nil
}