Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse tracking tests #2321

Merged
merged 26 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4e56eed
basic mousing tracking api tests
jerch Jul 17, 2019
27e8f7a
mixed col/row in report parser
jerch Jul 17, 2019
d4f65b7
remove copied over bug comments
jerch Jul 17, 2019
ee3cbae
modifier test examples
jerch Jul 17, 2019
044476a
Merge branch 'master' into mouse_report_tests
jerch Jul 19, 2019
986bdac
create wheel event remote
jerch Jul 19, 2019
25ed7f7
added modifier tests
jerch Jul 22, 2019
bca69a7
fix report eval for buttons > 5
jerch Jul 22, 2019
d63985a
Merge branch 'master' into mouse_report_tests
Tyriar Jul 22, 2019
62c25b0
Fix all auto-fixable tslint issues
Tyriar Jul 22, 2019
435cb3b
partial fix macos
jerch Jul 23, 2019
5b3d2fc
Merge branch 'mouse_report_tests' of github.com:jerch/xterm.js into m…
jerch Jul 23, 2019
10c61d4
macos fix part2
jerch Jul 23, 2019
2c3f9c9
macos fix part3
jerch Jul 23, 2019
50e5eb6
macos fix part4
jerch Jul 23, 2019
711865f
sanitize code extraction
jerch Jul 23, 2019
edf881b
macOS integration tests
jerch Jul 23, 2019
595465e
fix azure tasks
jerch Jul 23, 2019
6463a1f
increase mouse test timeout
jerch Jul 23, 2019
6391742
Merge branch 'master' into mouse_report_tests
jerch Jul 24, 2019
fb38bd1
fix general purpose test script
jerch Jul 24, 2019
4ee0e3f
Merge branch 'master' into mouse_report_tests
Tyriar Jul 24, 2019
113847a
Merge branch 'master' into mouse_report_tests
jerch Jul 24, 2019
20a8e56
Merge branch 'mouse_report_tests' of github.com:jerch/xterm.js into m…
jerch Jul 24, 2019
54586f7
Merge branch 'master' into mouse_report_tests
jerch Jul 26, 2019
6840f51
Merge branch 'master' into mouse_report_tests
Tyriar Jul 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 21 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
yarn lint
displayName: 'Lint'

- job: IntegrationTests
- job: Linux_IntegrationTests
pool:
vmImage: 'ubuntu-16.04'
steps:
Expand All @@ -81,14 +81,32 @@ jobs:
yarn start &
sleep 10
yarn test-api --headless
displayName: 'Integration tests'
displayName: 'Linux Integration tests'

- job: macOS_IntegrationTests
pool:
vmImage: 'xcode9-macos10.13'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- script: |
yarn
displayName: 'Install dependencies and build'
- script: |
yarn start &
sleep 10
yarn test-api --headless
displayName: 'MacOS Integration tests'

