(options: FileOptions)
| 86 | } |
| 87 | |
| 88 | function handleClear(options: FileOptions) { |
| 89 | return (state: State, _: Prompt.Prompt.Action<State, string>) => { |
| 90 | return Effect.gen(function*() { |
| 91 | const terminal = yield* Terminal.Terminal |
| 92 | const columns = yield* terminal.columns |
| 93 | const currentPath = yield* resolveCurrentPath(state.path, options) |
| 94 | const text = "\n".repeat(Math.min(state.files.length, options.maxPerPage)) |
| 95 | const clearPath = InternalAnsiUtils.eraseText(currentPath, columns) |
| 96 | const message = showConfirmation(state.confirm) ? CONFIRM_MESSAGE : options.message |
| 97 | const clearPrompt = InternalAnsiUtils.eraseText(`\n${message}`, columns) |
| 98 | const clearOptions = InternalAnsiUtils.eraseText(text, columns) |
| 99 | return clearOptions.pipe( |
| 100 | Doc.cat(clearPath), |
| 101 | Doc.cat(clearPrompt), |
| 102 | Optimize.optimize(Optimize.Deep), |
| 103 | Doc.render({ style: "pretty", options: { lineWidth: columns } }) |
| 104 | ) |
| 105 | }) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | const NEWLINE_REGEX = /\r?\n/ |
| 110 |
no test coverage detected