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

Function eraseText

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

Source from the content-addressed store, hash-verified

1598 * Clears all lines taken up by the specified `text`.
1599 */
1600const eraseText = (text: string, columns: number): string => {
1601 if (columns === 0) {
1602 return Ansi.eraseLine + Ansi.cursorTo(0)
1603 }
1604 let rows = 0
1605 const lines = text.split(NEWLINE_REGEXP)
1606 for (const line of lines) {
1607 rows += 1 + Math.floor(Math.max(line.length - 1, 0) / columns)
1608 }
1609 return Ansi.eraseLines(rows)
1610}
1611
1612const lines = (prompt: string, columns: number): number => {
1613 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