aboutsummaryrefslogtreecommitdiff
path: root/src/console/completion/actions.ts
blob: 59d1a048f7f58ea5a5e8960103a38616d69e5312 (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
import CompletionType from "../../shared/CompletionType";
import Completions from "../Completions";

export const INIT_COMPLETIONS = "reset.completions";
export const SET_COMPLETION_SOURCE = "set.completion.source";
export const SET_COMPLETIONS = "set.completions";
export const COMPLETION_NEXT = "completion.next";
export const COMPLETION_PREV = "completion.prev";

export interface InitCompletionAction {
  type: typeof INIT_COMPLETIONS;
  completionTypes: CompletionType[];
}

export interface SetCompletionSourceAction {
  type: typeof SET_COMPLETION_SOURCE;
  completionSource: string;
}

export interface SetCompletionsAction {
  type: typeof SET_COMPLETIONS;
  completions: Completions;
}

export interface CompletionNextAction {
  type: typeof COMPLETION_NEXT;
}

export interface CompletionPrevAction {
  type: typeof COMPLETION_PREV;
}

export type CompletionAction =
  | InitCompletionAction
  | SetCompletionSourceAction
  | SetCompletionsAction
  | CompletionNextAction
  | CompletionPrevAction;

export const initCompletion = (
  completionTypes: CompletionType[]
): InitCompletionAction => {
  return {
    type: INIT_COMPLETIONS,
    completionTypes,
  };
};
export const setCompletionSource = (
  query: string
): SetCompletionSourceAction => {
  return {
    type: SET_COMPLETION_SOURCE,
    completionSource: query,
  };
};

export const setCompletions = (
  completions: Completions
): SetCompletionsAction => {
  return {
    type: SET_COMPLETIONS,
    completions,
  };
};

export const selectNext = (): CompletionNextAction => {
  return {
    type: COMPLETION_NEXT,
  };
};

export const selectPrev = (): CompletionPrevAction => {
  return {
    type: COMPLETION_PREV,
  };
};