Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 3a2c177

Browse files
committed
[master] update go-ansiterm
1 parent 6b26288 commit 3a2c177

25 files changed

+611
-448
lines changed

vendor/src/github.com/Azure/go-ansiterm/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ For example the parser might receive "ESC, [, A" as a stream of three characters
77
The parser (parser.go) is a partial implementation of this state machine (http://vt100.net/emu/vt500_parser.png). There are also two event handler implementations, one for tests (test_event_handler.go) to validate that the expected events are being produced and called, the other is a Windows implementation (winterm/win_event_handler.go).
88

99
See parser_test.go for examples exercising the state machine and generating appropriate function calls.
10+
11+
-----
12+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

vendor/src/github.com/Azure/go-ansiterm/constants.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,32 @@ func getByteRange(start byte, end byte) []byte {
124124
return bytes
125125
}
126126

127-
var ToGroundBytes = getToGroundBytes()
128-
var Executors = getExecuteBytes()
127+
var toGroundBytes = getToGroundBytes()
128+
var executors = getExecuteBytes()
129129

130130
// SPACE 20+A0 hex Always and everywhere a blank space
131131
// Intermediate 20-2F hex !"#$%&'()*+,-./
132-
var Intermeds = getByteRange(0x20, 0x2F)
132+
var intermeds = getByteRange(0x20, 0x2F)
133133

134134
// Parameters 30-3F hex 0123456789:;<=>?
135135
// CSI Parameters 30-39, 3B hex 0123456789;
136-
var CsiParams = getByteRange(0x30, 0x3F)
136+
var csiParams = getByteRange(0x30, 0x3F)
137137

138-
var CsiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...)
138+
var csiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...)
139139

140140
// Uppercase 40-5F hex @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
141-
var UpperCase = getByteRange(0x40, 0x5F)
141+
var upperCase = getByteRange(0x40, 0x5F)
142142

143143
// Lowercase 60-7E hex `abcdefghijlkmnopqrstuvwxyz{|}~
144-
var LowerCase = getByteRange(0x60, 0x7E)
144+
var lowerCase = getByteRange(0x60, 0x7E)
145145

146146
// Alphabetics 40-7E hex (all of upper and lower case)
147-
var Alphabetics = append(UpperCase, LowerCase...)
147+
var alphabetics = append(upperCase, lowerCase...)
148148

149-
var Printables = getByteRange(0x20, 0x7F)
149+
var printables = getByteRange(0x20, 0x7F)
150150

151-
var EscapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E)
152-
var EscapeToGroundBytes = getEscapeToGroundBytes()
151+
var escapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E)
152+
var escapeToGroundBytes = getEscapeToGroundBytes()
153153

154154
// See http://www.vt100.net/emu/vt500_parser.png for description of the complex
155155
// byte ranges below

vendor/src/github.com/Azure/go-ansiterm/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ansiterm
22

