|
4 | 4 | * |
5 | 5 | * Script to test different mouse modes in terminal emulators. |
6 | 6 | * Tests for protocols DECSET 9, 1000, 1002, 1003 with different |
7 | | - * report encodings (default, UTF8, SGR, URXVT). |
| 7 | + * report encodings (default, UTF8, SGR, URXVT, SGR-pixels). |
8 | 8 | * |
9 | 9 | * VT200 Highlight mode (DECSET 1001) is not implemented. |
10 | 10 | * |
@@ -152,13 +152,27 @@ const ENC = { |
152 | 152 | ], |
153 | 153 | 'URXVT': [ |
154 | 154 | '\x1b[?1015h', |
155 | | - // format: CSI <button + 32> ; Prow ; Pcol M |
| 155 | + // format: CSI <button + 32> ; Prow ; Pcol M |
156 | 156 | report => { |
157 | 157 | // strip off introducer + M |
158 | 158 | const sReport = report.toString().slice(2, -1); |
159 | 159 | const [button, col, row] = sReport.split(';'); |
160 | 160 | return {state: evalButtonCode(button - 32), row, col}; |
161 | 161 | } |
| 162 | + ], |
| 163 | + 'SGR_PIXELS' : [ |
| 164 | + '\x1b[?1016h', |
| 165 | + // format: CSI < Pbutton ; Prow ; Pcol M |
| 166 | + report => { |
| 167 | + // strip off introducer + M |
| 168 | + const sReport = report.toString().slice(3, -1); |
| 169 | + const [buttonCode, col, row] = sReport.split(';'); |
| 170 | + const state = evalButtonCode(buttonCode); |
| 171 | + if (report[report.length - 1] === 'm'.charCodeAt(0)) { |
| 172 | + state.action = 'release'; |
| 173 | + } |
| 174 | + return {state, row, col}; |
| 175 | + } |
162 | 176 | ] |
163 | 177 | } |
164 | 178 |
|
@@ -203,9 +217,12 @@ function activate() { |
203 | 217 |
|
204 | 218 | function applyReportData(data) { |
205 | 219 | let {state, row, col} = ENC[Object.keys(ENC)[activeEnc]][1](data); |
206 | | - console.log('\x1b[2KButton:', state.button, 'Action:', state.action, 'Modifier:', state.modifier, 'row:', row, 'col:', col); |
207 | | - // apply to cursor position |
208 | | - process.stdout.write(`\x1b[${row};${col}H`); |
| 220 | + if (Object.keys(ENC)[activeEnc] !== 'SGR_PIXELS') { |
| 221 | + console.log('\x1b[2KButton:', state.button, 'Action:', state.action, 'Modifier:', state.modifier, 'row:', row, 'col:', col); |
| 222 | + process.stdout.write(`\x1b[${row};${col}H`); |
| 223 | + } else { |
| 224 | + console.log('\x1b[2KButton:', state.button, 'Action:', state.action, 'Modifier:', state.modifier, 'x:', row, 'y:', col); |
| 225 | + } |
209 | 226 | } |
210 | 227 |
|
211 | 228 | printMenu(); |
|
0 commit comments