package parserimport// Shift and masks for sequence parameters and intermediates.const (PrefixShift = 8IntermedShift = 16FinalMask = 0xffHasMoreFlag = math.MinInt32ParamMask = ^HasMoreFlagMissingParam = ParamMaskMissingCommand = MissingParamMaxParam = math.MaxUint16// the maximum value a parameter can have)const (// MaxParamsSize is the maximum number of parameters a sequence can have.MaxParamsSize = 32// DefaultParamValue is the default value used for missing parameters.DefaultParamValue = 0)// Prefix returns the prefix byte of the sequence.// This is always gonna be one of the following '<' '=' '>' '?' and in the// range of 0x3C-0x3F.// Zero is returned if the sequence does not have a prefix.func ( int) int {return ( >> PrefixShift) & FinalMask}// Intermediate returns the intermediate byte of the sequence.// An intermediate byte is in the range of 0x20-0x2F. This includes these// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+',// ',', '-', '.', '/'.// Zero is returned if the sequence does not have an intermediate byte.func ( int) int {return ( >> IntermedShift) & FinalMask}// Command returns the command byte of the CSI sequence.func ( int) int {return & FinalMask}// Param returns the parameter at the given index.// It returns -1 if the parameter does not exist.func ( []int, int) int {iflen() == 0 || < 0 || >= len() {return -1 } := [] & ParamMaskif == MissingParam {return -1 }return}// HasMore returns true if the parameter has more sub-parameters.func ( []int, int) bool {iflen() == 0 || >= len() {returnfalse }return []&HasMoreFlag != 0}// Subparams returns the sub-parameters of the given parameter.// It returns nil if the parameter does not exist.func ( []int, int) []int {iflen() == 0 || < 0 || >= len() {returnnil }// Count the number of parameters before the given parameter index.varintvarintfor = range {if == {break }if !HasMore(, ) { ++ } }if > || >= len() {returnnil }var []intfor ; < len(); ++ {if !HasMore(, ) {break } := Param(, )if == -1 { = DefaultParamValue } = append(, ) } := Param(, )if == -1 { = DefaultParamValue }returnappend(, )}// Len returns the number of parameters in the sequence.// This will return the number of parameters in the sequence, excluding any// sub-parameters.func ( []int) int {varintfor := range {if !HasMore(, ) { ++ } }return}// Range iterates over the parameters of the sequence and calls the given// function for each parameter.// The function should return false to stop the iteration.func ( []int, func( int, int, bool) bool) {for := range {if !(, Param(, ), HasMore(, )) {break } }}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)