mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Merge branch 'master' into v2
This commit is contained in:
commit
f8c19b0ef2
5 changed files with 21 additions and 71 deletions
|
|
@ -1,5 +1,4 @@
|
|||
const {readFileSync} = require('fs');
|
||||
const {normalize} = require('../utils/keymaps-normalize');
|
||||
const {defaultPlatformKeyPath} = require('./paths');
|
||||
|
||||
const commands = {};
|
||||
|
|
@ -8,7 +7,7 @@ const keys = {};
|
|||
const _setKeysForCommands = function(keymap) {
|
||||
for (const command in keymap) {
|
||||
if (command) {
|
||||
commands[command] = normalize(keymap[command]);
|
||||
commands[command] = keymap[command].toLowerCase();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -39,8 +38,8 @@ const _extend = function(customsKeys) {
|
|||
if (customsKeys) {
|
||||
for (const command in customsKeys) {
|
||||
if (command) {
|
||||
commands[command] = normalize(customsKeys[command]);
|
||||
keys[normalize(customsKeys[command])] = command;
|
||||
commands[command] = customsKeys[command];
|
||||
keys[customsKeys[command]] = command;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
const {getKeymaps} = require('../config/keymaps');
|
||||
|
||||
const normalize = keybinding => {
|
||||
function sortAlphabetically(a, b) {
|
||||
return a.localeCompare(b);
|
||||
}
|
||||
|
||||
return keybinding
|
||||
.toLowerCase()
|
||||
.split('+')
|
||||
.sort(sortAlphabetically)
|
||||
.join('+');
|
||||
};
|
||||
|
||||
const findCommandByKeys = (keys, commands) => {
|
||||
return commands[normalize(keys)];
|
||||
};
|
||||
|
||||
const getCommand = keys => {
|
||||
return findCommandByKeys(keys, getKeymaps().keys);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
normalize,
|
||||
findCommandByKeys,
|
||||
getCommand
|
||||
};
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import {remote} from 'electron';
|
||||
|
||||
const {getCommand} = remote.require('./utils/keymaps-normalize');
|
||||
const {getKeymaps} = remote.require('./config');
|
||||
|
||||
export default function returnKey(e) {
|
||||
let keys = [];
|
||||
|
|
@ -30,5 +30,5 @@ export default function returnKey(e) {
|
|||
}
|
||||
|
||||
keys = keys.join('+');
|
||||
return getCommand(keys);
|
||||
return getKeymaps().keys[keys.toLowerCase()];
|
||||
}
|
||||
|
|
|
|||
20
readme.md
20
readme.md
|
|
@ -30,10 +30,22 @@ choco install hyper
|
|||
|
||||
## Contribute
|
||||
|
||||
1. Install the dependencies
|
||||
* If you are running Linux, install `icnsutils`, `graphicsmagick`, `xz-utils`, `npm`, `rpm` and `yarn`
|
||||
* If you are running Windows, install `yarn` (If you use the MSI installer you will need to install npm), and `windows-build-tools` with `yarn global add windows-build-tools`.
|
||||
* Yarn installation instructions: https://yarnpkg.com/en/docs/install
|
||||
Regardless of the platform you are working on, you will need to have Yarn installed. If you have never installed Yarn before, you can find out how at: https://yarnpkg.com/en/docs/install.
|
||||
|
||||
1. Install necessary packages:
|
||||
* Windows
|
||||
- Be sure to run `yarn global add windows-build-tools` to install `windows-build-tools`.
|
||||
* macOS
|
||||
- Once you have installed Yarn, you can skip this section!
|
||||
* Linux
|
||||
- RPM-based
|
||||
+ `GraphicsMagick`
|
||||
+ `libicns-utils`
|
||||
+ `xz` (Installed by default on some distributions.)
|
||||
- Debian-based
|
||||
+ `graphicsmagick`
|
||||
+ `icnsutils`
|
||||
+ `xz-utils`
|
||||
2. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
3. Install the dependencies: `yarn`
|
||||
4. Build the code and watch for changes: `yarn run dev`
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
import test from 'ava';
|
||||
import {findCommandByKeys} from '../../app/utils/keymaps-normalize';
|
||||
|
||||
const expectedCommand = 'test-command';
|
||||
const expectedLocalizedCommand = 'test-localized-command';
|
||||
|
||||
const commands = {
|
||||
'alt+p+shift': expectedCommand,
|
||||
'ç+cmd+ctrl': expectedLocalizedCommand
|
||||
};
|
||||
|
||||
test(`returns a command`, t => {
|
||||
t.is(findCommandByKeys('alt+shift+p', commands), expectedCommand);
|
||||
|
||||
t.is(findCommandByKeys('shift+p+alt', commands), expectedCommand);
|
||||
|
||||
t.is(findCommandByKeys('p+alt+shift', commands), expectedCommand);
|
||||
|
||||
t.is(findCommandByKeys('alt+shift+P', commands), expectedCommand);
|
||||
|
||||
t.is(findCommandByKeys('Shift+P+Alt', commands), expectedCommand);
|
||||
});
|
||||
|
||||
test(`returns a localized command`, t => {
|
||||
t.is(findCommandByKeys('cmd+ctrl+ç', commands), expectedLocalizedCommand);
|
||||
|
||||
t.is(findCommandByKeys('ç+cmd+ctrl', commands), expectedLocalizedCommand);
|
||||
|
||||
t.is(findCommandByKeys('ctrl+ç+cmd', commands), expectedLocalizedCommand);
|
||||
|
||||
t.is(findCommandByKeys('ctrl+Ç+cmd', commands), expectedLocalizedCommand);
|
||||
|
||||
t.is(findCommandByKeys('Cmd+Ctrl+Ç', commands), expectedLocalizedCommand);
|
||||
});
|
||||
Loading…
Reference in a new issue