| 1 | package ansitermscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/ |
| 2 | |
| 3 | import ( |
| 4 | "strconvscip-go gomod github.com/golang/go/src go1.16 strconv/" |
| 5 | ) |
| 6 | |
| 7 | func parseParamsscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/parseParams().(bytes []byte) ([]string, error) { |
| 8 | paramBuff := make([]byte, 0, 0) |
| 9 | params := []string{} |
| 10 | |
| 11 | for _, v := range bytes { |
| 12 | if v == ';' { |
| 13 | if len(paramBuff) > 0 { |
| 14 | // Completed parameter, append it to the list |
| 15 | s := string(paramBuff) |
| 16 | params = append(params, s) |
| 17 | paramBuff = make([]byte, 0, 0) |
| 18 | } |
| 19 | } else { |
| 20 | paramBuff = append(paramBuff, v) |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // Last parameter may not be terminated with ';' |
| 25 | if len(paramBuff) > 0 { |
| 26 | s := string(paramBuff) |
| 27 | params = append(params, s) |
| 28 | } |
| 29 | |
| 30 | return params, nil |
| 31 | } |
| 32 | |
| 33 | func parseCmdscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/parseCmd().(context ansiContextscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/ansiContext#) (string, error) { |
| 34 | return string(context.currentCharscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/ansiContext#currentChar.), nil |
| 35 | } |
| 36 | |
| 37 | func getIntscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/getInt().(params []string, dflt int) int { |
| 38 | i := getIntsscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/getInts().(params, 1, dflt)[0] |
| 39 | return i |
| 40 | } |
| 41 | |
| 42 | func getIntsscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/getInts().(params []string, minCount int, dflt int) []int { |
| 43 | ints := []int{} |
| 44 | |
| 45 | for _, v := range params { |
| 46 | i, _ := strconvscip-go gomod github.com/golang/go/src go1.16 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.16 strconv/Atoi().(v) |
| 47 | // Zero is mapped to the default value in VT100. |
| 48 | if i == 0 { |
| 49 | i = dflt |
| 50 | } |
| 51 | ints = append(ints, i) |
| 52 | } |
| 53 | |
| 54 | if len(ints) < minCount { |
| 55 | remaining := minCount - len(ints) |
| 56 | for i := 0; i < remaining; i++ { |
| 57 | ints = append(ints, dflt) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | return ints |
| 62 | } |
| 63 | |
| 64 | func (ap *AnsiParserscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#) modeDispatchscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#modeDispatch().(param string, set bool) error { |
| 65 | switch param { |
| 66 | case "?3": |
| 67 | return ap.eventHandlerscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#eventHandler..DECCOLMscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiEventHandler#DECCOLM.(set) |
| 68 | case "?6": |
| 69 | return ap.eventHandlerscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#eventHandler..DECOMscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiEventHandler#DECOM.(set) |
| 70 | case "?25": |
| 71 | return ap.eventHandlerscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#eventHandler..DECTCEMscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiEventHandler#DECTCEM.(set) |
| 72 | } |
| 73 | return nil |
| 74 | } |
| 75 | |
| 76 | func (ap *AnsiParserscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#) hDispatchscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#hDispatch().(params []string) error { |
| 77 | if len(params) == 1 { |
| 78 | return ap.modeDispatchscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#modeDispatch().(params[0], true) |
| 79 | } |
| 80 | |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | func (ap *AnsiParserscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#) lDispatchscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#lDispatch().(params []string) error { |
| 85 | if len(params) == 1 { |
| 86 | return ap.modeDispatchscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/AnsiParser#modeDispatch().(params[0], false) |
| 87 | } |
| 88 | |
| 89 | return nil |
| 90 | } |
| 91 | |
| 92 | func getEraseParamscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/getEraseParam().(params []string) int { |
| 93 | param := getIntscip-go gomod github.com/Azure/go-ansiterm . `github.com/Azure/go-ansiterm`/getInt().(params, 0) |
| 94 | if param < 0 || 3 < param { |
| 95 | param = 0 |
| 96 | } |
| 97 | |
| 98 | return param |
| 99 | } |