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 string = require( 'string-kit' ) ;
|
33 | const termkit = require( '..' ) ;
|
34 | const term = termkit.terminal ;
|
35 | const SB = termkit.ScreenBufferHD ;
|
36 | const Promise = require( 'seventh' ) ;
|
37 |
|
38 |
|
39 |
|
40 | async function test() {
|
41 | var attr ;
|
42 | var fwa = string.unicode.toFullWidth( '@' ) ; // Get a full-width arobas
|
43 | var fwz = string.unicode.toFullWidth( '0' ) ; // Get a full-width arobas
|
44 |
|
45 | term.clear() ;
|
46 |
|
47 | var buffer = SB.create( { dst: term , width: 4 , height: 5 } ) ;
|
48 | var buffer2 = SB.create( { dst: buffer , width: 4 , height: 5 } ) ;
|
49 |
|
50 | //buffer.draw( { delta: true } ) ;
|
51 |
|
52 | //attr = { color: { r:255,g:155,b:155,a:255 } , bgColor: { r:0,g:50,b:0,a:255} } ;
|
53 | buffer.put( { x: 0 , y: 0 , attr } , fwa.repeat( 2 ) ) ;
|
54 | buffer.put( { x: 0 , y: 1 , attr } , fwa.repeat( 2 ) ) ;
|
55 | buffer.put( { x: 1 , y: 1 , attr } , fwa ) ;
|
56 | buffer.put( { x: 0 , y: 2 , attr } , fwa.repeat( 2 ) ) ;
|
57 | buffer.put( { x: 1 , y: 2 , attr } , '!' ) ;
|
58 | buffer.put( { x: 0 , y: 3 , attr } , fwa.repeat( 2 ) ) ;
|
59 | buffer.put( { x: 2 , y: 3 , attr } , '!' ) ;
|
60 | buffer.put( { x: 3 , y: 4 , attr } , fwa ) ;
|
61 |
|
62 | buffer.draw( { delta: false } ) ;
|
63 | term( '\n' ) ;
|
64 | term.moveTo.styleReset( 1 , 8 , '%s' , buffer.dump() ) ;
|
65 | //return ;
|
66 | //await Promise.resolveTimeout( 1000 ) ;
|
67 |
|
68 | buffer.x = 10 ;
|
69 | buffer2.put( { x: 0 , y: 0 , attr } , fwz ) ;
|
70 | buffer2.x = 1 ;
|
71 |
|
72 | //buffer.draw( { delta: false } ) ;
|
73 | buffer2.draw( { blending: true } ) ;
|
74 | buffer.draw( { delta: false } ) ;
|
75 | term.moveTo.styleReset( 1 , 16 , '%s' , buffer.dump() ) ;
|
76 | }
|
77 |
|
78 | test() ;
|
79 |
|