File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ function term (opts) {
36
36
// cached "context"
37
37
canvas . renderCtx = canvas . getContext ( '2d' ) ;
38
38
39
+ // handle the "resize" event
40
+ stream . on ( 'resize' , function ( ) {
41
+ canvas . width = stream . columns / pixelWidth ;
42
+ canvas . height = stream . rows / pixelHeight ;
43
+ } ) ;
44
+
39
45
return canvas ;
40
46
}
41
47
@@ -47,7 +53,6 @@ function term (opts) {
47
53
48
54
function render ( ) {
49
55
var cursor = ansi ( this . stream ) ;
50
- cursor . write ( '\n' ) ;
51
56
52
57
// erase everything on the screen
53
58
cursor . eraseData ( 2 ) ;
Original file line number Diff line number Diff line change
1
+
2
+ var tc = require ( './' ) ;
3
+
4
+ // create terminal <canvas>
5
+ var canvas = tc ( ) ;
6
+ var ctx = canvas . getContext ( '2d' ) ;
7
+
8
+ var x = 0 ;
9
+ var y = 0 ;
10
+ function render ( ) {
11
+
12
+ // black background
13
+ ctx . fillStyle = 'black' ;
14
+ ctx . fillRect ( 0 , 0 , canvas . width , canvas . height ) ;
15
+
16
+ // print height and width
17
+ ctx . font = '12px Arial' ;
18
+ ctx . textBaseline = "top" ;
19
+ ctx . fillStyle = 'red' ;
20
+ ctx . fillText ( 'w: ' + canvas . width + ', h: ' + canvas . height , 0 , 0 ) ;
21
+
22
+ // render to TTY
23
+ canvas . render ( ) ;
24
+ }
25
+
26
+ process . stdout . on ( 'resize' , render ) ;
27
+
28
+ setInterval ( render , 1000 / 60 ) ; // 60hz
29
+ //render();
You can’t perform that action at this time.
0 commit comments