aboutsummaryrefslogtreecommitdiff
path: root/src/content/operators/impls/focus.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/operators/impls/focus.ts')
-rw-r--r--src/content/operators/impls/focus.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/content/operators/impls/focus.ts b/src/content/operators/impls/focus.ts
new file mode 100644
index 0000000..ea8e27d
--- /dev/null
+++ b/src/content/operators/impls/focus.ts
@@ -0,0 +1,29 @@
+import { inject, injectable } from "tsyringe";
+import Operator from "../Operator";
+import OperatorFactoryChain from "../OperatorFactoryChain";
+import FocusPresenter from "../../presenters/FocusPresenter";
+import * as operations from "../../../shared/operations";
+
+export class FocusOperator implements Operator {
+ constructor(private readonly presenter: FocusPresenter) {}
+
+ async run(): Promise<void> {
+ this.presenter.focusFirstElement();
+ }
+}
+
+@injectable()
+export class FocusOperatorFactoryChain implements OperatorFactoryChain {
+ constructor(
+ @inject("FocusPresenter")
+ private readonly focusPresenter: FocusPresenter
+ ) {}
+
+ create(op: operations.Operation, _repeat: number): Operator | null {
+ switch (op.type) {
+ case operations.FOCUS_INPUT:
+ return new FocusOperator(this.focusPresenter);
+ }
+ return null;
+ }
+}