source: trip-planner-front/node_modules/console-control-strings/README.md~@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.2 KB
Line 
1# Console Control Strings
2
3A library of cross-platform tested terminal/console command strings for
4doing things like color and cursor positioning. This is a subset of both
5ansi and vt100. All control codes included work on both Windows & Unix-like
6OSes, except where noted.
7
8## Usage
9
10```js
11var consoleControl = require('console-control-strings')
12
13console.log(consoleControl.color('blue','bgRed', 'bold') + 'hi there' + consoleControl.color('reset'))
14process.stdout.write(consoleControl.goto(75, 10))
15```
16
17## Why Another?
18
19There are tons of libraries similar to this one. I wanted one that was:
20
211. Very clear about compatibility goals.
222. Could emit, for instance, a start color code without an end one.
233. Returned strings w/o writing to streams.
244. Was not weighed down with other unrelated baggage.
25
26## Functions
27
28### var code = consoleControl.up(_num = 1_)
29
30Returns the escape sequence to move _num_ lines up.
31
32### var code = consoleControl.down(_num = 1_)
33
34Returns the escape sequence to move _num_ lines down.
35
36### var code = consoleControl.forward(_num = 1_)
37
38Returns the escape sequence to move _num_ lines righ.
39
40### var code = consoleControl.back(_num = 1_)
41
42Returns the escape sequence to move _num_ lines left.
43
44### var code = consoleControl.nextLine(_num = 1_)
45
46Returns the escape sequence to move _num_ lines down and to the beginning of
47the line.
48
49### var code = consoleControl.previousLine(_num = 1_)
50
51Returns the escape sequence to move _num_ lines up and to the beginning of
52the line.
53
54### var code = consoleControl.eraseData()
55
56Returns the escape sequence to erase everything from the current cursor
57position to the bottom right of the screen. This is line based, so it
58erases the remainder of the current line and all following lines.
59
60### var code = consoleControl.eraseLine()
61
62Returns the escape sequence to erase to the end of the current line.
63
64### var code = consoleControl.goto(_x_, _y_)
65
66Returns the escape sequence to move the cursor to the designated position.
67Note that the origin is _1, 1_ not _0, 0_.
68
69### var code = consoleControl.gotoSOL()
70
71Returns the escape sequence to move the cursor to the beginning of the
72current line. (That is, it returns a carriage return, `\r`.)
73
74### var code = consoleControl.hideCursor()
75
76Returns the escape sequence to hide the cursor.
77
78### var code = consoleControl.showCursor()
79
80Returns the escape sequence to show the cursor.
81
82### var code = consoleControl.color(_colors = []_)
83
84### var code = consoleControl.color(_color1_, _color2_, _…_, _colorn_)
85
86Returns the escape sequence to set the current terminal display attributes
87(mostly colors). Arguments can either be a list of attributes or an array
88of attributes. The difference between passing in an array or list of colors
89and calling `.color` separately for each one, is that in the former case a
90single escape sequence will be produced where as in the latter each change
91will have its own distinct escape sequence. Each attribute can be one of:
92
93* Reset:
94 * **reset** – Reset all attributes to the terminal default.
95* Styles:
96 * **bold** – Display text as bold. In some terminals this means using a
97 bold font, in others this means changing the color. In some it means
98 both.
99 * **italic** – Display text as italic. This is not available in most Windows terminals.
100 * **underline** – Underline text. This is not available in most Windows Terminals.
101 * **inverse** – Invert the foreground and background colors.
102 * **stopBold** – Do not display text as bold.
103 * **stopItalic** – Do not display text as italic.
104 * **stopUnderline** – Do not underline text.
105 * **stopInverse** – Do not invert foreground and background.
106* Colors:
107 * **white**
108 * **black**
109 * **blue**
110 * **cyan**
111 * **green**
112 * **magenta**
113 * **red**
114 * **yellow**
115 * **grey** / **brightBlack**
116 * **brightRed**
117 * **brightGreen**
118 * **brightYellow**
119 * **brightBlue**
120 * **brightMagenta**
121 * **brightCyan**
122 * **brightWhite**
123* Background Colors:
124 * **bgWhite**
125 * **bgBlack**
126 * **bgBlue**
127 * **bgCyan**
128 * **bgGreen**
129 * **bgMagenta**
130 * **bgRed**
131 * **bgYellow**
132 * **bgGrey** / **bgBrightBlack**
133 * **bgBrightRed**
134 * **bgBrightGreen**
135 * **bgBrightYellow**
136 * **bgBrightBlue**
137 * **bgBrightMagenta**
138 * **bgBrightCyan**
139 * **bgBrightWhite**
140
Note: See TracBrowser for help on using the repository browser.