MCPcopy Create free account
hub / github.com/denoland/std / releaseLine

Method releaseLine

cli/unstable_static_line.ts:130–157  ·  view source on GitHub ↗

* 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

()

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 1

writeFunction · 0.50

Tested by

no test coverage detected