make top-content component and frame-content component

This commit is contained in:
Shin'ya Ueoka 2017-10-15 09:02:09 +09:00
parent 042aa94936
commit 4c9d0433a6
13 changed files with 102 additions and 76 deletions

View file

@ -1,31 +0,0 @@
import * as inputActions from 'content/actions/input';
import * as operationActions from 'content/actions/operation';
export default class KeymapperComponent {
constructor(store) {
this.store = store;
}
update() {
}
key(key, ctrl) {
this.store.dispatch(inputActions.keyPress(key, ctrl));
let input = this.store.getState().input;
let matched = Object.keys(input.keymaps).filter((keyStr) => {
return keyStr.startsWith(input.keys);
});
if (matched.length === 0) {
this.store.dispatch(inputActions.clearKeys());
return false;
} else if (matched.length > 1 ||
matched.length === 1 && input.keys !== matched[0]) {
return true;
}
let operation = input.keymaps[matched];
this.store.dispatch(operationActions.exec(operation));
this.store.dispatch(inputActions.clearKeys());
return true;
}
}