blob: eec95d605aea4a3aa4f3319d3c012f29548218e1 (
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 * as keyUtils from '../../../shared/utils/keys';
import MarkUseCase from '../../usecases/MarkUseCase';
let markUseCase = new MarkUseCase();
const cancelKey = (key: keyUtils.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: keyUtils.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;
}
}
|