aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/commands.h
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-11-22 21:20:41 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-22 21:20:41 -0500
commitd7d21bb0f895248cafefc3d12e4aed033a8e5d17 (patch)
treef1cf994ea711080c15fed5210054b491ba3c1d05 /include/sway/commands.h
parentAdd views to tree and render them (diff)
downloadsway-d7d21bb0f895248cafefc3d12e4aed033a8e5d17.tar.gz
sway-d7d21bb0f895248cafefc3d12e4aed033a8e5d17.tar.zst
sway-d7d21bb0f895248cafefc3d12e4aed033a8e5d17.zip
Add initial command subsystem (untested)
Need to spin up the IPC server to test this
Diffstat (limited to 'include/sway/commands.h')
-rw-r--r--include/sway/commands.h185
1 files changed, 185 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
new file mode 100644
index 00000000..df5c6859
--- /dev/null
+++ b/include/sway/commands.h
@@ -0,0 +1,185 @@
1#ifndef _SWAY_COMMANDS_H
2#define _SWAY_COMMANDS_H
3
4/**
5 * Indicates the result of a command's execution.
6 */
7enum cmd_status {
8 CMD_SUCCESS, /**< The command was successful */
9 CMD_FAILURE, /**< The command resulted in an error */
10 CMD_INVALID, /**< Unknown command or parser error */
11 CMD_DEFER, /**< Command execution deferred */
12 // Config Blocks
13 CMD_BLOCK_END,
14 CMD_BLOCK_MODE,
15 CMD_BLOCK_BAR,
16 CMD_BLOCK_BAR_COLORS,
17 CMD_BLOCK_INPUT,
18 CMD_BLOCK_COMMANDS,
19 CMD_BLOCK_IPC,
20 CMD_BLOCK_IPC_EVENTS,
21};
22
23/**
24 * Stores the result of executing a command.
25 */
26struct cmd_results {
27 enum cmd_status status;
28 char *input;
29 /**
30 * Human friendly error message, or NULL on success
31 */
32 char *error;
33};
34
35enum expected_args {
36 EXPECTED_MORE_THAN,
37 EXPECTED_AT_LEAST,
38 EXPECTED_LESS_THAN,
39 EXPECTED_EQUAL_TO
40};
41
42struct cmd_results *checkarg(int argc, const char *name,
43 enum expected_args type, int val);
44
45/**
46 * Parse and handles a command.
47 */
48struct cmd_results *handle_command(char *command);
49/**
50 * Allocates a cmd_results object.
51 */
52struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...);
53/**
54 * Frees a cmd_results object.
55 */
56void free_cmd_results(struct cmd_results *results);
57/**
58 * Serializes cmd_results to a JSON string.
59 *
60 * Free the JSON string later on.
61 */
62const char *cmd_results_to_json(struct cmd_results *results);
63
64typedef struct cmd_results *sway_cmd(int argc, char **argv);
65
66sway_cmd cmd_assign;
67sway_cmd cmd_bar;
68sway_cmd cmd_bindcode;
69sway_cmd cmd_bindsym;
70sway_cmd cmd_border;
71sway_cmd cmd_client_focused;
72sway_cmd cmd_client_focused_inactive;
73sway_cmd cmd_client_unfocused;
74sway_cmd cmd_client_urgent;
75sway_cmd cmd_client_placeholder;
76sway_cmd cmd_client_background;
77sway_cmd cmd_clipboard;
78sway_cmd cmd_commands;
79sway_cmd cmd_debuglog;
80sway_cmd cmd_default_border;
81sway_cmd cmd_default_floating_border;
82sway_cmd cmd_exec;
83sway_cmd cmd_exec_always;
84sway_cmd cmd_exit;
85sway_cmd cmd_floating;
86sway_cmd cmd_floating_maximum_size;
87sway_cmd cmd_floating_minimum_size;
88sway_cmd cmd_floating_mod;
89sway_cmd cmd_floating_scroll;
90sway_cmd cmd_focus;
91sway_cmd cmd_focus_follows_mouse;
92sway_cmd cmd_font;
93sway_cmd cmd_for_window;
94sway_cmd cmd_force_focus_wrapping;
95sway_cmd cmd_fullscreen;
96sway_cmd cmd_gaps;
97sway_cmd cmd_hide_edge_borders;
98sway_cmd cmd_include;
99sway_cmd cmd_input;
100sway_cmd cmd_ipc;
101sway_cmd cmd_kill;
102sway_cmd cmd_layout;
103sway_cmd cmd_log_colors;
104sway_cmd cmd_mark;
105sway_cmd cmd_mode;
106sway_cmd cmd_mouse_warping;
107sway_cmd cmd_move;
108sway_cmd cmd_new_float;
109sway_cmd cmd_new_window;
110sway_cmd cmd_no_focus;
111sway_cmd cmd_orientation;
112sway_cmd cmd_output;
113sway_cmd cmd_permit;
114sway_cmd cmd_reject;
115sway_cmd cmd_reload;
116sway_cmd cmd_resize;
117sway_cmd cmd_scratchpad;
118sway_cmd cmd_seamless_mouse;
119sway_cmd cmd_set;
120sway_cmd cmd_show_marks;
121sway_cmd cmd_smart_gaps;
122sway_cmd cmd_split;
123sway_cmd cmd_splith;
124sway_cmd cmd_splitt;
125sway_cmd cmd_splitv;
126sway_cmd cmd_sticky;
127sway_cmd cmd_unmark;
128sway_cmd cmd_workspace;
129sway_cmd cmd_ws_auto_back_and_forth;
130sway_cmd cmd_workspace_layout;
131
132sway_cmd bar_cmd_activate_button;
133sway_cmd bar_cmd_binding_mode_indicator;
134sway_cmd bar_cmd_bindsym;
135sway_cmd bar_cmd_colors;
136sway_cmd bar_cmd_context_button;
137sway_cmd bar_cmd_font;
138sway_cmd bar_cmd_mode;
139sway_cmd bar_cmd_modifier;
140sway_cmd bar_cmd_output;
141sway_cmd bar_cmd_height;
142sway_cmd bar_cmd_hidden_state;
143sway_cmd bar_cmd_icon_theme;
144sway_cmd bar_cmd_id;
145sway_cmd bar_cmd_position;
146sway_cmd bar_cmd_secondary_button;
147sway_cmd bar_cmd_separator_symbol;
148sway_cmd bar_cmd_status_command;
149sway_cmd bar_cmd_pango_markup;
150sway_cmd bar_cmd_strip_workspace_numbers;
151sway_cmd bar_cmd_swaybar_command;
152sway_cmd bar_cmd_tray_output;
153sway_cmd bar_cmd_tray_padding;
154sway_cmd bar_cmd_wrap_scroll;
155sway_cmd bar_cmd_workspace_buttons;
156
157sway_cmd bar_colors_cmd_active_workspace;
158sway_cmd bar_colors_cmd_background;
159sway_cmd bar_colors_cmd_focused_background;
160sway_cmd bar_colors_cmd_binding_mode;
161sway_cmd bar_colors_cmd_focused_workspace;
162sway_cmd bar_colors_cmd_inactive_workspace;
163sway_cmd bar_colors_cmd_separator;
164sway_cmd bar_colors_cmd_focused_separator;
165sway_cmd bar_colors_cmd_statusline;
166sway_cmd bar_colors_cmd_focused_statusline;
167sway_cmd bar_colors_cmd_urgent_workspace;
168
169sway_cmd input_cmd_accel_profile;
170sway_cmd input_cmd_click_method;
171sway_cmd input_cmd_drag_lock;
172sway_cmd input_cmd_dwt;
173sway_cmd input_cmd_events;
174sway_cmd input_cmd_left_handed;
175sway_cmd input_cmd_middle_emulation;
176sway_cmd input_cmd_natural_scroll;
177sway_cmd input_cmd_pointer_accel;
178sway_cmd input_cmd_scroll_method;
179sway_cmd input_cmd_tap;
180
181sway_cmd cmd_ipc_cmd;
182sway_cmd cmd_ipc_events;
183sway_cmd cmd_ipc_event_cmd;
184
185#endif