summaryrefslogtreecommitdiffstats
path: root/include/sway/commands.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/commands.h')
-rw-r--r--include/sway/commands.h64
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 */
11enum 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 */
27struct 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 */
39struct 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 */
45struct cmd_results *config_command(char *command, enum cmd_status block);
46
47/**
48 * Allocates a cmd_results object.
49 */
50struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...);
51/**
52 * Frees a cmd_results object.
53 */
54void 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 */
60const char *cmd_results_to_json(struct cmd_results *results);
61
62void remove_view_from_scratchpad(swayc_t *);
63
64#endif