aboutsummaryrefslogtreecommitdiff
path: root/src/console/completion/actions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/console/completion/actions.ts')
-rw-r--r--src/console/completion/actions.ts76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/console/completion/actions.ts b/src/console/completion/actions.ts
new file mode 100644
index 0000000..59d1a04
--- /dev/null
+++ b/src/console/completion/actions.ts
@@ -0,0 +1,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,
+ };
+};