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