const FAKE_CURSOR_PATTERN = String.raw`\x1b\[7m([^\x1b]*)\x1b\[(?:0|27)m`; const INVERSE_VIDEO = new RegExp(FAKE_CURSOR_PATTERN, "g"); const FAKE_CURSOR = new RegExp(FAKE_CURSOR_PATTERN); export function hasFakeCursor(lines: readonly string[]): boolean { return lines.some((line) => FAKE_CURSOR.test(line)); } export function hideFakeCursor(line: string): string { return line.replace(INVERSE_VIDEO, "$1"); } export function replaceFakeCursor(line: string, replacement: string): string { return line.replace(INVERSE_VIDEO, replacement); }