aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/commands.h
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-05-30 13:20:02 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-06-02 08:07:44 -0400
commit7c810dc344c28d1876c5ee158cb0806289d0f813 (patch)
treedbe756bceca42ea6f9a6cf5e5771037417bb64c3 /include/sway/commands.h
parentMerge pull request #2080 from frsfnrrg/keyboard-remodeling (diff)
downloadsway-7c810dc344c28d1876c5ee158cb0806289d0f813.tar.gz
sway-7c810dc344c28d1876c5ee158cb0806289d0f813.tar.zst
sway-7c810dc344c28d1876c5ee158cb0806289d0f813.zip
Make command block implementation generic
Diffstat (limited to 'include/sway/commands.h')
-rw-r--r--include/sway/commands.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index b2255c4b..6e2395bd 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -3,6 +3,13 @@
3 3
4#include "config.h" 4#include "config.h"
5 5
6typedef struct cmd_results *sway_cmd(int argc, char **argv);
7
8struct cmd_handler {
9 char *command;
10 sway_cmd *handle;
11};
12
6/** 13/**
7 * Indicates the result of a command's execution. 14 * Indicates the result of a command's execution.
8 */ 15 */
@@ -11,16 +18,9 @@ enum cmd_status {
11 CMD_FAILURE, /**< The command resulted in an error */ 18 CMD_FAILURE, /**< The command resulted in an error */
12 CMD_INVALID, /**< Unknown command or parser error */ 19 CMD_INVALID, /**< Unknown command or parser error */
13 CMD_DEFER, /**< Command execution deferred */ 20 CMD_DEFER, /**< Command execution deferred */
14 // Config Blocks 21 CMD_BLOCK,
15 CMD_BLOCK_END,
16 CMD_BLOCK_MODE,
17 CMD_BLOCK_BAR,
18 CMD_BLOCK_BAR_COLORS,
19 CMD_BLOCK_INPUT,
20 CMD_BLOCK_SEAT,
21 CMD_BLOCK_COMMANDS, 22 CMD_BLOCK_COMMANDS,
22 CMD_BLOCK_IPC, 23 CMD_BLOCK_END
23 CMD_BLOCK_IPC_EVENTS,
24}; 24};
25 25
26/** 26/**
@@ -45,6 +45,8 @@ enum expected_args {
45struct cmd_results *checkarg(int argc, const char *name, 45struct cmd_results *checkarg(int argc, const char *name,
46 enum expected_args type, int val); 46 enum expected_args type, int val);
47 47
48struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
49 int handlers_size);
48/** 50/**
49 * Parse and executes a command. 51 * Parse and executes a command.
50 */ 52 */
@@ -54,7 +56,12 @@ struct cmd_results *execute_command(char *command, struct sway_seat *seat);
54 * 56 *
55 * Do not use this under normal conditions. 57 * Do not use this under normal conditions.
56 */ 58 */
57struct cmd_results *config_command(char *command, enum cmd_status block); 59struct cmd_results *config_command(char *command);
60/**
61 * Parse and handle a sub command
62 */
63struct cmd_results *subcommand(char **argv, int argc,
64 struct cmd_handler *handlers, int handlers_size);
58/* 65/*
59 * Parses a command policy rule. 66 * Parses a command policy rule.
60 */ 67 */
@@ -77,8 +84,6 @@ const char *cmd_results_to_json(struct cmd_results *results);
77struct cmd_results *add_color(const char *name, 84struct cmd_results *add_color(const char *name,
78 char *buffer, const char *color); 85 char *buffer, const char *color);
79 86
80typedef struct cmd_results *sway_cmd(int argc, char **argv);
81
82sway_cmd cmd_assign; 87sway_cmd cmd_assign;
83sway_cmd cmd_bar; 88sway_cmd cmd_bar;
84sway_cmd cmd_bindcode; 89sway_cmd cmd_bindcode;