MCPcopy Create free account
hub / github.com/Mister-leo/fssh / cleanLinerInput

Function cleanLinerInput

cmd/fssh/shell_commands.go:15–39  ·  view source on GitHub ↗

cleanLinerInput 清理 liner 输入,移除 ANSI 转义序列和控制字符

(input string)

Source from the content-addressed store, hash-verified

13
14// cleanLinerInput 清理 liner 输入,移除 ANSI 转义序列和控制字符
15func cleanLinerInput(input string) string {
16 input = strings.TrimSpace(input)
17 var cleaned strings.Builder
18 inEscape := false
19 for _, r := range input {
20 if r == '\x1b' || r == '\033' {
21 inEscape = true
22 continue
23 }
24 if inEscape {
25 if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') {
26 inEscape = false
27 }
28 continue
29 }
30 if r < 32 || r == 127 {
31 continue
32 }
33 if r == '\u3000' || r == '\u00A0' {
34 continue
35 }
36 cleaned.WriteRune(r)
37 }
38 return strings.TrimSpace(cleaned.String())
39}
40
41// ShellContext holds state for shell commands
42type ShellContext struct {

Callers 4

cmdAddFunction · 0.85
cmdEditFunction · 0.85
cmdDeleteFunction · 0.85
cmdGlobalEditFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected