aboutsummaryrefslogtreecommitdiff
path: root/src/content/controllers/MarkKeyController.ts
blob: e7653ee00f1e0d8ad28ea27e594cdc3ad11d013f (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 '../../shared/settings/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;
  }
}