blob: 058b873a7c696494f8c1042f25d4a924fd97c64c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import * as markActions from '../../actions/mark';
import * as consoleFrames from '../..//console-frames';
import Key from '../../domains/Key';
import MarkUseCase from '../../usecases/MarkUseCase';
let markUseCase = new MarkUseCase();
const cancelKey = (key: Key): boolean => {
return key.key === 'Esc' || key.key === '[' && Boolean(key.ctrlKey);
};
export default class MarkComponent {
private store: any;
constructor(store: any) {
this.store = store;
}
// eslint-disable-next-line max-statements
key(key: Key) {
let { mark: markState } = this.store.getState();
if (!markState.setMode && !markState.jumpMode) {
return false;
}
if (cancelKey(key)) {
this.store.dispatch(markActions.cancel());
return true;
}
if (key.ctrlKey || key.metaKey || key.altKey) {
consoleFrames.postError('Unknown mark');
} else if (markState.setMode) {
markUseCase.set(key.key);
} else if (markState.jumpMode) {
markUseCase.jump(key.key);
}
this.store.dispatch(markActions.cancel());
return true;
}
}
|