MCPcopy Create free account
hub / github.com/Facets-cloud/flow / quoteAppleScriptString

Function quoteAppleScriptString

internal/iterm/iterm.go:208–224  ·  view source on GitHub ↗

quoteAppleScriptString returns an AppleScript expression that evaluates to s. Lines are emitted as separate quoted strings joined with `& linefeed &`, because AppleScript double-quoted strings cannot contain literal newlines and there are no \n escape sequences inside the quotes. Tabs are similarly

(s string)

Source from the content-addressed store, hash-verified

206// contain literal newlines and there are no \n escape sequences inside
207// the quotes. Tabs are similarly handled with `& tab &`.
208func quoteAppleScriptString(s string) string {
209 // Split on newlines; for each line, also split on tabs.
210 lines := strings.Split(s, "\n")
211 parts := make([]string, 0, len(lines))
212 for i, line := range lines {
213 // Split each line on tabs, escape pieces, join with `& tab &`.
214 segs := strings.Split(line, "\t")
215 quoted := make([]string, len(segs))
216 for j, seg := range segs {
217 quoted[j] = `"` + escapeAppleScriptString(seg) + `"`
218 }
219 joined := strings.Join(quoted, " & tab & ")
220 parts = append(parts, joined)
221 _ = i
222 }
223 return strings.Join(parts, " & linefeed & ")
224}

Callers 1

SpawnTabFunction · 0.85

Calls 1

escapeAppleScriptStringFunction · 0.70

Tested by

no test coverage detected