CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
readme.md297 linesDownload Raw Back to ansi-escapes
1# ansi-escapes2 3> [ANSI escape codes](https://www2.ccs.neu.edu/research/gpc/VonaUtils/vona/terminal/vtansi.htm) for manipulating the terminal4 5## Install6 7```sh8npm install ansi-escapes9```10 11## Usage12 13```js14import ansiEscapes from 'ansi-escapes';15 16// Moves the cursor two rows up and to the left17process.stdout.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);18//=> '\u001B[2A\u001B[1000D'19```20 21Or use named exports...22 23```js24import {cursorUp, cursorLeft} from 'ansi-escapes';25 26// etc, as above...27```28 29**You can also use it in the browser with Xterm.js:**30 31```js32import ansiEscapes from 'ansi-escapes';33import {Terminal} from 'xterm';34import 'xterm/css/xterm.css';35 36const terminal = new Terminal({…});37 38// Moves the cursor two rows up and to the left39terminal.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);40//=> '\u001B[2A\u001B[1000D'41```42 43## API44 45### cursorTo(x, y?)46 47Set the absolute position of the cursor. `x0` `y0` is the top left of the screen.48 49### cursorMove(x, y?)50 51Set the position of the cursor relative to its current position.52 53### cursorUp(count)54 55Move cursor up a specific amount of rows. Default is `1`.56 57### cursorDown(count)58 59Move cursor down a specific amount of rows. Default is `1`.60 61### cursorForward(count)62 63Move cursor forward a specific amount of columns. Default is `1`.64 65### cursorBackward(count)66 67Move cursor backward a specific amount of columns. Default is `1`.68 69### cursorLeft70 71Move cursor to the left side.72 73### cursorSavePosition74 75Save cursor position.76 77### cursorRestorePosition78 79Restore saved cursor position.80 81### cursorGetPosition82 83Get cursor position.84 85### cursorNextLine86 87Move cursor to the next line.88 89### cursorPrevLine90 91Move cursor to the previous line.92 93### cursorHide94 95Hide cursor.96 97### cursorShow98 99Show cursor.100 101### eraseLines(count)102 103Erase from the current cursor position up the specified amount of rows.104 105### eraseEndLine106 107Erase from the current cursor position to the end of the current line.108 109### eraseStartLine110 111Erase from the current cursor position to the start of the current line.112 113### eraseLine114 115Erase the entire current line.116 117### eraseDown118 119Erase the screen from the current line down to the bottom of the screen.120 121### eraseUp122 123Erase the screen from the current line up to the top of the screen.124 125### eraseScreen126 127Erase the screen and move the cursor the top left position.128 129### scrollUp130 131Scroll display up one line.132 133### scrollDown134 135Scroll display down one line.136 137### clearViewport138 139Clear only the visible terminal screen (viewport) without affecting scrollback buffer or terminal state.140 141This is a safer alternative to `clearScreen` that works consistently across terminals.142 143### clearScreen144 145Clear the terminal screen.146 147> [!WARNING]148> 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.149 150### clearTerminal151 152Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)153 154### enterAlternativeScreen155 156Enter the [alternative screen](https://terminalguide.namepad.de/mode/p47/).157 158### exitAlternativeScreen159 160Exit the [alternative screen](https://terminalguide.namepad.de/mode/p47/), assuming `enterAlternativeScreen` was called before.161 162### beginSynchronizedOutput163 164Begin [synchronized output](https://contour-terminal.org/vt-extensions/synchronized-output/) to reduce flicker during renders.165 166### endSynchronizedOutput167 168End [synchronized output](https://contour-terminal.org/vt-extensions/synchronized-output/).169 170### synchronizedOutput(text)171 172Wrap output in [synchronized output](https://contour-terminal.org/vt-extensions/synchronized-output/) sequences to reduce flicker during renders.173 174### beep175 176Output a beeping sound.177 178### link(text, url)179 180Create a clickable link.181 182[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) Use [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks) to detect link support.183 184### image(filePath, options?)185 186Display an image.187 188See [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.189 190#### input191 192Type: `Buffer`193 194Buffer of an image. Usually read in with `fs.readFile()`.195 196#### options197 198Type: `object`199 200##### width201##### height202 203Type: `string | number`204 205The width and height are given as a number followed by a unit, or the word "auto".206 207- `N`: N character cells.208- `Npx`: N pixels.209- `N%`: N percent of the session's width or height.210- `auto`: The image's inherent size will be used to determine an appropriate dimension.211 212##### preserveAspectRatio213 214Type: `boolean`\215Default: `true`216 217### setCwd(path?)218 219Type: `string`\220Default: `process.cwd()`221 222Set the current working directory for both iTerm2 and ConEmu.223 224### iTerm.setCwd(path?)225 226Type: `string`\227Default: `process.cwd()`228 229[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).230 231### ConEmu.setCwd(path?)232 233Type: `string`\234Default: `process.cwd()`235 236[Inform ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC) about shell current working directory.237 238### iTerm.annotation(message, options?)239 240Creates an escape code to display an "annotation" in iTerm2.241 242An annotation looks like this when shown:243 244<img src="https://user-images.githubusercontent.com/924465/64382136-b60ac700-cfe9-11e9-8a35-9682e8dc4b72.png" width="500">245 246See the [iTerm Proprietary Escape Codes documentation](https://iterm2.com/documentation-escape-codes.html) for more information.247 248#### message249 250Type: `string`251 252The message to display within the annotation.253 254The `|` character is disallowed and will be stripped.255 256#### options257 258Type: `object`259 260##### length261 262Type: `number`\263Default: The remainder of the line264 265Nonzero number of columns to annotate.266 267##### x268 269Type: `number`\270Default: Cursor position271 272Starting X coordinate.273 274Must be used with `y` and `length`.275 276##### y277 278Type: `number`\279Default: Cursor position280 281Starting Y coordinate.282 283Must be used with `x` and `length`.284 285##### isHidden286 287Type: `boolean`\288Default: `false`289 290Create a "hidden" annotation.291 292Annotations created this way can be shown using the "Show Annotations" iTerm command.293 294## Related295 296- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal297 
basant307/AI_Governance_Project · CoolFace