MCPcopy Create free account
hub / github.com/Effect-TS/effect / eraseText

Function eraseText

packages/effect/src/unstable/cli/Prompt.ts:1420–1430  ·  view source on GitHub ↗
(text: string, columns: number)

Source from the content-addressed store, hash-verified

1418 * Clears all lines taken up by the specified `text`.
1419 */
1420const eraseText = (text: string, columns: number): string => {
1421 if (columns === 0) {
1422 return Ansi.eraseLine + Ansi.cursorTo(0)
1423 }
1424 let rows = 0
1425 const lines = text.split(NEWLINE_REGEXP)
1426 for (const line of lines) {
1427 rows += 1 + Math.floor(Math.max(line.length - 1, 0) / columns)
1428 }
1429 return Ansi.eraseLines(rows)
1430}
1431
1432const lines = (prompt: string, columns: number): number => {
1433 const lines = prompt.split(NEWLINE_REGEXP)

Callers 6

clearOutputWithErrorFunction · 0.85
handleConfirmClearFunction · 0.85
handleFileClearFunction · 0.85
handleSelectClearFunction · 0.85
handleAutoCompleteClearFunction · 0.85
Prompt.tsFile · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected