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 | const termkit = require( '../lib/termkit.js' ) ;
|
37 | const term = termkit.terminal ;
|
38 |
|
39 |
|
40 |
|
41 | async function termInfo( t ) {
|
42 | var r ;
|
43 |
|
44 | term( 'Terminal name: %s\n' , t.appName ) ;
|
45 | term( 'Terminal app ID: %s\n' , t.appId ) ;
|
46 | term( 'Generic terminal: %s\n' , t.generic ) ;
|
47 | term( 'Config file: %s\n' , t.termconfigFile ) ;
|
48 | term( '\n' ) ;
|
49 |
|
50 | term( "Support for delta escape sequence: " + ( t.support.deltaEscapeSequence ? "^GOK^:\n" : "^RNO^:\n" ) ) ;
|
51 | term( "Support for 256 colors: " + ( t.support['256colors'] ? "^GOK^:\n" : "^RNO^:\n" ) ) ;
|
52 | term( "Support for true colors: " + ( t.support.trueColor ? "^GOK^:\n" : "^RNO^:\n" ) ) ;
|
53 |
|
54 | try {
|
55 | term( "Support for cursor location request: " ) ;
|
56 | r = await t.getCursorLocation() ;
|
57 | term( "^GOK^ ^K(%N)^:\n" , r ) ;
|
58 | }
|
59 | catch ( error ) {
|
60 | term( "^RFAILED^ (%s)^:\n" , error ) ;
|
61 | }
|
62 |
|
63 | try {
|
64 | term( "Support for palette request: " ) ;
|
65 | await t.getPalette() ;
|
66 | term( "^GOK^:\n" ) ;
|
67 | }
|
68 | catch ( error ) {
|
69 | term( "^RFAILED^ (%s)^:\n" , error ) ;
|
70 | }
|
71 |
|
72 | term( "Issue #116 CURSOR_LOCATION keymap: " + ( t.keymap.CURSOR_LOCATION && typeof t.keymap.CURSOR_LOCATION === 'object' ? "^GOK^:\n" : "^RNO^:\n" ) ) ;
|
73 | term( "Issue #116 cursorLocation handler: " + ( typeof t.handler.cursorLocation === 'function' ? "^GOK^:\n" : "^RNO^:\n" ) ) ;
|
74 |
|
75 | term( '\n' ) ;
|
76 | }
|
77 |
|
78 |
|
79 |
|
80 | async function detect() {
|
81 | var info , newTerm ;
|
82 |
|
83 | term.green( '\n== Environment variable ==\n\n' ) ;
|
84 | term( '$TERM: %s\n' , process.env.TERM ) ;
|
85 | term( '$COLORTERM: %s\n' , process.env.COLORTERM ) ;
|
86 | term( '$VTE_VERSION: %s\n' , process.env.VTE_VERSION ) ;
|
87 | term( '\n' ) ;
|
88 |
|
89 |
|
90 |
|
91 | term.green( '\n== Using simple terminal guessing ==\n\n' ) ;
|
92 | term( '.guessTerminal(): %J\n' , termkit.guessTerminal() ) ;
|
93 | await termInfo( term ) ;
|
94 |
|
95 |
|
96 |
|
97 | term.green( '\n== Using advanced terminal detection ==\n\n' ) ;
|
98 | try {
|
99 | info = await termkit.getParentTerminalInfo( info ) ;
|
100 | term( '.getParentTerminalInfo(): %J\n' , info ) ;
|
101 | }
|
102 | catch ( error ) {
|
103 | term.red( "Can't get parent terminal info: %E" , error ) ;
|
104 | }
|
105 |
|
106 | try {
|
107 | newTerm = await termkit.getDetectedTerminal() ;
|
108 | await termInfo( newTerm ) ;
|
109 | }
|
110 | catch ( error ) {
|
111 | term.red( "Can't get detect real terminal: %E" , error ) ;
|
112 | }
|
113 | }
|
114 |
|
115 | detect() ;
|
116 |
|