aboutsummaryrefslogtreecommitdiff
path: root/src/content/usecases
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-14 20:28:22 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-05-18 21:25:18 +0900
commit2ec912c262b51fe9523ebf74d5062d0b9bbdab71 (patch)
treebbda7eef0730cd1bff7b88850fbe3327e7d4f4e3 /src/content/usecases
parentefc48dc7421e3bd48534bc94f84e2b0bd47ae47c (diff)
Mark keys as a clean archtecture
Diffstat (limited to 'src/content/usecases')
-rw-r--r--src/content/usecases/MarkKeyUseCase.ts36
-rw-r--r--src/content/usecases/MarkUseCase.ts8
2 files changed, 42 insertions, 2 deletions
diff --git a/src/content/usecases/MarkKeyUseCase.ts b/src/content/usecases/MarkKeyUseCase.ts
new file mode 100644
index 0000000..c0aa655
--- /dev/null
+++ b/src/content/usecases/MarkKeyUseCase.ts
@@ -0,0 +1,36 @@
+import MarkKeyRepository, { MarkKeyRepositoryImpl }
+ from '../repositories/MarkKeyRepository';
+
+export default class MarkKeyUseCase {
+ private repository: MarkKeyRepository;
+
+ constructor({
+ repository = new MarkKeyRepositoryImpl()
+ } = {}) {
+ this.repository = repository;
+ }
+
+ isSetMode(): boolean {
+ return this.repository.isSetMode();
+ }
+
+ isJumpMode(): boolean {
+ return this.repository.isJumpMode();
+ }
+
+ enableSetMode(): void {
+ this.repository.enableSetMode();
+ }
+
+ disableSetMode(): void {
+ this.repository.disabeSetMode();
+ }
+
+ enableJumpMode(): void {
+ this.repository.enableJumpMode();
+ }
+
+ disableJumpMode(): void {
+ this.repository.disabeJumpMode();
+ }
+}
diff --git a/src/content/usecases/MarkUseCase.ts b/src/content/usecases/MarkUseCase.ts
index ec63f2b..530f141 100644
--- a/src/content/usecases/MarkUseCase.ts
+++ b/src/content/usecases/MarkUseCase.ts
@@ -51,11 +51,15 @@ export default class MarkUseCase {
if (!pos) {
throw new Error('Mark is not set');
}
- let smooth = this.settingRepository.get().properties.smoothscroll;
- this.scrollPresenter.scrollTo(pos.x, pos.y, smooth);
+ this.scroll(pos.x, pos.y);
}
}
+ scroll(x: number, y: number): void {
+ let smooth = this.settingRepository.get().properties.smoothscroll;
+ this.scrollPresenter.scrollTo(x, y, smooth);
+ }
+
private globalKey(key: string) {
return (/^[A-Z0-9]$/).test(key);
}