UNPKG

@visulima/ansi

Version:

ANSI escape codes for some terminal swag.

39 lines (34 loc) 1.46 kB
'use strict'; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); const constants = require('./packem_shared/constants-BK26O-46.cjs'); 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 = constants.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 += constants.ST + constants.DCS; } } } else { result += sequence; } result += constants.ST; return result; }, "screenPassthrough"); const tmuxPassthrough = /* @__PURE__ */ __name((sequence) => { let escapedSequence = ""; for (const element of sequence) { escapedSequence += element === constants.ESC ? constants.ESC + constants.ESC : element; } return `${constants.DCS}tmux;${escapedSequence}${constants.ST}`; }, "tmuxPassthrough"); exports.SCREEN_MAX_LEN_DEFAULT = SCREEN_MAX_LEN_DEFAULT; exports.SCREEN_TYPICAL_LIMIT = SCREEN_TYPICAL_LIMIT; exports.screenPassthrough = screenPassthrough; exports.tmuxPassthrough = tmuxPassthrough;