3-
type AnsiContext struct {
3+
type ansiContext struct {
44
currentChar byte
55
paramBuffer []byte
66
interBuffer []byte
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
package ansiterm
22

3-
type CsiEntryState struct {
4-
BaseState
3+
type csiEntryState struct {
4+
baseState
55
}
66

7-
func (csiState CsiEntryState) Handle(b byte) (s State, e error) {
8-
logger.Infof("CsiEntry::Handle %#x", b)
7+
func (csiState csiEntryState) Handle(b byte) (s state, e error) {
8+
csiState.parser.logf("CsiEntry::Handle %#x", b)
99

10-
nextState, err := csiState.BaseState.Handle(b)
10+
nextState, err := csiState.baseState.Handle(b)
1111
if nextState != nil || err != nil {
1212
return nextState, err
1313
}
1414

1515
switch {
16-
case sliceContains(Alphabetics, b):
17-
return csiState.parser.Ground, nil
18-
case sliceContains(CsiCollectables, b):
19-
return csiState.parser.CsiParam, nil
20-
case sliceContains(Executors, b):
16+
case sliceContains(alphabetics, b):
17+
return csiState.parser.ground, nil
18+
case sliceContains(csiCollectables, b):
19+
return csiState.parser.csiParam, nil
20+
case sliceContains(executors, b):
2121
return csiState, csiState.parser.execute()
2222
}
2323

2424
return csiState, nil
2525
}
2626

27-
func (csiState CsiEntryState) Transition(s State) error {
28-
logger.Infof("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name())
29-
csiState.BaseState.Transition(s)
27+
func (csiState csiEntryState) Transition(s state) error {
28+
csiState.parser.logf("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name())
29+
csiState.baseState.Transition(s)
3030

3131
switch s {
32-
case csiState.parser.Ground:
32+
case csiState.parser.ground:
3333
return csiState.parser.csiDispatch()
34-
case csiState.parser.CsiParam:
34+
case csiState.parser.csiParam:
3535
switch {
36-
case sliceContains(CsiParams, csiState.parser.context.currentChar):
36+
case sliceContains(csiParams, csiState.parser.context.currentChar):
3737
csiState.parser.collectParam()
38-
case sliceContains(Intermeds, csiState.parser.context.currentChar):
38+
case sliceContains(intermeds, csiState.parser.context.currentChar):
3939
csiState.parser.collectInter()
4040
}
4141
}
4242

4343
return nil
4444
}
4545

46-
func (csiState CsiEntryState) Enter() error {
46+
func (csiState csiEntryState) Enter() error {
4747
csiState.parser.clear()
4848
return nil
4949
}

vendor/src/github.com/Azure/go-ansiterm/csi_param_state.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
package ansiterm
22

3-
type CsiParamState struct {
4-
BaseState
3+
type csiParamState struct {
4+
baseState
55
}
66

7-
func (csiState CsiParamState) Handle(b byte) (s State, e error) {
8-
logger.Infof("CsiParam::Handle %#x", b)
7+
func (csiState csiParamState) Handle(b byte) (s state, e error) {
8+
csiState.parser.logf("CsiParam::Handle %#x", b)
99

10-
nextState, err := csiState.BaseState.Handle(b)
10+
nextState, err := csiState.baseState.Handle(b)
1111
if nextState != nil || err != nil {
1212
return nextState, err
1313
}
1414

1515
switch {
16-
case sliceContains(Alphabetics, b):
17-
return csiState.parser.Ground, nil
18-
case sliceContains(CsiCollectables, b):
16+
case sliceContains(alphabetics, b):
17+
return csiState.parser.ground, nil
18+
case sliceContains(csiCollectables, b):
1919
csiState.parser.collectParam()
2020
return csiState, nil
21-
case sliceContains(Executors, b):
21+
case sliceContains(executors, b):
2222
return csiState, csiState.parser.execute()
2323
}
2424

2525
return csiState, nil
2626
}
2727

28-
func (csiState CsiParamState) Transition(s State) error {
29-
logger.Infof("CsiParam::Transition %s --> %s", csiState.Name(), s.Name())
30-
csiState.BaseState.Transition(s)
28+
func (csiState csiParamState) Transition(s state) error {
29+
csiState.parser.logf("CsiParam::Transition %s --> %s", csiState.Name(), s.Name())
30+
csiState.baseState.Transition(s)
3131

3232
switch s {
33-
case csiState.parser.Ground:
33+
case csiState.parser.ground:
3434
return csiState.parser.csiDispatch()
3535
}
3636

vendor/src/github.com/Azure/go-ansiterm/escape_intermediate_state.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
package ansiterm
22

3-
type EscapeIntermediateState struct {
4-
BaseState
3+
type escapeIntermediateState struct {
4+
baseState
55
}
66

7-
func (escState EscapeIntermediateState) Handle(b byte) (s State, e error) {
8-
logger.Infof("EscapeIntermediateState::Handle %#x", b)
9-
nextState, err := escState.BaseState.Handle(b)
7+
func (escState escapeIntermediateState) Handle(b byte) (s state, e error) {
8+
escState.parser.logf("escapeIntermediateState::Handle %#x", b)
9+
nextState, err := escState.baseState.Handle(b)
1010
if nextState != nil || err != nil {
1111
return nextState, err
1212
}
1313

1414
switch {
15-
case sliceContains(Intermeds, b):
15+
case sliceContains(intermeds, b):
1616
return escState, escState.parser.collectInter()
17-
case sliceContains(Executors, b):
17+
case sliceContains(executors, b):
1818
return escState, escState.parser.execute()
19-
case sliceContains(EscapeIntermediateToGroundBytes, b):
20-
return escState.parser.Ground, nil
19+
case sliceContains(escapeIntermediateToGroundBytes, b):
20+
return escState.parser.ground, nil
2121
}
2222

2323
return escState, nil
2424
}
2525

26-
func (escState EscapeIntermediateState) Transition(s State) error {
27-
logger.Infof("EscapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
28-
escState.BaseState.Transition(s)
26+
func (escState escapeIntermediateState) Transition(s state) error {
27+
escState.parser.logf("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
28+
escState.baseState.Transition(s)
2929

3030
switch s {
31-
case escState.parser.Ground:
31+
case escState.parser.ground:
3232
return escState.parser.escDispatch()
3333
}
3434

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
package ansiterm
22

3-
type EscapeState struct {
4-
BaseState
3+
type escapeState struct {
4+
baseState
55
}
66

7-
func (escState EscapeState) Handle(b byte) (s State, e error) {
8-
logger.Infof("EscapeState::Handle %#x", b)
9-
nextState, err := escState.BaseState.Handle(b)
7+
func (escState escapeState) Handle(b byte) (s state, e error) {
8+
escState.parser.logf("escapeState::Handle %#x", b)
9+
nextState, err := escState.baseState.Handle(b)
1010
if nextState != nil || err != nil {
1111
return nextState, err
1212
}
1313

1414
switch {
1515
case b == ANSI_ESCAPE_SECONDARY:
16-
return escState.parser.CsiEntry, nil
16+
return escState.parser.csiEntry, nil
1717
case b == ANSI_OSC_STRING_ENTRY:
18-
return escState.parser.OscString, nil
19-
case sliceContains(Executors, b):
18+
return escState.parser.oscString, nil
19+
case sliceContains(executors, b):
2020
return escState, escState.parser.execute()
21-
case sliceContains(EscapeToGroundBytes, b):
22-
return escState.parser.Ground, nil
23-
case sliceContains(Intermeds, b):
24-
return escState.parser.EscapeIntermediate, nil
21+
case sliceContains(escapeToGroundBytes, b):
22+
return escState.parser.ground, nil
23+
case sliceContains(intermeds, b):
24+
return escState.parser.escapeIntermediate, nil
2525
}
2626

2727
return escState, nil
2828
}
2929

30-
func (escState EscapeState) Transition(s State) error {
31-
logger.Infof("Escape::Transition %s --> %s", escState.Name(), s.Name())
32-
escState.BaseState.Transition(s)
30+
func (escState escapeState) Transition(s state) error {
31+
escState.parser.logf("Escape::Transition %s --> %s", escState.Name(), s.Name())
32+
escState.baseState.Transition(s)
3333

3434
switch s {
35-
case escState.parser.Ground:
35+
case escState.parser.ground:
3636
return escState.parser.escDispatch()
37-
case escState.parser.EscapeIntermediate:
37+
case escState.parser.escapeIntermediate:
3838
return escState.parser.collectInter()
3939
}
4040

4141
return nil
4242
}
4343

44-
func (escState EscapeState) Enter() error {
44+
func (escState escapeState) Enter() error {
4545
escState.parser.clear()
4646
return nil
4747
}

vendor/src/github.com/Azure/go-ansiterm/ground_state.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package ansiterm
22

3-
type GroundState struct {
4-
BaseState
3+
type groundState struct {
4+
baseState
55
}
66

7-
func (gs GroundState) Handle(b byte) (s State, e error) {
7+
func (gs groundState) Handle(b byte) (s state, e error) {
88
gs.parser.context.currentChar = b
99

10-
nextState, err := gs.BaseState.Handle(b)
10+
nextState, err := gs.baseState.Handle(b)
1111
if nextState != nil || err != nil {
1212
return nextState, err
1313
}
1414

1515
switch {
16-
case sliceContains(Printables, b):
16+
case sliceContains(printables, b):
1717
return gs, gs.parser.print()
1818

19-
case sliceContains(Executors, b):
19+
case sliceContains(executors, b):
2020
return gs, gs.parser.execute()
2121
}
2222

vendor/src/github.com/Azure/go-ansiterm/osc_string_state.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package ansiterm
22

3-
type OscStringState struct {
4-
BaseState
3+
type oscStringState struct {
4+
baseState
55
}
66

7-
func (oscState OscStringState) Handle(b byte) (s State, e error) {
8-
logger.Infof("OscString::Handle %#x", b)
9-
nextState, err := oscState.BaseState.Handle(b)
7+
func (oscState oscStringState) Handle(b byte) (s state, e error) {
8+
oscState.parser.logf("OscString::Handle %#x", b)
9+
nextState, err := oscState.baseState.Handle(b)
1010
if nextState != nil || err != nil {
1111
return nextState, err
1212
}
1313

1414
switch {
1515
case isOscStringTerminator(b):
16-
return oscState.parser.Ground, nil
16+
return oscState.parser.ground, nil
1717
}
1818

1919
return oscState, nil

0 commit comments

Comments
 (0)