1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | "use strict" ;
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | var terminal = require( '../lib/termkit.js' ) ;
|
37 |
|
38 |
|
39 |
|
40 | terminal.getDetectedTerminal( function( error , term ) {
|
41 |
|
42 | var i ;
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | term( 'This is the style test, each word should be styled accordingly with what it says it is.\n\n' ) ;
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | term.bold( '=== Foreground colors ===\n\n' ) ;
|
55 |
|
56 | term.white( 'white ' ).brightWhite( 'brightWhite' )( '\n' ) ;
|
57 | term.black( 'black ' ).brightBlack( 'brightBlack' )( '\n' ) ;
|
58 | term.red( 'red ' ).brightRed( 'brightRed' )( '\n' ) ;
|
59 | term.yellow( 'yellow ' ).brightYellow( 'brightYellow' )( '\n' ) ;
|
60 | term.green( 'green ' ).brightGreen( 'brightGreen' )( '\n' ) ;
|
61 | term.cyan( 'cyan ' ).brightCyan( 'brightCyan' )( '\n' ) ;
|
62 | term.blue( 'blue ' ).brightBlue( 'brightBlue' )( '\n' ) ;
|
63 | term.magenta( 'magenta ' ).brightMagenta( 'brightMagenta' )( '\n' ) ;
|
64 |
|
65 |
|
66 | for ( i = 0 ; i < 16 ; i ++ ) { term.color( i , '*' ) ; }
|
67 | term( '\n' ) ;
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | term.bold( '\n=== Background colors ===\n\n' ) ;
|
74 |
|
75 | term.bgWhite( 'bgWhite ' ).bgBrightWhite( 'bgBrightWhite' )( '\n' ) ;
|
76 | term.bgBlack( 'bgBlack ' ).bgBrightBlack( 'bgBrightBlack' )( '\n' ) ;
|
77 | term.bgRed( 'bgRed ' ).bgBrightRed( 'bgBrightRed' )( '\n' ) ;
|
78 | term.bgYellow( 'bgYellow ' ).bgBrightYellow( 'bgBrightYellow' )( '\n' ) ;
|
79 | term.bgGreen( 'bgGreen ' ).bgBrightGreen( 'bgBrightGreen' )( '\n' ) ;
|
80 | term.bgCyan( 'bgCyan ' ).bgBrightCyan( 'bgBrightCyan' )( '\n' ) ;
|
81 | term.bgBlue( 'bgBlue ' ).bgBrightBlue( 'bgBrightBlue' )( '\n' ) ;
|
82 | term.bgMagenta( 'bgMagenta ' ).bgBrightMagenta( 'bgBrightMagenta' )( '\n' ) ;
|
83 |
|
84 |
|
85 | for ( i = 0 ; i < 16 ; i ++ ) { term.bgColor( i , ' ' ) ; }
|
86 | term( '\n' ) ;
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | term.bold( '\n=== Styles ===\n\n' ) ;
|
93 |
|
94 | term.bold( 'bold' )( '\n' ) ;
|
95 | term.dim( 'dim' )( '\n' ) ;
|
96 | term.italic( 'italic' )( '\n' ) ;
|
97 | term.underline( 'underline' )( '\n' ) ;
|
98 | term.blink( 'blink' )( '\n' ) ;
|
99 | term.inverse( 'inverse' )( '\n' ) ;
|
100 | term.hidden( 'hidden' )( ' <-- hidden\n' ) ;
|
101 | term.strike( 'strike' )( '\n' ) ;
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | term.bold( '\n=== Mixed styles ===\n\n' ) ;
|
108 |
|
109 | term.bold.red( 'bold-red' )( '\n' ) ;
|
110 | term.dim.red( 'dim-red' )( '\n' ) ;
|
111 | term.bold.dim.red( 'bold-dim-red' )( '\n' ) ;
|
112 | term.cyan.bgRed( 'cyan-on-red' )( '\n' ) ;
|
113 | term.bold.cyan.bgRed( 'bold-cyan-on-red' )( '\n' ) ;
|
114 | term.bold.italic.underline( 'bold-italic-underline' )( '\n' ) ;
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | var attr ;
|
121 | attr = term.object2attr( { color: 'blue' , bgColor: 'red' , underline: true , italic: true } ) ;
|
122 | term( attr ) ;
|
123 | term( '\nAttr test' ) ;
|
124 | attr = term.object2attr( { color: 'blue' } ) ;
|
125 | term( attr ) ;
|
126 | term( '\nAttr test2' ) ;
|
127 |
|
128 |
|
129 |
|
130 | term( '\n' ) ;
|
131 | term.styleReset() ;
|
132 | term( 'Reset...\n' ) ;
|
133 |
|
134 | } ) ;
|
135 |
|