...

Source file src/github.com/Azure/go-ansiterm/csi_entry_state.go

Documentation: github.com/Azure/go-ansiterm

     1  package ansiterm
     2  
     3  type csiEntryState struct {
     4  	baseState
     5  }
     6  
     7  func (csiState csiEntryState) Handle(b byte) (s state, e error) {
     8  	csiState.parser.logf("CsiEntry::Handle %#x", b)
     9  
    10  	nextState, err := csiState.baseState.Handle(b)
    11  	if nextState != nil || err != nil {
    12  		return nextState, err
    13  	}
    14  
    15  	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):
    21  		return csiState, csiState.parser.execute()
    22  	}
    23  
    24  	return csiState, nil
    25  }
    26  
    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)
    30  
    31  	switch s {
    32  	case csiState.parser.ground:
    33  		return csiState.parser.csiDispatch()
    34  	case csiState.parser.csiParam:
    35  		switch {
    36  		case sliceContains(csiParams, csiState.parser.context.currentChar):
    37  			csiState.parser.collectParam()
    38  		case sliceContains(intermeds, csiState.parser.context.currentChar):
    39  			csiState.parser.collectInter()
    40  		}
    41  	}
    42  
    43  	return nil
    44  }
    45  
    46  func (csiState csiEntryState) Enter() error {
    47  	csiState.parser.clear()
    48  	return nil
    49  }
    50  

View as plain text