diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-09-01 08:18:37 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-09-01 08:18:37 -0400 |
commit | 416417a54c5875abcdc257b6ad10ff086c35eefc (patch) | |
tree | 00f20884a05d05e620a4a24bba8595557cd41405 /include/sway/commands.h | |
parent | Merge pull request #876 from zandrmartin/patch-1 (diff) | |
download | sway-416417a54c5875abcdc257b6ad10ff086c35eefc.tar.gz sway-416417a54c5875abcdc257b6ad10ff086c35eefc.tar.zst sway-416417a54c5875abcdc257b6ad10ff086c35eefc.zip |
Reorganize includes
Diffstat (limited to 'include/sway/commands.h')
-rw-r--r-- | include/sway/commands.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h new file mode 100644 index 00000000..cd0610f4 --- /dev/null +++ b/include/sway/commands.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef _SWAY_COMMANDS_H | ||
2 | #define _SWAY_COMMANDS_H | ||
3 | #include <stdbool.h> | ||
4 | #include <json-c/json.h> | ||
5 | #include <wlc/wlc.h> | ||
6 | #include "config.h" | ||
7 | |||
8 | /** | ||
9 | * Indicates the result of a command's execution. | ||
10 | */ | ||
11 | enum cmd_status { | ||
12 | CMD_SUCCESS, /**< The command was successful */ | ||
13 | CMD_FAILURE, /**< The command resulted in an error */ | ||
14 | CMD_INVALID, /**< Unknown command or parser error */ | ||
15 | CMD_DEFER, /**< Command execution deferred */ | ||
16 | // Config Blocks | ||
17 | CMD_BLOCK_END, | ||
18 | CMD_BLOCK_MODE, | ||
19 | CMD_BLOCK_BAR, | ||
20 | CMD_BLOCK_BAR_COLORS, | ||
21 | CMD_BLOCK_INPUT | ||
22 | }; | ||
23 | |||
24 | /** | ||
25 | * Stores the result of executing a command. | ||
26 | */ | ||
27 | struct cmd_results { | ||
28 | enum cmd_status status; | ||
29 | char *input; | ||
30 | /** | ||
31 | * Human friendly error message, or NULL on success | ||
32 | */ | ||
33 | char *error; | ||
34 | }; | ||
35 | |||
36 | /** | ||
37 | * Parse and handles a command. | ||
38 | */ | ||
39 | struct cmd_results *handle_command(char *command); | ||
40 | /** | ||
41 | * Parse and handles a command during config file loading. | ||
42 | * | ||
43 | * Do not use this under normal conditions. | ||
44 | */ | ||
45 | struct cmd_results *config_command(char *command, enum cmd_status block); | ||
46 | |||
47 | /** | ||
48 | * Allocates a cmd_results object. | ||
49 | */ | ||
50 | struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...); | ||
51 | /** | ||
52 | * Frees a cmd_results object. | ||
53 | */ | ||
54 | void free_cmd_results(struct cmd_results *results); | ||
55 | /** | ||
56 | * Serializes cmd_results to a JSON string. | ||
57 | * | ||
58 | * Free the JSON string later on. | ||
59 | */ | ||
60 | const char *cmd_results_to_json(struct cmd_results *results); | ||
61 | |||
62 | void remove_view_from_scratchpad(swayc_t *); | ||
63 | |||
64 | #endif | ||