* Releases the line so other content can use it. * * @returns A promise that resolves when the line is released. * * @example Usage * ```ts ignore * import { delay } from "@std/async/delay"; * import { StaticLine } from "@std/cli/unstable-static-line"; * * const id = setIn
()
| 128 | * ``` |
| 129 | */ |
| 130 | async releaseLine(): Promise<void> { |
| 131 | if (this.#released) return; |
| 132 | this.#released = true; |
| 133 | const index = this.#lines.indexOf(this.#id); |
| 134 | this.#lines.splice(index, 1); |
| 135 | const rows = getRows(); |
| 136 | const top = linesAtTop.length + 1; |
| 137 | const bottom = rows - linesAtBottom.length; |
| 138 | await write( |
| 139 | Ansi.SAVE_CURSOR + |
| 140 | (this.#atTop |
| 141 | ? (top - index |
| 142 | ? Ansi.setScrollableRegion(index + 1, top + 1) + |
| 143 | Ansi.shiftUpAndInsert() |
| 144 | : Ansi.setCursorPosition(index + 1) + |
| 145 | Ansi.ERASE_LINE) |
| 146 | : (rows - index - bottom |
| 147 | ? Ansi.setScrollableRegion( |
| 148 | bottom, |
| 149 | rows - index, |
| 150 | ) + |
| 151 | Ansi.shiftDownAndInsert() |
| 152 | : Ansi.setCursorPosition(rows) + |
| 153 | Ansi.ERASE_LINE)) + |
| 154 | Ansi.setScrollableRegion(top, bottom) + |
| 155 | Ansi.RESTORE_CURSOR, |
| 156 | ); |
| 157 | } |
| 158 | } |