{"_id":"ansi.js","_rev":"448449","name":"ansi.js","description":"ansi escape sequences for terminal cursor positioning and coloring","dist-tags":{"latest":"0.0.5"},"maintainers":[{"name":"bubkoo","email":""}],"time":{"modified":"2021-08-05T06:53:40.000Z","created":"2016-03-03T12:32:20.110Z","0.0.5":"2016-03-11T14:48:56.784Z","0.0.4":"2016-03-10T08:42:45.133Z","0.0.3":"2016-03-10T08:24:09.931Z","0.0.2":"2016-03-08T11:07:47.642Z","0.0.1":"2016-03-03T12:32:20.110Z"},"users":{},"author":{"name":"bubkoo"},"repository":{"type":"git","url":"git+https://github.com/bubkoo/ansi.js.git"},"versions":{"0.0.5":{"name":"ansi.js","version":"0.0.5","description":"ansi escape sequences for terminal cursor positioning and coloring","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/bubkoo/ansi.js.git"},"keywords":["ansi","escape","terminal","console","cursor","coloring","positioning","color","256","rgb","hex","stream"],"author":{"name":"bubkoo"},"license":"MIT","bugs":{"url":"https://github.com/bubkoo/ansi.js/issues"},"homepage":"https://github.com/bubkoo/ansi.js","dependencies":{"on-new-line":"0.0.1"},"gitHead":"1fc85392338b75d6c605b886c63d6cebca6ca34d","_id":"ansi.js@0.0.5","_shasum":"e3e9e45eb6977ba0eeeeed11677d12144675348c","_from":".","_npmVersion":"2.14.20","_nodeVersion":"4.4.0","_npmUser":{"name":"bubkoo","email":"bubkoo@163.com"},"dist":{"shasum":"e3e9e45eb6977ba0eeeeed11677d12144675348c","size":7498,"noattachment":false,"key":"/ansi.js/-/ansi.js-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/ansi.js/download/ansi.js-0.0.5.tgz"},"maintainers":[{"name":"bubkoo","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ansi.js-0.0.5.tgz_1457707736392_0.1981446749996394"},"directories":{},"publish_time":1457707736784,"_cnpm_publish_time":1457707736784,"_hasShrinkwrap":false},"0.0.4":{"name":"ansi.js","version":"0.0.4","description":"ansi escape sequences for terminal cursor positioning and coloring","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/bubkoo/ansi.js.git"},"keywords":["ansi","escape","terminal","console","cursor","coloring","positioning","color","256","rgb","hex","stream"],"author":{"name":"bubkoo"},"license":"MIT","bugs":{"url":"https://github.com/bubkoo/ansi.js/issues"},"homepage":"https://github.com/bubkoo/ansi.js","gitHead":"45c55fc5c40f1351067b029b1d52f7cf7e40de25","_id":"ansi.js@0.0.4","_shasum":"fc06ae93a266d89f22261ce895e20db92a598cd9","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"bubkoo","email":"bubkoo@163.com"},"dist":{"shasum":"fc06ae93a266d89f22261ce895e20db92a598cd9","size":7984,"noattachment":false,"key":"/ansi.js/-/ansi.js-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/ansi.js/download/ansi.js-0.0.4.tgz"},"maintainers":[{"name":"bubkoo","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ansi.js-0.0.4.tgz_1457599364756_0.4762030665297061"},"directories":{},"publish_time":1457599365133,"_cnpm_publish_time":1457599365133,"_hasShrinkwrap":false},"0.0.3":{"name":"ansi.js","version":"0.0.3","description":"ansi escape sequences for terminal cursor positioning and coloring","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/bubkoo/ansi.js.git"},"keywords":["ansi","escape","terminal","console","cursor","coloring","positioning","color","256","rgb","hex","stream"],"author":{"name":"bubkoo"},"license":"MIT","bugs":{"url":"https://github.com/bubkoo/ansi.js/issues"},"homepage":"https://github.com/bubkoo/ansi.js","gitHead":"94c3b609a09fce28101e7b19b266e001b6d81500","_id":"ansi.js@0.0.3","_shasum":"1b60da802db18162996f18eb06c26cfb2bc37c35","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"bubkoo","email":"bubkoo@163.com"},"dist":{"shasum":"1b60da802db18162996f18eb06c26cfb2bc37c35","size":7982,"noattachment":false,"key":"/ansi.js/-/ansi.js-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/ansi.js/download/ansi.js-0.0.3.tgz"},"maintainers":[{"name":"bubkoo","email":""}],"_npmOperationalInternal":{"host":"packages-13-west.internal.npmjs.com","tmp":"tmp/ansi.js-0.0.3.tgz_1457598247611_0.14900609711185098"},"directories":{},"publish_time":1457598249931,"_cnpm_publish_time":1457598249931,"_hasShrinkwrap":false},"0.0.2":{"name":"ansi.js","version":"0.0.2","description":"ansi escape sequences for terminal cursor positioning and coloring","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/bubkoo/ansi.js.git"},"keywords":["ansi","escape","terminal","console","cursor","coloring","positioning","color","256","rgb","hex","stream"],"author":{"name":"bubkoo"},"license":"MIT","bugs":{"url":"https://github.com/bubkoo/ansi.js/issues"},"homepage":"https://github.com/bubkoo/ansi.js","gitHead":"9c9ee7ba8ede86810ff6d8140ced1e2c8acf1dfc","_id":"ansi.js@0.0.2","_shasum":"338997970fa599e88ce4a1b7e5a3e9a739dff46b","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"bubkoo","email":"bubkoo@163.com"},"dist":{"shasum":"338997970fa599e88ce4a1b7e5a3e9a739dff46b","size":7900,"noattachment":false,"key":"/ansi.js/-/ansi.js-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/ansi.js/download/ansi.js-0.0.2.tgz"},"maintainers":[{"name":"bubkoo","email":""}],"_npmOperationalInternal":{"host":"packages-13-west.internal.npmjs.com","tmp":"tmp/ansi.js-0.0.2.tgz_1457435263816_0.37046837876550853"},"directories":{},"publish_time":1457435267642,"_cnpm_publish_time":1457435267642,"_hasShrinkwrap":false},"0.0.1":{"name":"ansi.js","version":"0.0.1","description":"ansi control sequences for terminal cursor hopping and colors","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/bubkoo/ansi.js.git"},"keywords":["ansi","terminal","console","color","cursor","sequence","escape","control","stream","256","rgb","formatting"],"author":{"name":"bubkoo"},"license":"MIT","bugs":{"url":"https://github.com/bubkoo/ansi.js/issues"},"homepage":"https://github.com/bubkoo/ansi.js","gitHead":"d555b39a46c8d89aff11c132ad2bea85e4121dcc","_id":"ansi.js@0.0.1","_shasum":"6d4a20043848cdf3641df693a56b522510caed09","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"bubkoo","email":"bubkoo@163.com"},"dist":{"shasum":"6d4a20043848cdf3641df693a56b522510caed09","size":3395,"noattachment":false,"key":"/ansi.js/-/ansi.js-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/ansi.js/download/ansi.js-0.0.1.tgz"},"maintainers":[{"name":"bubkoo","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ansi.js-0.0.1.tgz_1457008339140_0.7784652749542147"},"directories":{},"publish_time":1457008340110,"_cnpm_publish_time":1457008340110,"_hasShrinkwrap":false}},"readme":"# ansi.js\n\n> ansi escape sequences for terminal cursor positioning and coloring.\n\n\n[![MIT License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat-square)](https://github.com/bubkoo/ansi.js/blob/master/LICENSE)\n \n[![NPM](https://nodei.co/npm/ansi.js.png)](https://nodei.co/npm/ansi.js/)\n \n\n`ansi.js` provides many easy-to-use methods for writing ANSI escape codes to \n`Stream` instances. ANSI escape codes are used to do fancy things in a terminal \nwindow, such as, positioning the cursor, coloring the text, erasing characters, \nlines or even the entire window, or hide and show the cursor, and many others.\n\n\n## Install\n  \nFirst make sure you have installed the latest version of [node.js](http://nodejs.org/) \n(You may need to restart your computer after this step).\n\nInstall with npm:\n\n```\n$ npm install ansi.js --save\n```\n\n\n## Usage\n\n```js\n\nvar ansi   = require('ansi.js');\nvar cursor = ansi(process.stdout);\n\n// You can chain your calls forever:\ncursor\n  .red()                 // set font color to red\n  .bg.grey()             // set background color to grey\n  .write('Hello World!') // write 'Hello World!' to stdout\n  .bg.reset().end()      // reset the bgcolor before writing the trailing \\n,\n                         // `end()` for chain calling.\n  .write('\\n');          // add a final \\n to wrap things up avoiding Terminal glitches\n\n// Rendering modes are persistent:\ncursor\n  .hex('#660000')\n  .bold()\n  .underline();\n\n// You can use the regular logging functions, text will be green:\nconsole.log('This is blood red, bold text.');\n\n// To reset just the foreground color:\ncursor.fg.reset();\n\nconsole.log('This will still be bold.');\n\n// move the cursor to an absolute location (x,y)\n// note: 1-indexed, not 0-indexed:\ncursor\n  .moveTo(10, 5)\n  .write('Five down, ten over.');\n\n// to clear the current line:\ncursor\n  .moveToColumn(0)\n  .eraseLine()\n  .write('Starting again');\n\n// to go to a different column on the current line:\ncursor\n  .moveToColumn(5)\n  .write('column five');\n\n// clean up\ncursor.reset();\n\n```\n\n\n## Constructor\n\n```js\nvar ansi   = require('ansi.js');\nvar cursor = ansi(stream, options);\n```\n\n### stream\n\nAny `Stream` instance, for terminal it would be `process.stdout`.\n\n\n### options\n\n#### `enabled`\n\nWhen `enabled` is `false` then all the methods are no-ops except for `write()`.\nDefault `true`.\n\n#### `buffering`\n\nWhen `buffering` is true, then `write()` calls are buffered in memory until `flush()` is invoked.\n\nDefault `false`.\n\n#### `lineTrack`\n\nKeep track of the number of `newline` that get encountered.\n\nDefault `false`.\n\n\n## Properties\n\n\n### stream\n\nThe `Stream` instance.\n\n\n### enabled\n\nPassed by `options`, when `enabled` is false then all the methods are no-ops except for `write()`.\n\n\n### buffering\n\nPassed by `options`, when `buffering` is true, then `write()` calls are buffered in memory until `flush()` is invoked.\n\n### newline\n \nThe number of new line that get encountered when `options.lineTrack` is `true`.\n\n### fg/foreground\n\nInstance of `Colour`, provides many useful methods for setting foreground color.\n\n\n#### Set by color names: `cursor.fg.white()`\n\nValid color name methods:\n\n- black()\n- red()\n- green()\n- yellow()\n- blue()\n- magenta()\n- cyan()\n- white()\n- grey()\n- brightBlack()\n- brightRed()\n- brightGreen()\n- brightYellow()\n- brightBlue()\n- brightMagenta()\n- brightCyan()\n- brightWhite()\n\n\n#### Set by `rgb(r, g, b)`\n\nArguments are the values of color channels, should be `0-255`. \n\n\n#### Set by `hex(color)`\n\n`color` is CSS color string, such as: `\"#FF0000\"`\n\n**PS:** All the above methods of `bg` was attached on `cursor` with the \nsame method name. And these methods are chainable:\n\n```js\ncursor\n  .blue()\n  .write('This is blue.')\n  .green()\n  .write('this is green.');\n\n// with the `fg` property\ncursor\n  .fg.blue().end()\n  .write('This is blue.')\n  .fg.green().end()\n  .write('this is green.');\n```\n\n\n#### `end()`\n\nEnd the methods calling of `bg`, return `Cursor` instance for chain calling.\n\n\n#### `reset()`\n\nReset the current foreground color to the default setting.\n\n\n### bg/background\n\nInstance of `Colour`, provides many useful methods for setting background color. \nThis property has all the same methods of `fg`, but these methods are not be \nattached on `Curosr` instance, you can use it like this:\n\n\n```js\ncursor\n  .bg.blue().end()\n  .write('This background is blue.')\n  .bg.green().end()\n  .write('this background is green.');\n```\n\n### font\n\nInstance of `Font`, for setting font styles with these methods:\n\n- bold()\n- italic()\n- underline()\n- inverse()\n- resetBold()\n- resetItalic()\n- resetUnderline()\n- resetInverse()\n- end()\n\nAnd these methods are attached on `Curosr` instance:\n\n```is\ncursor\n  .font.bold().italic().end()\n  .write('This will be bold and italic.')\n  .resetItalic()\n  .underline()\n  .write('This will be bold and underline.');\n```\n\n\n### display\n\nInstance of `Display`, setting the display mode with the these methods:\n\n- dim()\n- blink()\n- hidden()\n- bright()\n- reverse()\n- underscore()\n- reset()\n\n\n### newlines\n\nKeep track of the number of `newline` that get encountered.\n\n\n## Methods\n\n\n### enable() & disable()\n\nUpdate the `cursor.enabled`, When `cursor.enabled` is false then all the \nmethods are no-ops except for `write()`.\n\n\n### write(data)\n\nHelper method that calls `write()` on the underlying Stream.\n\n\n### buffer()\n\nSet `cursor.buffering` truly, when `cursor.buffering` is true, then `write()` \ncalls are buffered in memory until `flush()` is invoked.\n\n\n### flush()\n\nWrite out the in-memory buffer, then set `cursor.buffering` falsely.\n\n\n### move(x, y)\n\nMove the cursor position by the relative coordinates `x`, `y`.\n\n\n### moveTo(x, y)\n\nSet the cursor position to the absolute coordinates `x`, `y`.\n\n\n### moveUp(count)\n\nMove the cursor up by `count` (default `1`) rows.\n\n\n### moveDown(count)\n\nMove the cursor down by `count` (default `1`) rows.\n\n\n### backward(count)\n\nMove the cursor backward by `count` (default `1`) columns.\n\n\n### forward(count)\n\nMove the cursor forward by `count` (default `1`) columns.\n\n\n### nextLine(n)\n\nMove cursor to beginning of the line `n` (default `1`) lines down.\n\n\n### prevLine(n)\n\nMove cursor to beginning of the line `n` (default `1`) lines up.\n\n\n### moveToColumn(n)\n\nMoves the cursor to column `n` (default `1`).\n\n\n### scrollUp(n)\n\nScroll whole page up by `n` (default `1`) lines. \nNew lines are added at the bottom.\n\n\n### scrollDown()\n\nScroll whole page down by `n` (default `1`) lines. \nNew lines are added at the top.\n\n\n### erase(type)\n\nClear part of the screen or line defined by the string `type`. \n\n- end - clear from the cursor to the end of the line\n- start - clear from the cursor to the start of the line\n- line - clear the current line\n- down - clear everything below the current line\n- up - clear everything above the current line\n- screen - clear the entire screen\n\n\n### eraseRight()\n\nClear from cursor to the end of the line. Cursor position does not change.\n\n\n### eraseLeft()\n\nClear from cursor to the start of the line. Cursor position does not change.\n\n\n### eraseLine()\n\nClear the current line. Cursor position does not change.\n\n\n### eraseUp()\n\nClear from cursor to beginning of the screen.\n\n\n### eraseDown()\n\nClear from cursor to end of screen.\n\n\n### eraseScreen()\n\nClear entire screen. And moves cursor to upper left on DOS\n\n\n### delete(mode, n)\n\nDelete 'line' or 'char's. delete differs from erase because it does not write over the deleted characters with whitesapce, but instead removes the deleted space.\n\nmode can be 'line' or 'char'. n is the number of items to be deleted. n must be a positive integer.\n\nThe cursor position is not updated.\n\n### deleteLine(n)\n\n\n### deleteChar(n)\n\n\n### insert(mode, n)\n\nInsert space into the terminal. insert is the opposite ofdelete, and the arguments are the same.\n\n\n### beep()\n\nOutput a beeping sound.\n\n\n### show() & hide()\n\nShow/Hide cursor.\n\n\n### save(withAttributes) & restore(withAttributes)\n\nSave/Restore the cursor position and optionally the attribute state.\n\n\n### reset()\n\nReset all terminal settings to default.\n\n\n### Attached methods of `foreground` property\n\nThese methods are used for setting the foreground color.\n\n- black()\n- red()\n- green()\n- yellow()\n- blue()\n- magenta()\n- cyan()\n- white()\n- grey()\n- brightBlack()\n- brightRed()\n- brightGreen()\n- brightYellow()\n- brightBlue()\n- brightMagenta()\n- brightCyan()\n- brightWhite()\n- rgb(r, g, b)\n- hex(color)\n\n\n### Attached methods of `font` property\n\nThese methods are used for setting the font style.\n\n- bold()\n- italic()\n- underline()\n- inverse()\n- resetBold()\n- resetItalic()\n- resetUnderline()\n- resetInverse()\n\n\n### Attached methods of `display` property\n\nThese methods are used for setting the display mode.\n\n- dim()\n- blink()\n- hidden()\n- bright()\n- reverse()\n- underscore()\n\n\n## License\n\n[MIT](https://github.com/bubkoo/ansi.js/blob/master/LICENSE) © bubkoo\n\n","_attachments":{},"homepage":"https://github.com/bubkoo/ansi.js","bugs":{"url":"https://github.com/bubkoo/ansi.js/issues"},"license":"MIT"}