From e5728ca78f763b44f97742d193069d0bf4320cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 14 Jul 2019 20:34:51 +0200 Subject: [PATCH 1/3] test script for mouse modes --- fixtures/mouse_modes/test_modes.js | 97 ++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 fixtures/mouse_modes/test_modes.js diff --git a/fixtures/mouse_modes/test_modes.js b/fixtures/mouse_modes/test_modes.js new file mode 100644 index 00000000..98fdfd38 --- /dev/null +++ b/fixtures/mouse_modes/test_modes.js @@ -0,0 +1,97 @@ +let activeEnc = 0; + +const stdin = process.openStdin(); +process.stdin.setRawMode(true); + +// close handler - reset terminal on exit +stdin.addListener('data', function(data) { + if (data[0] === 0x04) { + process.stdin.setRawMode(false); + process.stdout.write('\x1bc'); + process.exit(); + } + if (data[0] === 0x01) { + switchActive(); + printMenu(); + } + console.log('\x1b[100;H\x1b[2A\x1b[2KReport:', data, [data.toString('binary')]); + // filter mouse reports + if (data[0] === 0x1b && data[1] === '['.charCodeAt(0)) { + applyReportData(data); + } +}); + +const BUTTONS = ['left', 'middle', 'right']; + +// encodings: ENCODING_NAME => [sequence, parse_report] +const ENC = { + 'X10' : [ + '\x1b[?9h', + // format: CSI M