- job: Release
dependsOn:
- Linux
- macOS
- Windows
- IntegrationTests
- Linux_IntegrationTests
- macOS_IntegrationTests
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/release/*')))
pool:
vmImage: 'ubuntu-16.04'
Expand Down
89 changes: 56 additions & 33 deletions bin/test_mousemodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,43 +48,66 @@ stdin.addListener('data', function(data) {
}
});

// basic button codes (modifier keys are added on top)
const BUTTONS = {
0: ['left', 'press'],
1: ['middle', 'press'],
2: ['right', 'press'],
3: ['', 'release'],
32: ['left', 'move'],
33: ['middle', 'move'],
34: ['right', 'move'],
35: ['', 'move'],
64: ['wheel', 'up'],
65: ['wheel', 'down']
// button definitions
const buttons = {
'<none>': -1,
left: 0,
middle: 1,
right: 2,
released: 3,
wheelUp: 4,
wheelDown: 5,
wheelLeft: 6,
wheelRight: 7,
aux1: 8,
aux2: 9,
aux3: 10,
aux4: 11,
aux5: 12,
aux6: 13,
aux7: 14,
aux8: 15
};
const reverseButtons = {};
for (const el in buttons) {
reverseButtons[buttons[el]] = el;
}

// extract button data from buttonCode
function evalButtonCode(code) {
// 2 bits: 0 - left, 1 - middle, 2 - right, 3 - release
// higher bits: 4 - shift, 8 - meta, 16 - control
// more than 15 buttons are not supported
if (code > 255) {
return {button: 'invalid', action: 'invalid', modifier: {}};
}
const modifier = {shift: !!(code & 4), meta: !!(code & 8), control: !!(code & 16)};
const wheel = code & 64;
let action;
let button;
if (wheel) {
action = (code & 1) ? 'down' : 'up';
button = 'wheel';
} else {
action = code & 32 ? 'move' : code === 3 ? 'release' : 'press';
code &= 3; // TODO: more than 3 buttons + wheel
button = code === 0 ? 'left' : code === 1 ? 'middle' : code === 2 ? 'right' : '<none>';
const move = code & 32;
let button = code & 3;
if (code & 128) {
button |= 8;
}
if (code & 64) {
button |= 4
}
let actionS = 'press';
let buttonS = reverseButtons[button];
if (button === 3) {
buttonS = '<none>';
actionS = 'release';
}
if (move) {
actionS = 'move';
} else if (4 <= button && button <= 7) {
buttonS = 'wheel';
actionS = button === 4 ? 'up' : button === 5 ? 'down' : button === 6 ? 'left' : 'right';
}
return {button, action, modifier};
return {button: buttonS, action: actionS, modifier};
}

// protocols
const PROTOCOLS = {
'9 (X10: press only)': '\x1b[?9h',
'1000 (VT200: press, release, wheel)': '\x1b[?1000h',
// '1001 (VT200 highlight)': '\x1b[?1001h', // handle of backreport not implemented
// '1001 (VT200 highlight)': '\x1b[?1001h', // handle of backreport - not implemented
'1002 (press, release, move on pressed, wheel)': '\x1b[?1002h',
'1003 (press, relase, move, wheel)': '\x1b[?1003h'
}
Expand All @@ -96,8 +119,8 @@ const ENC = {
// format: CSI M <button + 32> <row + 32> <col + 32>
report => ({
state: evalButtonCode(report[3] - 32),
row: report[4] - 32,
col: report[5] - 32
col: report[4] - 32,
row: report[5] - 32
})
],
'UTF8' : [
Expand All @@ -108,8 +131,8 @@ const ENC = {
const sReport = report.toString(); // decode with utf8
return {
state: evalButtonCode(sReport.charCodeAt(3) - 32),
row: sReport.charCodeAt(4) - 32,
col: sReport.charCodeAt(5) - 32
col: sReport.charCodeAt(4) - 32,
row: sReport.charCodeAt(5) - 32
};
}
],
Expand All @@ -119,7 +142,7 @@ const ENC = {
report => {
// strip off introducer + M
const sReport = report.toString().slice(3, -1);
const [buttonCode, row, col] = sReport.split(';');
const [buttonCode, col, row] = sReport.split(';');
const state = evalButtonCode(buttonCode);
if (report[report.length - 1] === 'm'.charCodeAt(0)) {
state.action = 'release';
Expand All @@ -133,7 +156,7 @@ const ENC = {
report => {
// strip off introducer + M
const sReport = report.toString().slice(2, -1);
const [button, row, col] = sReport.split(';');
const [button, col, row] = sReport.split(';');
return {state: evalButtonCode(button - 32), row, col};
}
]
Expand Down Expand Up @@ -182,7 +205,7 @@ 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
process.stdout.write(`\x1b[${col};${row}H`);
process.stdout.write(`\x1b[${row};${col}H`);
}

printMenu();
Expand Down