UNPKG

@visulima/ansi

Version:

ANSI escape codes for some terminal swag.

32 lines (29 loc) 1.15 kB
import { D as DCS, a as ST, E as ESC } from './packem_shared/constants-CE7WkXh_.mjs'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); const SCREEN_MAX_LEN_DEFAULT = 0; const SCREEN_TYPICAL_LIMIT = 768; const screenPassthrough = /* @__PURE__ */ __name((sequence, limit = SCREEN_MAX_LEN_DEFAULT) => { let result = DCS; if (limit > 0 && sequence.length > limit) { for (let index = 0; index < sequence.length; index += limit) { const end = Math.min(index + limit, sequence.length); result += sequence.slice(index, end); if (end < sequence.length) { result += ST + DCS; } } } else { result += sequence; } result += ST; return result; }, "screenPassthrough"); const tmuxPassthrough = /* @__PURE__ */ __name((sequence) => { let escapedSequence = ""; for (const element of sequence) { escapedSequence += element === ESC ? ESC + ESC : element; } return `${DCS}tmux;${escapedSequence}${ST}`; }, "tmuxPassthrough"); export { SCREEN_MAX_LEN_DEFAULT, SCREEN_TYPICAL_LIMIT, screenPassthrough, tmuxPassthrough };