aboutsummaryrefslogtreecommitdiff
path: root/src/content/actions/index.ts
blob: f6d19aabaa976c7118b90dba4518fb88c351fa42 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import Redux from 'redux';
import * as keyUtils from '../../shared/utils/keys';

// User input
export const INPUT_KEY_PRESS = 'input.key.press';
export const INPUT_CLEAR_KEYS = 'input.clear.keys';

// Completion
export const COMPLETION_SET_ITEMS = 'completion.set.items';
export const COMPLETION_SELECT_NEXT = 'completions.select.next';
export const COMPLETION_SELECT_PREV = 'completions.select.prev';

// Follow
export const FOLLOW_CONTROLLER_ENABLE = 'follow.controller.enable';
export const FOLLOW_CONTROLLER_DISABLE = 'follow.controller.disable';
export const FOLLOW_CONTROLLER_KEY_PRESS = 'follow.controller.key.press';
export const FOLLOW_CONTROLLER_BACKSPACE = 'follow.controller.backspace';

// Mark
export const MARK_START_SET = 'mark.start.set';
export const MARK_START_JUMP = 'mark.start.jump';
export const MARK_CANCEL = 'mark.cancel';
export const MARK_SET_LOCAL = 'mark.set.local';

export const NOOP = 'noop';

export interface InputKeyPressAction extends Redux.Action {
  type: typeof INPUT_KEY_PRESS;
  key: keyUtils.Key;
}

export interface InputClearKeysAction extends Redux.Action {
  type: typeof INPUT_CLEAR_KEYS;
}

export interface FollowControllerEnableAction extends Redux.Action {
  type: typeof FOLLOW_CONTROLLER_ENABLE;
  newTab: boolean;
  background: boolean;
}

export interface FollowControllerDisableAction extends Redux.Action {
  type: typeof FOLLOW_CONTROLLER_DISABLE;
}

export interface FollowControllerKeyPressAction extends Redux.Action {
  type: typeof FOLLOW_CONTROLLER_KEY_PRESS;
  key: string;
}

export interface FollowControllerBackspaceAction extends Redux.Action {
  type: typeof FOLLOW_CONTROLLER_BACKSPACE;
}

export interface MarkStartSetAction extends Redux.Action {
  type: typeof MARK_START_SET;
}

export interface MarkStartJumpAction extends Redux.Action {
  type: typeof MARK_START_JUMP;
}

export interface MarkCancelAction extends Redux.Action {
  type: typeof MARK_CANCEL;
}

export interface MarkSetLocalAction extends Redux.Action {
  type: typeof MARK_SET_LOCAL;
  key: string;
  x: number;
  y: number;
}

export interface NoopAction extends Redux.Action {
  type: typeof NOOP;
}

export type InputAction = InputKeyPressAction | InputClearKeysAction;
export type FollowAction =
  FollowControllerEnableAction | FollowControllerDisableAction |
  FollowControllerKeyPressAction | FollowControllerBackspaceAction;
export type MarkAction =
  MarkStartSetAction | MarkStartJumpAction |
  MarkCancelAction | MarkSetLocalAction | NoopAction;

export type Action =
  InputAction |
  FollowAction |
  MarkAction |
  NoopAction;