diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-11-22 21:20:41 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-11-22 21:20:41 -0500 |
commit | d7d21bb0f895248cafefc3d12e4aed033a8e5d17 (patch) | |
tree | f1cf994ea711080c15fed5210054b491ba3c1d05 /include | |
parent | Add views to tree and render them (diff) | |
download | sway-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')
-rw-r--r-- | include/sway/commands.h | 185 |
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 | */ | ||
7 | enum 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 | */ | ||
26 | struct 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 | |||
35 | enum expected_args { | ||
36 | EXPECTED_MORE_THAN, | ||
37 | EXPECTED_AT_LEAST, | ||
38 | EXPECTED_LESS_THAN, | ||
39 | EXPECTED_EQUAL_TO | ||
40 | }; | ||
41 | |||
42 | struct cmd_results *checkarg(int argc, const char *name, | ||
43 | enum expected_args type, int val); | ||
44 | |||
45 | /** | ||
46 | * Parse and handles a command. | ||
47 | */ | ||
48 | struct cmd_results *handle_command(char *command); | ||
49 | /** | ||
50 | * Allocates a cmd_results object. | ||
51 | */ | ||
52 | struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...); | ||
53 | /** | ||
54 | * Frees a cmd_results object. | ||
55 | */ | ||
56 | void 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 | */ | ||
62 | const char *cmd_results_to_json(struct cmd_results *results); | ||
63 | |||
64 | typedef struct cmd_results *sway_cmd(int argc, char **argv); | ||
65 | |||
66 | sway_cmd cmd_assign; | ||
67 | sway_cmd cmd_bar; | ||
68 | sway_cmd cmd_bindcode; | ||
69 | sway_cmd cmd_bindsym; | ||
70 | sway_cmd cmd_border; | ||
71 | sway_cmd cmd_client_focused; | ||
72 | sway_cmd cmd_client_focused_inactive; | ||
73 | sway_cmd cmd_client_unfocused; | ||
74 | sway_cmd cmd_client_urgent; | ||
75 | sway_cmd cmd_client_placeholder; | ||
76 | sway_cmd cmd_client_background; | ||
77 | sway_cmd cmd_clipboard; | ||
78 | sway_cmd cmd_commands; | ||
79 | sway_cmd cmd_debuglog; | ||
80 | sway_cmd cmd_default_border; | ||
81 | sway_cmd cmd_default_floating_border; | ||
82 | sway_cmd cmd_exec; | ||
83 | sway_cmd cmd_exec_always; | ||
84 | sway_cmd cmd_exit; | ||
85 | sway_cmd cmd_floating; | ||
86 | sway_cmd cmd_floating_maximum_size; | ||
87 | sway_cmd cmd_floating_minimum_size; | ||
88 | sway_cmd cmd_floating_mod; | ||
89 | sway_cmd cmd_floating_scroll; | ||
90 | sway_cmd cmd_focus; | ||
91 | sway_cmd cmd_focus_follows_mouse; | ||
92 | sway_cmd cmd_font; | ||
93 | sway_cmd cmd_for_window; | ||
94 | sway_cmd cmd_force_focus_wrapping; | ||
95 | sway_cmd cmd_fullscreen; | ||
96 | sway_cmd cmd_gaps; | ||
97 | sway_cmd cmd_hide_edge_borders; | ||
98 | sway_cmd cmd_include; | ||
99 | sway_cmd cmd_input; | ||
100 | sway_cmd cmd_ipc; | ||
101 | sway_cmd cmd_kill; | ||
102 | sway_cmd cmd_layout; | ||
103 | sway_cmd cmd_log_colors; | ||
104 | sway_cmd cmd_mark; | ||
105 | sway_cmd cmd_mode; | ||
106 | sway_cmd cmd_mouse_warping; | ||
107 | sway_cmd cmd_move; | ||
108 | sway_cmd cmd_new_float; | ||
109 | sway_cmd cmd_new_window; | ||
110 | sway_cmd cmd_no_focus; | ||
111 | sway_cmd cmd_orientation; | ||
112 | sway_cmd cmd_output; | ||
113 | sway_cmd cmd_permit; | ||
114 | sway_cmd cmd_reject; | ||
115 | sway_cmd cmd_reload; | ||
116 | sway_cmd cmd_resize; | ||
117 | sway_cmd cmd_scratchpad; | ||
118 | sway_cmd cmd_seamless_mouse; | ||
119 | sway_cmd cmd_set; | ||
120 | sway_cmd cmd_show_marks; | ||
121 | sway_cmd cmd_smart_gaps; | ||
122 | sway_cmd cmd_split; | ||
123 | sway_cmd cmd_splith; | ||
124 | sway_cmd cmd_splitt; | ||
125 | sway_cmd cmd_splitv; | ||
126 | sway_cmd cmd_sticky; | ||
127 | sway_cmd cmd_unmark; | ||
128 | sway_cmd cmd_workspace; | ||
129 | sway_cmd cmd_ws_auto_back_and_forth; | ||
130 | sway_cmd cmd_workspace_layout; | ||
131 | |||
132 | sway_cmd bar_cmd_activate_button; | ||
133 | sway_cmd bar_cmd_binding_mode_indicator; | ||
134 | sway_cmd bar_cmd_bindsym; | ||
135 | sway_cmd bar_cmd_colors; | ||
136 | sway_cmd bar_cmd_context_button; | ||
137 | sway_cmd bar_cmd_font; | ||
138 | sway_cmd bar_cmd_mode; | ||
139 | sway_cmd bar_cmd_modifier; | ||
140 | sway_cmd bar_cmd_output; | ||
141 | sway_cmd bar_cmd_height; | ||
142 | sway_cmd bar_cmd_hidden_state; | ||
143 | sway_cmd bar_cmd_icon_theme; | ||
144 | sway_cmd bar_cmd_id; | ||
145 | sway_cmd bar_cmd_position; | ||
146 | sway_cmd bar_cmd_secondary_button; | ||
147 | sway_cmd bar_cmd_separator_symbol; | ||
148 | sway_cmd bar_cmd_status_command; | ||
149 | sway_cmd bar_cmd_pango_markup; | ||
150 | sway_cmd bar_cmd_strip_workspace_numbers; | ||
151 | sway_cmd bar_cmd_swaybar_command; | ||
152 | sway_cmd bar_cmd_tray_output; | ||
153 | sway_cmd bar_cmd_tray_padding; | ||
154 | sway_cmd bar_cmd_wrap_scroll; | ||
155 | sway_cmd bar_cmd_workspace_buttons; | ||
156 | |||
157 | sway_cmd bar_colors_cmd_active_workspace; | ||
158 | sway_cmd bar_colors_cmd_background; | ||
159 | sway_cmd bar_colors_cmd_focused_background; | ||
160 | sway_cmd bar_colors_cmd_binding_mode; | ||
161 | sway_cmd bar_colors_cmd_focused_workspace; | ||
162 | sway_cmd bar_colors_cmd_inactive_workspace; | ||
163 | sway_cmd bar_colors_cmd_separator; | ||
164 | sway_cmd bar_colors_cmd_focused_separator; | ||
165 | sway_cmd bar_colors_cmd_statusline; | ||
166 | sway_cmd bar_colors_cmd_focused_statusline; | ||
167 | sway_cmd bar_colors_cmd_urgent_workspace; | ||
168 | |||
169 | sway_cmd input_cmd_accel_profile; | ||
170 | sway_cmd input_cmd_click_method; | ||
171 | sway_cmd input_cmd_drag_lock; | ||
172 | sway_cmd input_cmd_dwt; | ||
173 | sway_cmd input_cmd_events; | ||
174 | sway_cmd input_cmd_left_handed; | ||
175 | sway_cmd input_cmd_middle_emulation; | ||
176 | sway_cmd input_cmd_natural_scroll; | ||
177 | sway_cmd input_cmd_pointer_accel; | ||
178 | sway_cmd input_cmd_scroll_method; | ||
179 | sway_cmd input_cmd_tap; | ||
180 | |||
181 | sway_cmd cmd_ipc_cmd; | ||
182 | sway_cmd cmd_ipc_events; | ||
183 | sway_cmd cmd_ipc_event_cmd; | ||
184 | |||
185 | #endif | ||