aboutsummaryrefslogtreecommitdiff
path: root/src/content/controllers/MarkKeyController.ts
blob: 886e5ff97de9650e49496f57a25dc492254e9d46 (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
import { injectable } from 'tsyringe';
import MarkUseCase from '../usecases/MarkUseCase';
import MarkKeyyUseCase from '../usecases/MarkKeyUseCase';
import Key from '../domains/Key';

@injectable()
export default class MarkKeyController {
  constructor(
    private markUseCase: MarkUseCase,
    private markKeyUseCase: MarkKeyyUseCase,
  ) {
  }

  press(key: Key): boolean {
    if (this.markKeyUseCase.isSetMode()) {
      this.markUseCase.set(key.key);
      this.markKeyUseCase.disableSetMode();
      return true;
    }
    if (this.markKeyUseCase.isJumpMode()) {
      this.markUseCase.jump(key.key);
      this.markKeyUseCase.disableJumpMode();
      return true;
    }
    return false;
  }
}