aboutsummaryrefslogtreecommitdiff
path: root/src/content/reducers/mark.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/reducers/mark.ts')
-rw-r--r--src/content/reducers/mark.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/content/reducers/mark.ts b/src/content/reducers/mark.ts
new file mode 100644
index 0000000..7409938
--- /dev/null
+++ b/src/content/reducers/mark.ts
@@ -0,0 +1,35 @@
+import Mark from '../Mark';
+import * as actions from '../actions';
+
+export interface State {
+ setMode: boolean;
+ jumpMode: boolean;
+ marks: { [key: string]: Mark };
+}
+
+const defaultState: State = {
+ setMode: false,
+ jumpMode: false,
+ marks: {},
+};
+
+export default function reducer(
+ state: State = defaultState,
+ action: actions.MarkAction,
+): State {
+ switch (action.type) {
+ case actions.MARK_START_SET:
+ return { ...state, setMode: true };
+ case actions.MARK_START_JUMP:
+ return { ...state, jumpMode: true };
+ case actions.MARK_CANCEL:
+ return { ...state, setMode: false, jumpMode: false };
+ case actions.MARK_SET_LOCAL: {
+ let marks = { ...state.marks };
+ marks[action.key] = { x: action.x, y: action.y };
+ return { ...state, setMode: false, marks };
+ }
+ default:
+ return state;
+ }
+}