diff --git a/src/common/editor/ansi.ts b/src/common/editor/ansi.ts index f46f649..bb5c20a 100644 --- a/src/common/editor/ansi.ts +++ b/src/common/editor/ansi.ts @@ -8,12 +8,14 @@ function esc(pieces: TemplateStringsArray): string { * ANSI escapes for various inputs */ export enum KeyCommand { - ArrowUp = `${ANSI_PREFIX}A`, - ArrowDown = `${ANSI_PREFIX}B`, - ArrowRight = `${ANSI_PREFIX}C`, - ArrowLeft = `${ANSI_PREFIX}D`, - PageUp = `${ANSI_PREFIX}5~`, - PageDown = `${ANSI_PREFIX}6~`, + ArrowUp = ANSI_PREFIX + 'A', + ArrowDown = ANSI_PREFIX + 'B', + ArrowRight = ANSI_PREFIX + 'C', + ArrowLeft = ANSI_PREFIX + 'D', + PageUp = ANSI_PREFIX + '5~', + PageDown = ANSI_PREFIX + '6~', + + // These keys have several possible escape sequences Home = 'LineHome', End = 'LineEnd', } @@ -30,10 +32,10 @@ export const Ansi = { row++; col++; - return `\x1b[${row};${col}H`; + return ANSI_PREFIX + `${row};${col}H`; }, - moveCursorForward: (col: number): string => `${ANSI_PREFIX}${col}C`, - moveCursorDown: (row: number): string => `${ANSI_PREFIX}${row}B`, + moveCursorForward: (col: number): string => ANSI_PREFIX + `${col}C`, + moveCursorDown: (row: number): string => ANSI_PREFIX + `${row}B`, }; export default Ansi;