( input: typeof Deno.stdin, output: typeof Deno.stdout, )
| 207 | } |
| 208 | |
| 209 | function 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 | } |
no test coverage detected