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 |
|
37 | var termkit = require( '../../lib/termkit.js' ) ;
|
38 | var term = termkit.terminal ;
|
39 |
|
40 |
|
41 |
|
42 | term.clear() ;
|
43 |
|
44 | var document = term.createDocument( {
|
45 |
|
46 | } ) ;
|
47 |
|
48 | var A = new termkit.Button( {
|
49 | parent: document ,
|
50 | content: '<A>' ,
|
51 | value: 'A' ,
|
52 | x: 0 ,
|
53 | y: 0 ,
|
54 | } ) ;
|
55 |
|
56 | new termkit.Button( {
|
57 | parent: A ,
|
58 | content: '<1>' ,
|
59 | value: '1' ,
|
60 | x: 10 ,
|
61 | y: 0 ,
|
62 | } ) ;
|
63 |
|
64 | new termkit.Button( {
|
65 | parent: A ,
|
66 | content: '<2>' ,
|
67 | value: '2' ,
|
68 | x: 10 ,
|
69 | y: 2 ,
|
70 | } ) ;
|
71 |
|
72 | new termkit.Button( {
|
73 | parent: A ,
|
74 | content: '<3>' ,
|
75 | value: '3' ,
|
76 | x: 10 ,
|
77 | y: 4 ,
|
78 | } ) ;
|
79 |
|
80 | var B = new termkit.Button( {
|
81 | parent: document ,
|
82 | content: '<B>' ,
|
83 | value: 'B' ,
|
84 | x: 0 ,
|
85 | y: 6 ,
|
86 | } ) ;
|
87 |
|
88 | var sub = new termkit.Button( {
|
89 | parent: B ,
|
90 | content: '<1>' ,
|
91 | value: '1' ,
|
92 | x: 10 ,
|
93 | y: 6 ,
|
94 | } ) ;
|
95 |
|
96 | new termkit.Button( {
|
97 | parent: sub ,
|
98 | content: '<...>' ,
|
99 | value: '...' ,
|
100 | x: 20 ,
|
101 | y: 6 ,
|
102 | } ) ;
|
103 |
|
104 | new termkit.Button( {
|
105 | parent: sub ,
|
106 | content: '<...>' ,
|
107 | value: '...' ,
|
108 | x: 30 ,
|
109 | y: 6 ,
|
110 | } ) ;
|
111 |
|
112 | new termkit.Button( {
|
113 | parent: sub ,
|
114 | content: '<...>' ,
|
115 | value: '...' ,
|
116 | x: 40 ,
|
117 | y: 6 ,
|
118 | } ) ;
|
119 |
|
120 | new termkit.Button( {
|
121 | parent: B ,
|
122 | content: '<2>' ,
|
123 | value: '2' ,
|
124 | x: 10 ,
|
125 | y: 8 ,
|
126 | } ) ;
|
127 |
|
128 | var sub2 = new termkit.Button( {
|
129 | parent: B ,
|
130 | content: '<3>' ,
|
131 | value: '3' ,
|
132 | x: 10 ,
|
133 | y: 10 ,
|
134 | } ) ;
|
135 |
|
136 | new termkit.Button( {
|
137 | parent: sub2 ,
|
138 | content: '<...>' ,
|
139 | value: '...' ,
|
140 | x: 20 ,
|
141 | y: 10 ,
|
142 | } ) ;
|
143 |
|
144 | new termkit.Button( {
|
145 | parent: sub2 ,
|
146 | content: '<...>' ,
|
147 | value: '...' ,
|
148 | x: 30 ,
|
149 | y: 10 ,
|
150 | } ) ;
|
151 |
|
152 | new termkit.Button( {
|
153 | parent: sub2 ,
|
154 | content: '<...>' ,
|
155 | value: '...' ,
|
156 | x: 40 ,
|
157 | y: 10 ,
|
158 | } ) ;
|
159 |
|
160 | var C = new termkit.Button( {
|
161 | parent: document ,
|
162 | content: '<C>' ,
|
163 | value: 'C' ,
|
164 | x: 0 ,
|
165 | y: 12 ,
|
166 | } ) ;
|
167 |
|
168 | new termkit.Button( {
|
169 | parent: C ,
|
170 | content: '<1>' ,
|
171 | value: '1' ,
|
172 | x: 10 ,
|
173 | y: 12 ,
|
174 | } ) ;
|
175 |
|
176 | new termkit.Button( {
|
177 | parent: C ,
|
178 | content: '<2>' ,
|
179 | value: '2' ,
|
180 | x: 10 ,
|
181 | y: 14 ,
|
182 | } ) ;
|
183 |
|
184 | var sub3 = new termkit.Button( {
|
185 | parent: C ,
|
186 | content: '<3>' ,
|
187 | value: '3' ,
|
188 | x: 10 ,
|
189 | y: 16 ,
|
190 | } ) ;
|
191 |
|
192 | new termkit.Button( {
|
193 | parent: sub3 ,
|
194 | content: '<...>' ,
|
195 | value: '...' ,
|
196 | x: 20 ,
|
197 | y: 16 ,
|
198 | } ) ;
|
199 |
|
200 | new termkit.Button( {
|
201 | parent: sub3 ,
|
202 | content: '<...>' ,
|
203 | value: '...' ,
|
204 | x: 30 ,
|
205 | y: 16 ,
|
206 | } ) ;
|
207 |
|
208 | new termkit.Button( {
|
209 | parent: sub3 ,
|
210 | content: '<...>' ,
|
211 | value: '...' ,
|
212 | x: 40 ,
|
213 | y: 16 ,
|
214 | } ) ;
|
215 |
|
216 |
|
217 | term.on( 'key' , function( key ) {
|
218 | switch( key )
|
219 | {
|
220 | case 'CTRL_C' :
|
221 | term.grabInput( false ) ;
|
222 | term.hideCursor( false ) ;
|
223 | term.styleReset() ;
|
224 | term.clear() ;
|
225 | process.exit() ;
|
226 | break ;
|
227 | }
|
228 | } ) ;
|
229 |
|
230 |
|
231 |
|