dotfiles/.vscode/extensions/vscodevim.vim-0.1.10/out/src/notation.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-09-11 09:29:13 +01:00
"use strict";
class AngleBracketNotation {
/**
* Normalizes key to AngleBracketNotation
* For instance, <ctrl+x>, Ctrl+x, <c-x> normalized to <C-x>
*/
static Normalize(key) {
if (!this.isSurroundedByAngleBrackets(key) && key.length > 1) {
key = `<${key.toLocaleLowerCase()}>`;
}
for (const notationMapKey in this._notationMap) {
if (this._notationMap.hasOwnProperty(notationMapKey)) {
const regex = new RegExp(this._notationMap[notationMapKey].join('|'), 'gi');
if (regex.test(key)) {
key = key.replace(regex, notationMapKey);
break;
}
}
}
return key;
}
static isSurroundedByAngleBrackets(key) {
return key.startsWith('<') && key.endsWith('>');
}
}
AngleBracketNotation._notationMap = {
'C-': ['ctrl\\+', 'c\\-'],
'Esc': ['escape', 'esc'],
'BS': ['backspace', 'bs'],
'Del': ['delete', 'del'],
};
exports.AngleBracketNotation = AngleBracketNotation;
//# sourceMappingURL=notation.js.map