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 | //console.error( "\n\n\n\n\n\n\n\n" ) ;
|
33 | const termkit = require( '../..' ) ;
|
34 | const term = termkit.terminal ;
|
35 |
|
36 | term.clear() ;
|
37 |
|
38 | var document = term.createDocument( {
|
39 | palette: new termkit.Palette()
|
40 | // backgroundAttr: { bgColor: 'magenta' , dim: true } ,
|
41 | } ) ;
|
42 |
|
43 | var textTable = new termkit.TextTable( {
|
44 | parent: document ,
|
45 | cellContents: [
|
46 | //*
|
47 | [ 'header #1' , 'header #2' , 'header #3' ] ,
|
48 | [ 'row #1' , 'a much bigger cell '.repeat( 10 ) , 'cell' ] ,
|
49 | [ 'row #2' , 'cell' , 'a medium cell' ] ,
|
50 | [ 'row #3' , 'cell' , 'cell' ] ,
|
51 | [ 'row #4' , 'cell\nwith\nnew\nlines' , 'cell' ]
|
52 | //*/
|
53 | /*
|
54 | [ '1-1' , '2-1' , '3-1' ] ,
|
55 | [ '1-2' , '2-2' , '3-2' ] ,
|
56 | [ '1-3' , '2-3' , '3-3' ]
|
57 | //*/
|
58 | ] ,
|
59 | x: 0 ,
|
60 | y: 2 ,
|
61 | //hasBorder: false ,
|
62 | //borderChars: 'double' ,
|
63 | borderAttr: { color: 'blue' } ,
|
64 | textAttr: { bgColor: 'default' } ,
|
65 | //textAttr: { bgColor: 'black' } ,
|
66 | firstCellTextAttr: { bgColor: 'blue' } ,
|
67 | firstRowTextAttr: { bgColor: 'gray' } ,
|
68 | firstColumnTextAttr: { bgColor: 'red' } ,
|
69 | //checkerEvenCellTextAttr: { bgColor: 'gray' } ,
|
70 | //evenCellTextAttr: { bgColor: 'gray' } ,
|
71 | //evenRowTextAttr: { bgColor: 'gray' } ,
|
72 | //evenColumnTextAttr: { bgColor: 'gray' } ,
|
73 | width: 50 ,
|
74 | //width: term.width ,
|
75 | height: 15 ,
|
76 | fit: true , // Activate all expand/shrink + wordWrap
|
77 | //expandToWidth: true , shrinkToWidth: true , expandToHeight: true , shrinkToHeight: true , wordWrap: true ,
|
78 | //lineWrap: true ,
|
79 | } ) ;
|
80 |
|
81 |
|
82 | term.on( 'key' , function( key ) {
|
83 | switch( key ) {
|
84 | case 'CTRL_C' :
|
85 | term.grabInput( false ) ;
|
86 | term.hideCursor( false ) ;
|
87 | term.styleReset() ;
|
88 | term.clear() ;
|
89 | process.exit() ;
|
90 | break ;
|
91 | }
|
92 | } ) ;
|
93 |
|