{"name":"ansi-escapes","version":"7.3.0","description":"ANSI escape codes for manipulating the terminal","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/ansi-escapes.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"ava && tsd","//test":"xo && ava && tsd"},"keywords":["ansi","terminal","console","cli","string","tty","escape","escapes","formatting","shell","xterm","log","logging","command-line","text","vt100","sequence","control","code","codes","cursor","iterm","iterm2","clear","screen","erase","scrollback"],"dependencies":{"environment":"^1.0.0"},"devDependencies":{"@types/node":"20.12.8","ava":"^6.1.2","tsd":"0.31.0","xo":"^0.58.0"},"gitHead":"73e652efe7a353bdf25f456e592c858e4648db3d","types":"./index.d.ts","_id":"ansi-escapes@7.3.0","bugs":{"url":"https://github.com/sindresorhus/ansi-escapes/issues"},"homepage":"https://github.com/sindresorhus/ansi-escapes#readme","_nodeVersion":"25.3.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-BvU8nYgGQBxcmMuEeUEmNTvrMVjJNSH7RgW24vXexN4Ven6qCvy4TntnvlnwnMLTVlcRQQdbRY8NKnaIoeWDNg==","shasum":"5395bb74b2150a4a1d6e3c2565f4aeca78d28627","tarball":"http://registry-npm.ywwl.com/ansi-escapes/download/ansi-escapes-7.3.0.tgz","fileCount":7,"unpackedSize":22023,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBCkyavXJUyZfpxcPSpa6o42wLnWRBVuiySHH5+SkeJ7AiEAzvHS3V/5fr3uqEpZABa0j2iUGlGQH5IWm3u7wz4Akqs="}],"size":6499,"noattachment":false,"key":"/ansi-escapes/-/ansi-escapes-7.3.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ansi-escapes_7.3.0_1770222070064_0.36798071422343104"},"_hasShrinkwrap":false,"readme":"# ansi-escapes\n\n> [ANSI escape codes](https://www2.ccs.neu.edu/research/gpc/VonaUtils/vona/terminal/vtansi.htm) for manipulating the terminal\n\n## Install\n\n```sh\nnpm install ansi-escapes\n```\n\n## Usage\n\n```js\nimport ansiEscapes from 'ansi-escapes';\n\n// Moves the cursor two rows up and to the left\nprocess.stdout.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);\n//=> '\\u001B[2A\\u001B[1000D'\n```\n\nOr use named exports...\n\n```js\nimport {cursorUp, cursorLeft} from 'ansi-escapes';\n\n// etc, as above...\n```\n\n**You can also use it in the browser with Xterm.js:**\n\n```js\nimport ansiEscapes from 'ansi-escapes';\nimport {Terminal} from 'xterm';\nimport 'xterm/css/xterm.css';\n\nconst terminal = new Terminal({…});\n\n// Moves the cursor two rows up and to the left\nterminal.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);\n//=> '\\u001B[2A\\u001B[1000D'\n```\n\n## API\n\n### cursorTo(x, y?)\n\nSet the absolute position of the cursor. `x0` `y0` is the top left of the screen.\n\n### cursorMove(x, y?)\n\nSet the position of the cursor relative to its current position.\n\n### cursorUp(count)\n\nMove cursor up a specific amount of rows. Default is `1`.\n\n### cursorDown(count)\n\nMove cursor down a specific amount of rows. Default is `1`.\n\n### cursorForward(count)\n\nMove cursor forward a specific amount of columns. Default is `1`.\n\n### cursorBackward(count)\n\nMove cursor backward a specific amount of columns. Default is `1`.\n\n### cursorLeft\n\nMove cursor to the left side.\n\n### cursorSavePosition\n\nSave cursor position.\n\n### cursorRestorePosition\n\nRestore saved cursor position.\n\n### cursorGetPosition\n\nGet cursor position.\n\n### cursorNextLine\n\nMove cursor to the next line.\n\n### cursorPrevLine\n\nMove cursor to the previous line.\n\n### cursorHide\n\nHide cursor.\n\n### cursorShow\n\nShow cursor.\n\n### eraseLines(count)\n\nErase from the current cursor position up the specified amount of rows.\n\n### eraseEndLine\n\nErase from the current cursor position to the end of the current line.\n\n### eraseStartLine\n\nErase from the current cursor position to the start of the current line.\n\n### eraseLine\n\nErase the entire current line.\n\n### eraseDown\n\nErase the screen from the current line down to the bottom of the screen.\n\n### eraseUp\n\nErase the screen from the current line up to the top of the screen.\n\n### eraseScreen\n\nErase the screen and move the cursor the top left position.\n\n### scrollUp\n\nScroll display up one line.\n\n### scrollDown\n\nScroll display down one line.\n\n### clearViewport\n\nClear only the visible terminal screen (viewport) without affecting scrollback buffer or terminal state.\n\nThis is a safer alternative to `clearScreen` that works consistently across terminals.\n\n### clearScreen\n\nClear the terminal screen.\n\n> [!WARNING]\n> This uses RIS (Reset to Initial State) which may also clear scrollback buffer in some terminals (xterm.js, VTE) and reset terminal modes. Consider using `clearViewport()` for safer viewport-only clearing.\n\n### clearTerminal\n\nClear the whole terminal, including scrollback buffer. (Not just the visible part of it)\n\n### enterAlternativeScreen\n\nEnter the [alternative screen](https://terminalguide.namepad.de/mode/p47/).\n\n### exitAlternativeScreen\n\nExit the [alternative screen](https://terminalguide.namepad.de/mode/p47/), assuming `enterAlternativeScreen` was called before.\n\n### beginSynchronizedOutput\n\nBegin [synchronized output](https://contour-terminal.org/vt-extensions/synchronized-output/) to reduce flicker during renders.\n\n### endSynchronizedOutput\n\nEnd [synchronized output](https://contour-terminal.org/vt-extensions/synchronized-output/).\n\n### synchronizedOutput(text)\n\nWrap output in [synchronized output](https://contour-terminal.org/vt-extensions/synchronized-output/) sequences to reduce flicker during renders.\n\n### beep\n\nOutput a beeping sound.\n\n### link(text, url)\n\nCreate a clickable link.\n\n[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) Use [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks) to detect link support.\n\n### image(filePath, options?)\n\nDisplay an image.\n\nSee [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.\n\n#### input\n\nType: `Buffer`\n\nBuffer of an image. Usually read in with `fs.readFile()`.\n\n#### options\n\nType: `object`\n\n##### width\n##### height\n\nType: `string | number`\n\nThe width and height are given as a number followed by a unit, or the word \"auto\".\n\n- `N`: N character cells.\n- `Npx`: N pixels.\n- `N%`: N percent of the session's width or height.\n- `auto`: The image's inherent size will be used to determine an appropriate dimension.\n\n##### preserveAspectRatio\n\nType: `boolean`\\\nDefault: `true`\n\n### setCwd(path?)\n\nType: `string`\\\nDefault: `process.cwd()`\n\nSet the current working directory for both iTerm2 and ConEmu.\n\n### iTerm.setCwd(path?)\n\nType: `string`\\\nDefault: `process.cwd()`\n\n[Inform iTerm2](https://www.iterm2.com/documentation-escape-codes.html) of the current directory to help semantic history and enable [Cmd-clicking relative paths](https://coderwall.com/p/b7e82q/quickly-open-files-in-iterm-with-cmd-click).\n\n### ConEmu.setCwd(path?)\n\nType: `string`\\\nDefault: `process.cwd()`\n\n[Inform ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC) about shell current working directory.\n\n### iTerm.annotation(message, options?)\n\nCreates an escape code to display an \"annotation\" in iTerm2.\n\nAn annotation looks like this when shown:\n\n<img src=\"https://user-images.githubusercontent.com/924465/64382136-b60ac700-cfe9-11e9-8a35-9682e8dc4b72.png\" width=\"500\">\n\nSee the [iTerm Proprietary Escape Codes documentation](https://iterm2.com/documentation-escape-codes.html) for more information.\n\n#### message\n\nType: `string`\n\nThe message to display within the annotation.\n\nThe `|` character is disallowed and will be stripped.\n\n#### options\n\nType: `object`\n\n##### length\n\nType: `number`\\\nDefault: The remainder of the line\n\nNonzero number of columns to annotate.\n\n##### x\n\nType: `number`\\\nDefault: Cursor position\n\nStarting X coordinate.\n\nMust be used with `y` and `length`.\n\n##### y\n\nType: `number`\\\nDefault: Cursor position\n\nStarting Y coordinate.\n\nMust be used with `x` and `length`.\n\n##### isHidden\n\nType: `boolean`\\\nDefault: `false`\n\nCreate a \"hidden\" annotation.\n\nAnnotations created this way can be shown using the \"Show Annotations\" iTerm command.\n\n## Related\n\n- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal\n","publish_time":1770222070230,"_cnpm_publish_time":1770222070230,"dist-tags":{"latest":"7.3.0"}}