@@ -26,33 +26,74 @@ function () use ($xterm) {
26
26
}
27
27
);
28
28
29
-
30
29
$ xterm
31
30
// boot
32
31
->setPrivateModeSaveCursorAndEnterAlternateScreenBuffer ()
33
32
->hideCursor ()
34
- // set colors
35
- ->bgBlue ()
36
- ->brightYellow ()
37
- ->eraseAll ()
38
- // Primary DA
39
- ->moveCursorTo (2 , 2 )
40
- ->write ("Terminal ID ..... : $ primary ->terminalId " )
41
- ->moveCursorTo (3 , 2 )
42
- ->write ("Capabilities .... : " . implode (' ' , $ primary ->capabilities ))
43
- // Secondary DA
44
- ->moveCursorTo (6 , 2 )
45
- ->write ("Type ............ : $ secondary ->type " )
46
- ->moveCursorTo (8 , 2 )
47
- ->write ("Version ......... : $ secondary ->version " )
48
- ->moveCursorTo (10 , 2 )
49
- ->write ("Cartridge Reg. .. : $ secondary ->cartridgeRegistration " )
50
- //
51
- ->moveCursorTo (15 , 10 )
52
- ->blink ()
53
- ->write ("Press any key to exit " )
54
- ->normal ()
55
33
->flush ()
56
34
;
57
35
36
+ EventLoop::repeat (1 , function () use ($ xterm , $ primary , $ secondary ) {
37
+ $ xterm
38
+ // set colors
39
+ ->bgBlue ()
40
+ ->brightYellow ()
41
+ ->eraseAll ();
42
+
43
+ $ view = [
44
+ // Primary
45
+ 'Terminal ID ' => $ primary ->terminalId ,
46
+ 'Capabilities ' => "\n\t" . implode (
47
+ " " ,
48
+ // only first letter for when its running on xterm
49
+ array_map (fn ($ capability ) => substr ($ capability , 0 , 1 ), $ primary ->capabilities )
50
+ ),
51
+
52
+ // Secondary
53
+ 'Type ' => $ secondary ->type ,
54
+ 'Version ' => $ secondary ->version ,
55
+ 'Cartridge Reg ' => $ secondary ->cartridgeRegistration ,
56
+
57
+ // Sizes
58
+ 'TextArea Position ' => implode (' x ' , $ xterm ->reportTextAreaPosition ()),
59
+ 'TextArea Size (px) ' => implode (' x ' , $ xterm ->reportTextAreaSizePixels ()),
60
+ 'TextArea Size (char) ' => implode (' x ' , $ xterm ->reportTextAreaSizeCharacters ()),
61
+ 'Window Size (px) ' => implode (' x ' , $ xterm ->reportWindowSizePixels ()),
62
+ 'Screen Size (px) ' => implode (' x ' , $ xterm ->reportScreenSizePixels ()),
63
+ 'Screen Size (char) ' => implode (' x ' , $ xterm ->reportScreenSizeCharacters ()),
64
+ 'Character size (px) ' => implode (' x ' , $ xterm ->reportCharacterSizePixels ()),
65
+ ];
66
+
67
+ $ lines = [
68
+ [2 ,2 ],
69
+ [3 ,2 ],
70
+ [6 ,2 ],
71
+ [8 ,2 ],
72
+ [10 ,2 ],
73
+ [2 , 40 ],
74
+ [3 , 40 ],
75
+ [4 , 40 ],
76
+ [6 , 40 ],
77
+ [8 , 40 ],
78
+ [9 , 40 ],
79
+ [11 , 40 ],
80
+ ];
81
+
82
+ $ i = 0 ;
83
+ foreach ($ view as $ title => $ data ) {
84
+ $ element = str_pad ($ title . ' ' , 25 , '. ' ) . ' : ' . $ data ;
85
+ $ xterm
86
+ ->moveCursorTo (...$ lines [$ i ++])
87
+ ->write ($ element );
88
+ }
89
+ //
90
+ $ xterm
91
+ ->moveCursorTo (15 , 10 )
92
+ ->blink ()
93
+ ->write ("Press any key to exit or resize/move your screen " )
94
+ ->normal ()
95
+ ->flush ()
96
+ ;
97
+ });
98
+
58
99
EventLoop::run ();
0 commit comments