Skip to content

Commit 69bebf6

Browse files
Qix-sindresorhus
authored andcommittedJun 20, 2017
Support urxvt escapes (#13)
1 parent 3dff5e7 commit 69bebf6

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
 

‎fixtures/ansi-codes.js

+17
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,20 @@ exports.otherCode = new Map([
212212
['3n', ['Response: terminal is not OK', 'DSR']],
213213
['6n', ['Get cursor position', 'DSR']]
214214
]);
215+
216+
// urxvt escapes
217+
exports.urxvt = new Map([
218+
['[5~', ['URxvt.keysym.Prior']],
219+
['[6~', ['URxvt.keysym.Next']],
220+
['[7~', ['URxvt.keysym.Home']],
221+
['[8~', ['URxvt.keysym.End']],
222+
['[A', ['URxvt.keysym.Up']],
223+
['[B', ['URxvt.keysym.Down']],
224+
['[C', ['URxvt.keysym.Right']],
225+
['[D', ['URxvt.keysym.Left']],
226+
['[3;5;5t', ['URxvt.keysym.C-M-q']],
227+
['[3;5;606t', ['URxvt.keysym.C-M-y']],
228+
['[3;1605;5t', ['URxvt.keysym.C-M-e']],
229+
['[3;1605;606t', ['URxvt.keysym.C-M-c']],
230+
[']710;9x15bold\x07', ['URxvt.keysym.font']]
231+
]);

‎index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
'use strict';
2-
module.exports = () => (/[\u001B\u009B][[()#;?]*(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PRZcf-nqry=><]/g);
2+
3+
module.exports = () => {
4+
const pattern = [
5+
'[\\u001b\\u009b][[\\]()#;?]*(?:(?:(?:[a-zA-Z0-9]*(?:;[a-zA-Z0-9]*)*)?\\x07)',
6+
'(?:(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-ntqry=><~]))'
7+
].join('|');
8+
9+
return new RegExp(pattern, 'g');
10+
};

0 commit comments

Comments
 (0)
Please sign in to comment.