1 |
|
2 | /*
|
3 | Terminal Kit
|
4 |
|
5 | Copyright (c) 2009 - 2020 Cédric Ronvel
|
6 |
|
7 | The MIT License (MIT)
|
8 |
|
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
10 | of this software and associated documentation files (the "Software"), to deal
|
11 | in the Software without restriction, including without limitation the rights
|
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13 | copies of the Software, and to permit persons to whom the Software is
|
14 | furnished to do so, subject to the following conditions:
|
15 |
|
16 | The above copyright notice and this permission notice shall be included in all
|
17 | copies or substantial portions of the Software.
|
18 |
|
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
25 | SOFTWARE.
|
26 | */
|
27 |
|
28 | ;
|
29 |
|
30 |
|
31 |
|
32 | const term = require( '..' ).terminal ;
|
33 | //const term = require( '..' ).realTerminal ;
|
34 |
|
35 | //*
|
36 | term.clear() ;
|
37 | term.moveTo( 1 , 1 ) ;
|
38 | term.bgGreen( 'abcde\nfghij\nklmno\npqrst\nuvwxy\n' ) ;
|
39 | term.moveTo( 3 , 3 ) ;
|
40 | //term.bgRed.deleteLine( 1 , '*' ) ;
|
41 | //term( '\x08\x08\x08\x08\x08\x08\x08*' ) ;
|
42 | //term( '\x7f\x7f' ) ;
|
43 | term( '\x1b[2X' , '*' ) ;
|
44 | //term.bgRed.delete() ;
|
45 | //term.bgRed.insertLine( 2 ) ;
|
46 | //term.inverse()( '!\r' ) ;
|
47 | //term.bgRed.eraseDisplayAbove() ;
|
48 | //term( '!' ) ;
|
49 | term.moveTo( 1 , 8 ) ;
|
50 | process.exit() ;
|
51 | //*/
|
52 |
|
53 | term( 'term.isTTY: %I\n' , term.isTTY ) ;
|
54 | term( 'a\n' )( 'true\n' )( 'warrior\n' ) ;
|
55 | term( term.esc.blue.on + 'Blue' + term.esc.blue.off ) ;
|
56 | term( 'normal' ) ;
|
57 | term.red( 'Red' ) ;
|
58 | term( ' normal' ) ;
|
59 | term.red( 'Red' ) ;
|
60 | term( ' normal' ) ;
|
61 | term.bold.underline.red( 'Bold-underline-red' ) ;
|
62 | term.green.strike( 'Green-strike' ) ;
|
63 | term.magenta.italic( 'Magenta-italic' ) ;
|
64 | term.blink( 'Blink' ) ;
|
65 | term( term.esc.blue.on + 'Blue' ) ;
|
66 | term.styleReset() ; term( 'normal\n' ) ;
|
67 | term( 'The terminal size is %dx%d' , term.width , term.height ) ;
|
68 | term.saveCursor() ;
|
69 |
|
70 | term.windowTitle( 'wonderful title' ) ;
|
71 |
|
72 | term.up( 4 ).red( 'up ' ).cyan( 4 ) ;
|
73 |
|
74 | term.moveTo( 1 , 1 ).blue( 'origin' ) ;
|
75 | term.move( 0 , 0 ).bold.cyan( '(0;0)' ) ;
|
76 | term.move( 5 , 5 ).bold.brightYellow( '(+5;+5)' ) ;
|
77 | term.move( -2 , -3 ) ; term.bold.brightGreen( '(-2;-3)' ) ;
|
78 | term.moveTo.cyan( 1 , 2 , "My name is %s, I'm %d.\n" , 'Jack' , 32 ) ;
|
79 | term.restoreCursor() ;
|
80 |
|
81 | var toto = term.str.red( 'toto' ) ;
|
82 | console.log( '\nconsole.log(toto):' , toto ) ;
|
83 |
|
84 | term.bgColor( 'red' , 'some red?' ) ;
|
85 | term( '\n' ) ;
|