]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/ansi/README.md
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / ansi / README.md
1 ansi.js
2 =========
3 ### Advanced ANSI formatting tool for Node.js
4
5 `ansi.js` is a module for Node.js that provides an easy-to-use API for
6 writing ANSI escape codes to `Stream` instances. ANSI escape codes are used to do
7 fancy things in a terminal window, like render text in colors, delete characters,
8 lines, the entire window, or hide and show the cursor, and lots more!
9
10 #### Features:
11
12  * 256 color support for the terminal!
13  * Make a beep sound from your terminal!
14  * Works with *any* writable `Stream` instance.
15  * Allows you to move the cursor anywhere on the terminal window.
16  * Allows you to delete existing contents from the terminal window.
17  * Allows you to hide and show the cursor.
18  * Converts CSS color codes and RGB values into ANSI escape codes.
19  * Low-level; you are in control of when escape codes are used, it's not abstracted.
20
21
22 Installation
23 ------------
24
25 Install with `npm`:
26
27 ``` bash
28 $ npm install ansi
29 ```
30
31
32 Example
33 -------
34
35 ``` js
36 var ansi = require('ansi')
37   , cursor = ansi(process.stdout)
38
39 // You can chain your calls forever:
40 cursor
41   .red()                 // Set font color to red
42   .bg.grey()             // Set background color to grey
43   .write('Hello World!') // Write 'Hello World!' to stdout
44   .bg.reset()            // Reset the bgcolor before writing the trailing \n,
45                          //      to avoid Terminal glitches
46   .write('\n')           // And a final \n to wrap things up
47
48 // Rendering modes are persistent:
49 cursor.hex('#660000').bold().underline()
50
51 // You can use the regular logging functions, text will be green:
52 console.log('This is blood red, bold text')
53
54 // To reset just the foreground color:
55 cursor.fg.reset()
56
57 console.log('This will still be bold')
58
59 // to go to a location (x,y) on the console
60 // note: 1-indexed, not 0-indexed:
61 cursor.goto(10, 5).write('Five down, ten over')
62
63 // to clear the current line:
64 cursor.horizontalAbsolute(0).eraseLine().write('Starting again')
65
66 // to go to a different column on the current line:
67 cursor.horizontalAbsolute(5).write('column five')
68
69 // Clean up after yourself!
70 cursor.reset()
71 ```
72
73
74 License
75 -------
76
77 (The MIT License)
78
79 Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>
80
81 Permission is hereby granted, free of charge, to any person obtaining
82 a copy of this software and associated documentation files (the
83 'Software'), to deal in the Software without restriction, including
84 without limitation the rights to use, copy, modify, merge, publish,
85 distribute, sublicense, and/or sell copies of the Software, and to
86 permit persons to whom the Software is furnished to do so, subject to
87 the following conditions:
88
89 The above copyright notice and this permission notice shall be
90 included in all copies or substantial portions of the Software.
91
92 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
93 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
94 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
95 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
96 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
97 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
98 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.