fix pixel to cell offsets
This commit is contained in:
+27
-26
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Script to test different mouse modes in terminal emulators.
|
||||
* Tests for protocols DECSET 9, 1000, 1002, 1003 with different
|
||||
* report encodings (default, UTF8, SGR, URXVT).
|
||||
* report encodings (default, UTF8, SGR, URXVT, SGR-pixels).
|
||||
*
|
||||
* VT200 Highlight mode (DECSET 1001) is not implemented.
|
||||
*
|
||||
@@ -123,19 +123,19 @@ const ENC = {
|
||||
row: report[5] - 32
|
||||
})
|
||||
],
|
||||
// 'UTF8' : [
|
||||
// '\x1b[?1005h',
|
||||
// // format: CSI M <button + 32> <row + 32> <col + 32>
|
||||
// // + utf8 encoding on row/col
|
||||
// report => {
|
||||
// const sReport = report.toString(); // decode with utf8
|
||||
// return {
|
||||
// state: evalButtonCode(sReport.charCodeAt(3) - 32),
|
||||
// col: sReport.charCodeAt(4) - 32,
|
||||
// row: sReport.charCodeAt(5) - 32
|
||||
// };
|
||||
// }
|
||||
// ],
|
||||
'UTF8' : [
|
||||
'\x1b[?1005h',
|
||||
// format: CSI M <button + 32> <row + 32> <col + 32>
|
||||
// + utf8 encoding on row/col
|
||||
report => {
|
||||
const sReport = report.toString(); // decode with utf8
|
||||
return {
|
||||
state: evalButtonCode(sReport.charCodeAt(3) - 32),
|
||||
col: sReport.charCodeAt(4) - 32,
|
||||
row: sReport.charCodeAt(5) - 32
|
||||
};
|
||||
}
|
||||
],
|
||||
'SGR' : [
|
||||
'\x1b[?1006h',
|
||||
// format: CSI < Pbutton ; Prow ; Pcol M
|
||||
@@ -150,16 +150,16 @@ const ENC = {
|
||||
return {state, row, col};
|
||||
}
|
||||
],
|
||||
// 'URXVT': [
|
||||
// '\x1b[?1015h',
|
||||
// // format: CSI <button + 32> ; Prow ; Pcol M
|
||||
// report => {
|
||||
// // strip off introducer + M
|
||||
// const sReport = report.toString().slice(2, -1);
|
||||
// const [button, col, row] = sReport.split(';');
|
||||
// return {state: evalButtonCode(button - 32), row, col};
|
||||
// }
|
||||
// ],
|
||||
'URXVT': [
|
||||
'\x1b[?1015h',
|
||||
// format: CSI <button + 32> ; Prow ; Pcol M
|
||||
report => {
|
||||
// strip off introducer + M
|
||||
const sReport = report.toString().slice(2, -1);
|
||||
const [button, col, row] = sReport.split(';');
|
||||
return {state: evalButtonCode(button - 32), row, col};
|
||||
}
|
||||
],
|
||||
'SGR_PIXELS' : [
|
||||
'\x1b[?1016h',
|
||||
// format: CSI < Pbutton ; Prow ; Pcol M
|
||||
@@ -217,10 +217,11 @@ function activate() {
|
||||
|
||||
function applyReportData(data) {
|
||||
let {state, row, col} = ENC[Object.keys(ENC)[activeEnc]][1](data);
|
||||
console.log('\x1b[2KButton:', state.button, 'Action:', state.action, 'Modifier:', state.modifier, 'row:', row, 'col:', col);
|
||||
// apply to cursor position
|
||||
if (Object.keys(ENC)[activeEnc] !== 'SGR_PIXELS') {
|
||||
console.log('\x1b[2KButton:', state.button, 'Action:', state.action, 'Modifier:', state.modifier, 'row:', row, 'col:', col);
|
||||
process.stdout.write(`\x1b[${row};${col}H`);
|
||||
} else {
|
||||
console.log('\x1b[2KButton:', state.button, 'Action:', state.action, 'Modifier:', state.modifier, 'x:', row, 'y:', col);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user