MCPcopy Create free account
hub / github.com/cli/cli / screenText

Function screenText

script/ghmock/terminal.go:128–140  ·  view source on GitHub ↗

screenText is the terminal's screen as text, without trailing spaces or blank lines at the bottom.

(term vt10x.Terminal)

Source from the content-addressed store, hash-verified

126// screenText is the terminal's screen as text, without trailing spaces or
127// blank lines at the bottom.
128func screenText(term vt10x.Terminal) string {
129 lines := strings.Split(term.String(), "\n")
130 for i, line := range lines {
131 lines[i] = strings.TrimRight(line, " ")
132 }
133 for len(lines) > 0 && lines[len(lines)-1] == "" {
134 lines = lines[:len(lines)-1]
135 }
136 if len(lines) == 0 {
137 return ""
138 }
139 return strings.Join(lines, "\n") + "\n"
140}
141
142// lockedWriter lets ghmock's typing and the terminal's answers to gh share
143// the pseudo-terminal without interleaving.

Callers 1

runInTerminalFunction · 0.85

Calls 2

JoinMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected