osx-jetbrains-keymap-generator 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ahk-script-printer.d.ts +2 -0
- package/dist/ahk-script-printer.js +29 -0
- package/dist/ahk-script-printer.js.map +1 -0
- package/dist/hotkey-mapper.d.ts +1 -0
- package/dist/hotkey-mapper.js +48 -0
- package/dist/hotkey-mapper.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +32 -0
- package/dist/main.js.map +1 -0
- package/dist/test/ahk-script-printer.test.d.ts +1 -0
- package/dist/test/ahk-script-printer.test.js +31 -0
- package/dist/test/ahk-script-printer.test.js.map +1 -0
- package/dist/test/hotkey-mapper.test.d.ts +1 -0
- package/dist/test/hotkey-mapper.test.js +106 -0
- package/dist/test/hotkey-mapper.test.js.map +1 -0
- package/dist/test/translator.test.d.ts +1 -0
- package/dist/test/translator.test.js +55 -0
- package/dist/test/translator.test.js.map +1 -0
- package/dist/translator.d.ts +12 -0
- package/dist/translator.js +38 -0
- package/dist/translator.js.map +1 -0
- package/dist/xmlParser.d.ts +4 -0
- package/dist/xmlParser.js +28 -0
- package/dist/xmlParser.js.map +1 -0
- package/package.json +8 -6
- package/tsconfig.json +2 -1
- package/index.js +0 -3
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.print = void 0;
|
4
|
+
const _ = require("lodash");
|
5
|
+
const splitter = '\n ';
|
6
|
+
const print = (processName, translateResults) => {
|
7
|
+
const printOneLine = printTranslateResult(processName);
|
8
|
+
return `
|
9
|
+
LAlt::LWin
|
10
|
+
LWin::LAlt
|
11
|
+
#IfWinActive ahk_exe ${processName}
|
12
|
+
{
|
13
|
+
${_.map(translateResults, r => printOneLine(r)).join(splitter)}
|
14
|
+
}
|
15
|
+
`;
|
16
|
+
};
|
17
|
+
exports.print = print;
|
18
|
+
const printTranslateResult = (processName) => (translateResult) => {
|
19
|
+
if (typeof translateResult === 'string') {
|
20
|
+
return `; ${translateResult}`;
|
21
|
+
}
|
22
|
+
return `$${translateResult.left}::ControlSend ,,{Blind}${printRightResult(translateResult.right)},ahk_exe ${processName} ; ${translateResult.action}`;
|
23
|
+
};
|
24
|
+
const printRightResult = (right) => {
|
25
|
+
const downStrike = _.map(right, s => `{${s} down}`).join('');
|
26
|
+
const upStrike = _.map(right.reverse(), s => `{${s} up}`).join('');
|
27
|
+
return downStrike + upStrike;
|
28
|
+
};
|
29
|
+
//# sourceMappingURL=ahk-script-printer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ahk-script-printer.js","sourceRoot":"","sources":["../src/ahk-script-printer.ts"],"names":[],"mappings":";;;AACA,4BAA4B;AAE5B,MAAM,QAAQ,GAAG,QAAQ,CAAA;AAElB,MAAM,KAAK,GAAG,CAAC,WAAmB,EAAE,gBAA8C,EAAE,EAAE;IACzF,MAAM,YAAY,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAA;IACtD,OAAO;;;uBAGY,WAAW;;MAE5B,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;;KAE7D,CAAA;AACL,CAAC,CAAA;AAVY,QAAA,KAAK,SAUjB;AAED,MAAM,oBAAoB,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC,CAAC,eAAyC,EAAE,EAAE;IAChG,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE;QACrC,OAAO,KAAK,eAAe,EAAE,CAAA;KAChC;IACD,OAAO,IAAI,eAAe,CAAC,IAAI,0BAA0B,gBAAgB,CAAC,eAAe,CAAC,KAAK,CAAC,YAAY,WAAW,MAAM,eAAe,CAAC,MAAM,EAAE,CAAA;AACzJ,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,KAAe,EAAE,EAAE;IACzC,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5D,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAClE,OAAO,UAAU,GAAC,QAAQ,CAAA;AAC9B,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const translateKey: (shortcut: string) => any;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.translateKey = void 0;
|
4
|
+
const _ = require("lodash");
|
5
|
+
const keymapTable = {
|
6
|
+
'COMMA': ',',
|
7
|
+
'SEMICOLON': ';',
|
8
|
+
'SLASH': '/',
|
9
|
+
'PAGE_DOWN': 'PgDown',
|
10
|
+
'OPEN_BRACKET': '[',
|
11
|
+
'CLOSE_BRACKET': ']',
|
12
|
+
'ADD': '!=',
|
13
|
+
'MINUS': '-',
|
14
|
+
'SUBSTRATE': '-',
|
15
|
+
'meta': '#',
|
16
|
+
'control': '^',
|
17
|
+
'ctrl': '^',
|
18
|
+
'shift': '+',
|
19
|
+
'alt': '!',
|
20
|
+
'BACK_SPACE': 'Backspace',
|
21
|
+
'PAGE_UP': 'PgUp',
|
22
|
+
'DELETE': 'Del',
|
23
|
+
'EQUAL': '=',
|
24
|
+
'EQUALS': '=',
|
25
|
+
'DIVIDE': '/',
|
26
|
+
'BACK_QUOTE': '`',
|
27
|
+
'MULTIPLY': '*'
|
28
|
+
};
|
29
|
+
const allowedNormalKeys = new Set(['HOME', 'END', 'ENTER', 'TAB', 'SPACE', 'INSERT', 'RIGHT', 'LEFT', 'UP', 'DOWN']);
|
30
|
+
const isAlphanumeric = (s) => /^[a-zA-Z0-9]$/.test(s);
|
31
|
+
const isFunctionKey = (s) => /^F[1-2]*[0-9]$/.test(s);
|
32
|
+
const translateKey = (shortcut) => {
|
33
|
+
if (keymapTable[shortcut] != undefined) {
|
34
|
+
return keymapTable[shortcut];
|
35
|
+
}
|
36
|
+
if (isAlphanumeric(shortcut)) {
|
37
|
+
return shortcut.toLowerCase();
|
38
|
+
}
|
39
|
+
if (isFunctionKey(shortcut)) {
|
40
|
+
return shortcut;
|
41
|
+
}
|
42
|
+
if (allowedNormalKeys.has(shortcut)) {
|
43
|
+
return _.capitalize(shortcut);
|
44
|
+
}
|
45
|
+
throw `unknown key: ${shortcut}`;
|
46
|
+
};
|
47
|
+
exports.translateKey = translateKey;
|
48
|
+
//# sourceMappingURL=hotkey-mapper.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"hotkey-mapper.js","sourceRoot":"","sources":["../src/hotkey-mapper.ts"],"names":[],"mappings":";;;AAAA,4BAA6B;AAE7B,MAAM,WAAW,GAAG;IAChB,OAAO,EAAE,GAAG;IACZ,WAAW,EAAE,GAAG;IAChB,OAAO,EAAE,GAAG;IACZ,WAAW,EAAE,QAAQ;IACrB,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,GAAG;IACpB,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,GAAG;IACZ,WAAW,EAAE,GAAG;IAChB,MAAM,EAAE,GAAG;IACX,SAAS,EAAE,GAAG;IACd,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;IACZ,KAAK,EAAE,GAAG;IACV,YAAY,EAAE,WAAW;IACzB,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IACb,YAAY,EAAE,GAAG;IACjB,UAAU,EAAE,GAAG;CAClB,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;AAEpH,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAE7D,MAAM,aAAa,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAEtD,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,EAAE;IAE7C,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAE,SAAS,EAAE;QAClC,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAA;KAC/B;IAED,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE;QAC1B,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAA;KAChC;IAED,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE;QACzB,OAAO,QAAQ,CAAA;KAClB;IAED,IAAI,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;QACjC,OAAO,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;KAChC;IAED,MAAM,gBAAgB,QAAQ,EAAE,CAAA;AACpC,CAAC,CAAA;AAnBY,QAAA,YAAY,gBAmBxB"}
|
package/dist/main.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/dist/main.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const fs = require("fs");
|
4
|
+
const translator_1 = require("./translator");
|
5
|
+
const ahk_script_printer_1 = require("./ahk-script-printer");
|
6
|
+
const commander_1 = require("commander");
|
7
|
+
const xmlParser_1 = require("./xmlParser");
|
8
|
+
const keyGeneratorProgram = new commander_1.Command();
|
9
|
+
keyGeneratorProgram
|
10
|
+
.usage('kmg [options]')
|
11
|
+
.requiredOption('-f, --file <file>', 'path of jetbrains keymap xml file')
|
12
|
+
.option('-e, --exec <exec>', 'windows process name that ahk need to send key strike to', 'java.exe')
|
13
|
+
.option('-d, --destination <destination>', 'generated ahk script file location')
|
14
|
+
.showSuggestionAfterError()
|
15
|
+
.showHelpAfterError();
|
16
|
+
keyGeneratorProgram.parse();
|
17
|
+
const options = keyGeneratorProgram.opts();
|
18
|
+
const keymapConfigReadStream = fs.readFileSync(options.file).toString();
|
19
|
+
const translateResult = (0, translator_1.translate)((0, xmlParser_1.getParsedResult)(keymapConfigReadStream));
|
20
|
+
const script = (0, ahk_script_printer_1.print)(options.exec, translateResult);
|
21
|
+
const destination = options.destination;
|
22
|
+
if (destination) {
|
23
|
+
if (fs.existsSync(destination) && fs.lstatSync(destination).isDirectory()) {
|
24
|
+
throw `destination is directory: ${destination}`;
|
25
|
+
}
|
26
|
+
console.info(`Generated file: ${destination}`);
|
27
|
+
fs.writeFileSync(destination, script);
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
console.info(script);
|
31
|
+
}
|
32
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,yBAAyB;AAEzB,6CAAuC;AACvC,6DAA2C;AAC3C,yCAAkC;AAClC,2CAA4C;AAG5C,MAAM,mBAAmB,GAAG,IAAI,mBAAO,EAAE,CAAA;AACzC,mBAAmB;KACd,KAAK,CAAC,eAAe,CAAC;KACtB,cAAc,CAAC,mBAAmB,EAAE,mCAAmC,CAAC;KACxE,MAAM,CAAC,mBAAmB,EAAE,0DAA0D,EAAE,UAAU,CAAC;KACnG,MAAM,CAAC,iCAAiC,EAAE,oCAAoC,CAAC;KAC/E,wBAAwB,EAAE;KAC1B,kBAAkB,EAAE,CAAA;AAEzB,mBAAmB,CAAC,KAAK,EAAE,CAAA;AAE3B,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,EAAE,CAAA;AAE1C,MAAM,sBAAsB,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;AAEvE,MAAM,eAAe,GAAG,IAAA,sBAAS,EAAC,IAAA,2BAAe,EAAC,sBAAsB,CAAC,CAAC,CAAA;AAC1E,MAAM,MAAM,GAAG,IAAA,0BAAK,EAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAA;AAGnD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;AAExC,IAAI,WAAW,EAAE;IACb,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,EAAE;QACvE,MAAM,6BAA6B,WAAW,EAAE,CAAA;KACnD;IACD,OAAO,CAAC,IAAI,CAAC,mBAAmB,WAAW,EAAE,CAAC,CAAA;IAC9C,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;CACxC;KAAM;IACH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;CACvB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const chai = require("chai");
|
4
|
+
const ahk_script_printer_1 = require("../ahk-script-printer");
|
5
|
+
chai.should();
|
6
|
+
const expectedResult = (processName, ...results) => {
|
7
|
+
return `
|
8
|
+
LAlt::LWin
|
9
|
+
LWin::LAlt
|
10
|
+
#IfWinActive ahk_exe ${processName}
|
11
|
+
{
|
12
|
+
${results.join('\n ')}
|
13
|
+
}
|
14
|
+
`;
|
15
|
+
};
|
16
|
+
describe('printer tests', () => {
|
17
|
+
it('should print result success', () => {
|
18
|
+
const translateResult = [
|
19
|
+
{ action: 'first', left: '#k', right: ['LWin', 'k'] },
|
20
|
+
{ action: 'second', left: '#+k', right: ['LWin', 'LShift', 'k'] }
|
21
|
+
];
|
22
|
+
const result = (0, ahk_script_printer_1.print)('java.exe', translateResult);
|
23
|
+
result.should.be.equal(expectedResult('java.exe', '$#k::ControlSend ,,{Blind}{LWin down}{k down}{k up}{LWin up},ahk_exe java.exe ; first', '$#+k::ControlSend ,,{Blind}{LWin down}{LShift down}{k down}{k up}{LShift up}{LWin up},ahk_exe java.exe ; second'));
|
24
|
+
});
|
25
|
+
it('should print warning when translate result is error msg', () => {
|
26
|
+
const translateResult = ['I am an error!'];
|
27
|
+
const result = (0, ahk_script_printer_1.print)('java.exe', translateResult);
|
28
|
+
result.should.be.equal(expectedResult('java.exe', '; I am an error!'));
|
29
|
+
});
|
30
|
+
});
|
31
|
+
//# sourceMappingURL=ahk-script-printer.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ahk-script-printer.test.js","sourceRoot":"","sources":["../../src/test/ahk-script-printer.test.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,8DAA4C;AAE5C,IAAI,CAAC,MAAM,EAAE,CAAA;AAEb,MAAM,cAAc,GAAG,CAAC,WAAmB,EAAE,GAAG,OAAiB,EAAE,EAAE;IACjE,OAAO;;;uBAGY,WAAW;;MAE5B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;;KAEvB,CAAA;AACL,CAAC,CAAA;AAGD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACnC,MAAM,eAAe,GAAG;YACpB,EAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,EAAC;YACnD,EAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAC,GAAG,CAAC,EAAC;SACjE,CAAA;QACD,MAAM,MAAM,GAAG,IAAA,0BAAK,EAAC,UAAU,EAAE,eAAe,CAAC,CAAA;QACjD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,EAC5C,uFAAuF,EACvF,iHAAiH,CACpH,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IACF,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QAC/D,MAAM,eAAe,GAAG,CAAC,gBAAgB,CAAC,CAAA;QAC1C,MAAM,MAAM,GAAG,IAAA,0BAAK,EAAC,UAAU,EAAE,eAAe,CAAC,CAAA;QACjD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,EAC5C,kBAAkB,CACrB,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,106 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const hotkey_mapper_1 = require("../hotkey-mapper");
|
4
|
+
const chai = require("chai");
|
5
|
+
const chai_1 = require("chai");
|
6
|
+
chai.should();
|
7
|
+
describe('hotkey translator tests', () => {
|
8
|
+
describe('should translate modifier keys success', () => {
|
9
|
+
const modifierTranslationTable = [
|
10
|
+
['meta', '#'],
|
11
|
+
['control', '^'],
|
12
|
+
['shift', '+'],
|
13
|
+
['alt', '!'],
|
14
|
+
['ctrl', '^']
|
15
|
+
];
|
16
|
+
modifierTranslationTable.forEach(([modifier, ahkHotkey]) => {
|
17
|
+
it(`should translate ${modifier} to ${ahkHotkey} success`, () => {
|
18
|
+
const result = (0, hotkey_mapper_1.translateKey)(modifier);
|
19
|
+
result.should.equal(ahkHotkey);
|
20
|
+
});
|
21
|
+
});
|
22
|
+
});
|
23
|
+
describe('should translate all alphanumeric keys to lowercase success', () => {
|
24
|
+
const uppercaseAlphabetTranslations = [
|
25
|
+
['A', 'a'],
|
26
|
+
['B', 'b'],
|
27
|
+
['c', 'c'],
|
28
|
+
['5', '5']
|
29
|
+
];
|
30
|
+
uppercaseAlphabetTranslations.forEach(([arrowKey, ahkHotkey]) => {
|
31
|
+
it(`should translate ${arrowKey} to ${ahkHotkey} success`, () => {
|
32
|
+
const result = (0, hotkey_mapper_1.translateKey)(arrowKey);
|
33
|
+
result.should.equal(ahkHotkey);
|
34
|
+
});
|
35
|
+
});
|
36
|
+
});
|
37
|
+
describe('should translate all other keys to success', () => {
|
38
|
+
const uppercaseAlphabetTranslations = [
|
39
|
+
['LEFT', 'Left'],
|
40
|
+
['UP', 'Up'],
|
41
|
+
['DOWN', 'Down'],
|
42
|
+
['RIGHT', 'Right'],
|
43
|
+
['ENTER', 'Enter'],
|
44
|
+
['TAB', 'Tab'],
|
45
|
+
['SPACE', 'Space'],
|
46
|
+
];
|
47
|
+
uppercaseAlphabetTranslations.forEach(([arrowKey, ahkHotkey]) => {
|
48
|
+
it(`should translate ${arrowKey} to ${ahkHotkey} success`, () => {
|
49
|
+
const result = (0, hotkey_mapper_1.translateKey)(arrowKey);
|
50
|
+
result.should.equal(ahkHotkey);
|
51
|
+
});
|
52
|
+
});
|
53
|
+
});
|
54
|
+
describe('should translate special defined keys success', () => {
|
55
|
+
const specialDefinedKeys = [
|
56
|
+
['BACK_SPACE', 'Backspace'],
|
57
|
+
['DELETE', 'Del'],
|
58
|
+
['PAGE_UP', 'PgUp'],
|
59
|
+
['PAGE_DOWN', 'PgDown'],
|
60
|
+
];
|
61
|
+
specialDefinedKeys.forEach(([specialDefinedKey, ahkHotkey]) => {
|
62
|
+
it(`should translate ${specialDefinedKey} to ${ahkHotkey} success`, () => {
|
63
|
+
const result = (0, hotkey_mapper_1.translateKey)(specialDefinedKey);
|
64
|
+
result.should.equal(ahkHotkey);
|
65
|
+
});
|
66
|
+
});
|
67
|
+
});
|
68
|
+
describe('should translate function keys success', () => {
|
69
|
+
const specialDefinedKeys = [
|
70
|
+
['F1', 'F1'],
|
71
|
+
['F12', 'F12'],
|
72
|
+
];
|
73
|
+
specialDefinedKeys.forEach(([specialDefinedKey, ahkHotkey]) => {
|
74
|
+
it(`should translate ${specialDefinedKey} to ${ahkHotkey} success`, () => {
|
75
|
+
const result = (0, hotkey_mapper_1.translateKey)(specialDefinedKey);
|
76
|
+
result.should.equal(ahkHotkey);
|
77
|
+
});
|
78
|
+
});
|
79
|
+
});
|
80
|
+
describe('should translate symbols success', () => {
|
81
|
+
const symbolsTranslation = [
|
82
|
+
['COMMA', ','],
|
83
|
+
['SEMICOLON', ';'],
|
84
|
+
['SLASH', '/'],
|
85
|
+
['OPEN_BRACKET', '['],
|
86
|
+
['CLOSE_BRACKET', ']'],
|
87
|
+
['ADD', '!='],
|
88
|
+
['MINUS', '-'],
|
89
|
+
['SUBSTRATE', '-'],
|
90
|
+
['EQUAL', '='],
|
91
|
+
['BACK_QUOTE', '`'],
|
92
|
+
['MULTIPLY', '*'],
|
93
|
+
];
|
94
|
+
symbolsTranslation.forEach(([symbol, ahkHotkey]) => {
|
95
|
+
it(`should translate ${symbol} to ${ahkHotkey} success`, () => {
|
96
|
+
const result = (0, hotkey_mapper_1.translateKey)(symbol);
|
97
|
+
result.should.equal(ahkHotkey);
|
98
|
+
});
|
99
|
+
});
|
100
|
+
});
|
101
|
+
it('should throw error if unknown key is passed', () => {
|
102
|
+
const unknownKey = 'HELL';
|
103
|
+
(0, chai_1.expect)(() => (0, hotkey_mapper_1.translateKey)(unknownKey)).to.throws(`unknown key: ${unknownKey}`);
|
104
|
+
});
|
105
|
+
});
|
106
|
+
//# sourceMappingURL=hotkey-mapper.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"hotkey-mapper.test.js","sourceRoot":"","sources":["../../src/test/hotkey-mapper.test.ts"],"names":[],"mappings":";;AAAA,oDAA8C;AAC9C,6BAA6B;AAC7B,+BAA4B;AAE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BAAY,EAAC,MAAM,CAAC,CAAA;gBACnC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;YAClC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACnD,MAAM,UAAU,GAAG,MAAM,CAAA;QACzB,IAAA,aAAM,EAAC,GAAG,EAAE,CAAC,IAAA,4BAAY,EAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAA;IAClF,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const chai = require("chai");
|
4
|
+
const translator_1 = require("../translator");
|
5
|
+
chai.should();
|
6
|
+
describe('translator tests', () => {
|
7
|
+
it('should translate key action to ahkscript instruction success with action name', () => {
|
8
|
+
const keyAction = [{ keys: ['meta', 'K', 'M', 'P'], action: 'test one' }];
|
9
|
+
const result = (0, translator_1.translate)(keyAction);
|
10
|
+
result.length.should.equal(1);
|
11
|
+
const target = result[0];
|
12
|
+
target.action.should.equal('test one');
|
13
|
+
});
|
14
|
+
it('should translate keys to left construction success', () => {
|
15
|
+
const keyAction = [{ keys: ['control', 'meta', 'shift', 'alt', 'K', 'M', 'P'], action: 'test one' }];
|
16
|
+
const result = (0, translator_1.translate)(keyAction);
|
17
|
+
const target = result[0];
|
18
|
+
target.left.should.equal('^#+!kmp');
|
19
|
+
});
|
20
|
+
it('should translate modifier keys to right construction success', () => {
|
21
|
+
const keyAction = [{ keys: ['control', 'meta', 'shift', 'alt'], action: 'test one' }];
|
22
|
+
const result = (0, translator_1.translate)(keyAction);
|
23
|
+
result.length.should.equal(1);
|
24
|
+
const target = result[0];
|
25
|
+
target.right.should.eql(['LCtrl', 'LWin', 'LShift', 'LAlt']);
|
26
|
+
});
|
27
|
+
it('should translate other keys to right as hotkey mapper success', () => {
|
28
|
+
const keyAction = [{ keys: ['meta', 'K', 'UP', 'HOME'], action: 'test one' }];
|
29
|
+
const result = (0, translator_1.translate)(keyAction);
|
30
|
+
const target = result[0];
|
31
|
+
target.right.should.eql(['LWin', 'k', 'Up', 'Home']);
|
32
|
+
});
|
33
|
+
it('should return error msg when keys contains unknown key', () => {
|
34
|
+
const unknownKey = 'WrongKey';
|
35
|
+
const action = 'test one';
|
36
|
+
const unknownKeyAction = [{ keys: ['WrongKey', 'K', 'UP', 'HOME'], action: action }];
|
37
|
+
const result = (0, translator_1.translate)(unknownKeyAction);
|
38
|
+
const target = result[0];
|
39
|
+
target.should.be.equal(`unknown key: ${unknownKey}, skip action: ${action}`);
|
40
|
+
});
|
41
|
+
it('should not map keys without meta or arrow keys', () => {
|
42
|
+
const keyAction = [{ keys: ['K', 'HOME'], action: 'skip one' }];
|
43
|
+
const result = (0, translator_1.translate)(keyAction);
|
44
|
+
result.length.should.be.equal(0);
|
45
|
+
});
|
46
|
+
it('should translate constructions with same keys success', () => {
|
47
|
+
const keyAction = [{ keys: ['meta', 'K'], action: 'test one' }, { keys: ['meta', 'K'], action: 'test two' }];
|
48
|
+
const result = (0, translator_1.translate)(keyAction);
|
49
|
+
result.length.should.be.equal(1);
|
50
|
+
const target = result[0];
|
51
|
+
target.right.should.eql(['LWin', 'k']);
|
52
|
+
target.action.should.eql('test one & test two');
|
53
|
+
});
|
54
|
+
});
|
55
|
+
//# sourceMappingURL=translator.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"translator.test.js","sourceRoot":"","sources":["../../src/test/translator.test.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,8CAAyD;AAEzD,IAAI,CAAC,MAAM,EAAE,CAAA;AAEb,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC9B,EA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G,CAAC,EAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAC,CAAC,CAAA;QAC7D,MAAM,MAAM,GAAG,IAAA,sBAAS,EAAC,SAAS,CAAC,CAAA;QAEnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IACF,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC7D,MAAM,SAAS,GAAG,CAAC,EAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,EAAC,EAAE,EAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,EAAC,CAAC,CAAA;QACxG,MAAM,MAAM,GAAG,IAAA,sBAAS,EAAC,SAAS,CAAC,CAAA;QAEnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAoB,CAAA;QAC3C,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;QACtC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;IACnD,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export interface KeyAction {
|
2
|
+
keys: string[];
|
3
|
+
action: string;
|
4
|
+
}
|
5
|
+
export declare const ArrowKeys: string[];
|
6
|
+
export declare const MetaKey = "meta";
|
7
|
+
export interface TranslateResult {
|
8
|
+
action: string;
|
9
|
+
left: string;
|
10
|
+
right: string[];
|
11
|
+
}
|
12
|
+
export declare const translate: (actions: KeyAction[]) => (string | TranslateResult)[];
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.translate = exports.MetaKey = exports.ArrowKeys = void 0;
|
4
|
+
const _ = require("lodash");
|
5
|
+
const hotkey_mapper_1 = require("./hotkey-mapper");
|
6
|
+
const modifierMap = {
|
7
|
+
'^': 'LCtrl',
|
8
|
+
'!': 'LAlt',
|
9
|
+
'+': 'LShift',
|
10
|
+
'#': 'LWin'
|
11
|
+
};
|
12
|
+
exports.ArrowKeys = ['UP', 'DOWN', 'RIGHT', 'LEFT'];
|
13
|
+
exports.MetaKey = 'meta';
|
14
|
+
const isMetaKeyOrArrowKey = (action) => action.keys.some(key => key === exports.MetaKey || exports.ArrowKeys.includes(key));
|
15
|
+
const translate = (actions) => {
|
16
|
+
let ahkStore = {};
|
17
|
+
const errStore = [];
|
18
|
+
_.filter(actions, isMetaKeyOrArrowKey)
|
19
|
+
.forEach((action) => {
|
20
|
+
try {
|
21
|
+
const translated = _.map(action.keys, (key) => (0, hotkey_mapper_1.translateKey)(key));
|
22
|
+
const left = translated.join('');
|
23
|
+
if (ahkStore[left]) {
|
24
|
+
ahkStore[left].action = `${ahkStore[left].action} & ${action.action}`;
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
ahkStore[left] = { action: action.action, left: left, right: translateRight(translated) };
|
28
|
+
}
|
29
|
+
}
|
30
|
+
catch (e) {
|
31
|
+
errStore.push(`${e}, skip action: ${action.action}`);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
return [...Object.values(ahkStore), ...errStore];
|
35
|
+
};
|
36
|
+
exports.translate = translate;
|
37
|
+
const translateRight = (translated) => _.map(translated, (key) => { var _a; return (_a = modifierMap[key]) !== null && _a !== void 0 ? _a : key; });
|
38
|
+
//# sourceMappingURL=translator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"translator.js","sourceRoot":"","sources":["../src/translator.ts"],"names":[],"mappings":";;;AAAA,4BAA4B;AAC5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AC,EAAC,CAAA;aAC1F;SACJ;QAAC,OAAO,CAAC,EAAE;YACR,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;SACvD;IACL,CAAC,CAAC,CAAA;IACN,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAC,GAAG,QAAQ,CAAC,CAAA;AACnD,CAAC,CAAA;AApBY,QAAA,SAAS,aAoBrB;AAED,MAAM,cAAc,GAAG,CAAC,UAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,WAAC,OAAA,MAAA,WAAW,CAAC,GAAG,CAAC,mCAAI,GAAG,CAAA,EAAA,CAAC,CAAA"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getParsedResult = void 0;
|
4
|
+
const parser = require("fast-xml-parser");
|
5
|
+
const _ = require("lodash");
|
6
|
+
const parseOption = {
|
7
|
+
ignoreAttributes: false,
|
8
|
+
parseNodeValue: false,
|
9
|
+
parseAttributeValue: true,
|
10
|
+
trimValues: true,
|
11
|
+
};
|
12
|
+
const getParsedResult = (rawXml) => {
|
13
|
+
const parsedKeymap = parser.parse(rawXml, parseOption);
|
14
|
+
const actions = parsedKeymap.keymap.action;
|
15
|
+
return _.chain(actions)
|
16
|
+
.filter((action) => action['keyboard-shortcut'])
|
17
|
+
.flatMap((action) => _.map(tryConvertToCollection(action['keyboard-shortcut']), (key) => ({ "keys": key["@_first-keystroke"].split(' '), "action": action['@_id'] }))).value();
|
18
|
+
};
|
19
|
+
exports.getParsedResult = getParsedResult;
|
20
|
+
const tryConvertToCollection = (input) => {
|
21
|
+
if (Array.isArray(input)) {
|
22
|
+
return input;
|
23
|
+
}
|
24
|
+
else {
|
25
|
+
return [input];
|
26
|
+
}
|
27
|
+
};
|
28
|
+
//# sourceMappingURL=xmlParser.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"xmlParser.js","sourceRoot":"","sources":["../src/xmlParser.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,4BAA4B;AAQ5B,MAAM,WAAW,GAAG;IAChB,gBAAgB,EAAE,KAAK;IACvB,cAAc,EAAE,KAAK;IACrB,mBAAmB,EAAE,IAAI;IACzB,UAAU,EAAE,IAAI;CACnB,CAAA;AAGM,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,EAAE;IAC9C,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,CAAW,CAAA;IAEhE,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC;IAE3C,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;SAClB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;SAC/C,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAChB,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,EACrD,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAC,MAAM,EAAG,GAAG,CAAC,mBAAmB,CAAY,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAW,EAAC,CAAC,CAC3G,CACJ,CAAC,KAAK,EAAE,CAAA;AACjB,CAAC,CAAA;AAZY,QAAA,eAAe,mBAY3B;AAED,MAAM,sBAAsB,GAAG,CAAI,KAAc,EAAE,EAAE;IACjD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACtB,OAAO,KAAK,CAAA;KACf;SAAM;QACH,OAAO,CAAC,KAAK,CAAC,CAAA;KACjB;AACL,CAAC,CAAA"}
|
package/package.json
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "osx-jetbrains-keymap-generator",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"description": "generate autohotkeymap script from jetbrains keymap config for windows user",
|
5
|
-
"main": "
|
5
|
+
"main": "dist/main.js",
|
6
|
+
"types": "dist/main.d.ts",
|
6
7
|
"bin": {
|
7
|
-
"kmg": "
|
8
|
+
"kmg": "dist/main.js"
|
8
9
|
},
|
9
10
|
"scripts": {
|
10
|
-
"
|
11
|
+
"build": "tsc",
|
12
|
+
"start": "tsc && node dist/main.js",
|
11
13
|
"test": "mocha -r ts-node/register src/test/**/*.test.ts"
|
12
14
|
},
|
13
15
|
"author": "selimeli",
|
@@ -18,18 +20,18 @@
|
|
18
20
|
"license": "MIT",
|
19
21
|
"devDependencies": {
|
20
22
|
"@types/chai": "^4.2.21",
|
23
|
+
"@types/lodash": "^4.14.175",
|
21
24
|
"@types/mocha": "^9.0.0",
|
22
25
|
"@types/node": "^16.7.13",
|
23
26
|
"@typescript-eslint/eslint-plugin": "^4.30.0",
|
24
27
|
"@typescript-eslint/parser": "^4.30.0",
|
25
|
-
"@types/lodash": "^4.14.175",
|
26
28
|
"chai": "^4.3.4",
|
27
29
|
"eslint": "^7.32.0",
|
28
30
|
"eslint-plugin-node": "^11.1.0",
|
29
31
|
"mocha": "^9.1.1",
|
30
32
|
"nodeman": "^1.1.2",
|
31
33
|
"prettier": "^2.3.2",
|
32
|
-
"ts-node": "^10.
|
34
|
+
"ts-node": "^10.3.0",
|
33
35
|
"typescript": "^4.4.2"
|
34
36
|
},
|
35
37
|
"dependencies": {
|
package/tsconfig.json
CHANGED
package/index.js
DELETED