Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exports #20

Merged
merged 2 commits into from
Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,32 +124,32 @@ func getByteRange(start byte, end byte) []byte {
return bytes
}

var ToGroundBytes = getToGroundBytes()
var Executors = getExecuteBytes()
var toGroundBytes = getToGroundBytes()
var executors = getExecuteBytes()

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

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

var CsiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...)
var csiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...)

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

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

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

var Printables = getByteRange(0x20, 0x7F)
var printables = getByteRange(0x20, 0x7F)

var EscapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E)
var EscapeToGroundBytes = getEscapeToGroundBytes()
var escapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E)
var escapeToGroundBytes = getEscapeToGroundBytes()

// See http://www.vt100.net/emu/vt500_parser.png for description of the complex
// byte ranges below
Expand Down
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ansiterm

type AnsiContext struct {
type ansiContext struct {
currentChar byte
paramBuffer []byte
interBuffer []byte
Expand Down
32 changes: 16 additions & 16 deletions csi_entry_state.go
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package ansiterm

type CsiEntryState struct {
BaseState
type csiEntryState struct {
baseState
}

func (csiState CsiEntryState) Handle(b byte) (s State, e error) {
func (csiState csiEntryState) Handle(b byte) (s state, e error) {
logger.Infof("CsiEntry::Handle %#x", b)

nextState, err := csiState.BaseState.Handle(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):
return csiState.parser.CsiParam, nil
case sliceContains(Executors, b):
case sliceContains(alphabetics, b):
return csiState.parser.ground, nil
case sliceContains(csiCollectables, b):
return csiState.parser.csiParam, nil
case sliceContains(executors, b):
return csiState, csiState.parser.execute()
}

return csiState, nil
}

func (csiState CsiEntryState) Transition(s State) error {
func (csiState csiEntryState) Transition(s state) error {
logger.Infof("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name())
csiState.BaseState.Transition(s)
csiState.baseState.Transition(s)

switch s {
case csiState.parser.Ground:
case csiState.parser.ground:
return csiState.parser.csiDispatch()
case csiState.parser.CsiParam:
case csiState.parser.csiParam:
switch {
case sliceContains(CsiParams, csiState.parser.context.currentChar):
case sliceContains(csiParams, csiState.parser.context.currentChar):
csiState.parser.collectParam()
case sliceContains(Intermeds, csiState.parser.context.currentChar):
case sliceContains(intermeds, csiState.parser.context.currentChar):
csiState.parser.collectInter()
}
}

return nil
}

func (csiState CsiEntryState) Enter() error {
func (csiState csiEntryState) Enter() error {
csiState.parser.clear()
return nil
}
22 changes: 11 additions & 11 deletions csi_param_state.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
package ansiterm

type CsiParamState struct {
BaseState
type csiParamState struct {
baseState
}

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

nextState, err := csiState.BaseState.Handle(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):
case sliceContains(alphabetics, b):
return csiState.parser.ground, nil
case sliceContains(csiCollectables, b):
csiState.parser.collectParam()
return csiState, nil
case sliceContains(Executors, b):
case sliceContains(executors, b):
return csiState, csiState.parser.execute()
}

return csiState, nil
}

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

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

Expand Down
26 changes: 13 additions & 13 deletions escape_intermediate_state.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package ansiterm

type EscapeIntermediateState struct {
BaseState
type escapeIntermediateState struct {
baseState
}

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

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

return escState, nil
}

func (escState EscapeIntermediateState) Transition(s State) error {
logger.Infof("EscapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
escState.BaseState.Transition(s)
func (escState escapeIntermediateState) Transition(s state) error {
logger.Infof("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
escState.baseState.Transition(s)

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

Expand Down
34 changes: 17 additions & 17 deletions escape_state.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
package ansiterm

type EscapeState struct {
BaseState
type escapeState struct {
baseState
}

func (escState EscapeState) Handle(b byte) (s State, e error) {
logger.Infof("EscapeState::Handle %#x", b)
nextState, err := escState.BaseState.Handle(b)
func (escState escapeState) Handle(b byte) (s state, e error) {
logger.Infof("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
return escState.parser.csiEntry, nil
case b == ANSI_OSC_STRING_ENTRY:
return escState.parser.OscString, nil
case sliceContains(Executors, b):
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
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 {
func (escState escapeState) Transition(s state) error {
logger.Infof("Escape::Transition %s --> %s", escState.Name(), s.Name())
escState.BaseState.Transition(s)
escState.baseState.Transition(s)

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

return nil
}

func (escState EscapeState) Enter() error {
func (escState escapeState) Enter() error {
escState.parser.clear()
return nil
}
12 changes: 6 additions & 6 deletions ground_state.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package ansiterm

type GroundState struct {
BaseState
type groundState struct {
baseState
}

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

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

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

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

Expand Down
10 changes: 5 additions & 5 deletions osc_string_state.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package ansiterm

type OscStringState struct {
BaseState
type oscStringState struct {
baseState
}

func (oscState OscStringState) Handle(b byte) (s State, e error) {
func (oscState oscStringState) Handle(b byte) (s state, e error) {
logger.Infof("OscString::Handle %#x", b)
nextState, err := oscState.BaseState.Handle(b)
nextState, err := oscState.baseState.Handle(b)
if nextState != nil || err != nil {
return nextState, err
}

switch {
case isOscStringTerminator(b):
return oscState.parser.Ground, nil
return oscState.parser.ground, nil
}

return oscState, nil
Expand Down
Loading