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

Function getCursorRow

cli/_prompt_select.ts:209–227  ·  view source on GitHub ↗
(
  input: typeof Deno.stdin,
  output: typeof Deno.stdout,
)

Source from the content-addressed store, hash-verified

207}
208
209function getCursorRow(
210 input: typeof Deno.stdin,
211 output: typeof Deno.stdout,
212): number | undefined {
213 output.writeSync(QUERY_CURSOR_POSITION);
214
215 const buffer = new Uint8Array(32);
216 const n = input.readSync(buffer);
217 if (n === null || n === 0) return undefined;
218
219 const response = decoder.decode(buffer.subarray(0, n)).trim();
220
221 // deno-lint-ignore no-control-regex
222 const match = response.match(/\x1b\[(\d+);(\d+)R/);
223 if (match) {
224 return parseInt(match[1]!, 10);
225 }
226 return undefined;
227}

Callers 1

handlePromptSelectFunction · 0.85

Calls 3

matchMethod · 0.80
writeSyncMethod · 0.65
readSyncMethod · 0.65

Tested by

no test coverage detected