From 11231de35245c0fafab78503797275d2dc243eb5 Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Mon, 19 Feb 2024 13:56:17 +0100 Subject: [PATCH] feat(text-format): add common ANSI escape seqs --- packages/text-format/src/ansi.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/text-format/src/ansi.ts b/packages/text-format/src/ansi.ts index 69626d0ec1..4423ec2704 100644 --- a/packages/text-format/src/ansi.ts +++ b/packages/text-format/src/ansi.ts @@ -2,7 +2,19 @@ import { memoize1 } from "@thi.ng/memoize/memoize1"; import type { StringFormat } from "./api.js"; import { defFormat } from "./format.js"; -const ANSI_RESET = `\x1b[0m`; +export const ANSI_RESET = "\x1b[0m"; + +// https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec#control-sequence +export const ANSI_SYNC_START = "\x1bP=1s\x1b\\"; +export const ANSI_SYNC_END = "\x1bP=2s\x1b\\"; + +// https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797 +export const ANSI_HOME = "\x1b[H"; +export const ANSI_HOME_LINE = "\x1b[0G"; +export const ANSI_HOME_PREV_LINE = "\x1b[1F"; + +export const ANSI_CLEAR_SCREEN = "\x1b[2J"; +export const ANSI_CLEAR_LINE = "\x1b[2K"; const ANSI_FLAGS = ["", "1", "2", "1;2", "4", "1;4", "2;4", "1;2;4"];