aboutsummaryrefslogtreecommitdiff
path: root/src/console/completion/actions.ts
blob: 0c5e1f1176e40aa41bdf661be5941652ae494f57 (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
import Completions from "../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 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 =
  | SetCompletionSourceAction
  | SetCompletionsAction
  | CompletionNextAction
  | CompletionPrevAction;

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,
  };
};