aboutsummaryrefslogtreecommitdiff
path: root/src/content/operators/impls/mark.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/operators/impls/mark.ts')
-rw-r--r--src/content/operators/impls/mark.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/content/operators/impls/mark.ts b/src/content/operators/impls/mark.ts
new file mode 100644
index 0000000..d90aba9
--- /dev/null
+++ b/src/content/operators/impls/mark.ts
@@ -0,0 +1,39 @@
+import { inject, injectable } from "tsyringe";
+import Operator from "../Operator";
+import OperatorFactoryChain from "../OperatorFactoryChain";
+import MarkKeyRepository from "../../repositories/MarkKeyRepository";
+import * as operations from "../../../shared/operations";
+
+export class EnableSetMarkOperator implements Operator {
+ constructor(private readonly repository: MarkKeyRepository) {}
+
+ async run(): Promise<void> {
+ this.repository.enableSetMode();
+ }
+}
+
+export class EnableJumpMarkOperator implements Operator {
+ constructor(private readonly repository: MarkKeyRepository) {}
+
+ async run(): Promise<void> {
+ this.repository.enableJumpMode();
+ }
+}
+
+@injectable()
+export class MarkOperatorFactoryChain implements OperatorFactoryChain {
+ constructor(
+ @inject("MarkKeyRepository")
+ private readonly markKeyRepository: MarkKeyRepository
+ ) {}
+
+ create(op: operations.Operation, _repeat: number): Operator | null {
+ switch (op.type) {
+ case operations.MARK_SET_PREFIX:
+ return new EnableSetMarkOperator(this.markKeyRepository);
+ case operations.MARK_JUMP_PREFIX:
+ return new EnableJumpMarkOperator(this.markKeyRepository);
+ }
+ return null;
+ }
+}