diff options
Diffstat (limited to 'include/sway/commands.h')
-rw-r--r-- | include/sway/commands.h | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h new file mode 100644 index 00000000..f646c412 --- /dev/null +++ b/include/sway/commands.h | |||
@@ -0,0 +1,181 @@ | |||
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 | enum expected_args { | ||
37 | EXPECTED_MORE_THAN, | ||
38 | EXPECTED_AT_LEAST, | ||
39 | EXPECTED_LESS_THAN, | ||
40 | EXPECTED_EQUAL_TO | ||
41 | }; | ||
42 | |||
43 | struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val); | ||
44 | struct cmd_results *add_color(const char*, char*, const char*); | ||
45 | void input_cmd_apply(struct input_config *input); | ||
46 | void hide_view_in_scratchpad(swayc_t *sp_view); | ||
47 | |||
48 | swayc_t *sp_view; | ||
49 | int sp_index; | ||
50 | |||
51 | /** | ||
52 | * Parse and handles a command. | ||
53 | */ | ||
54 | struct cmd_results *handle_command(char *command); | ||
55 | /** | ||
56 | * Parse and handles a command during config file loading. | ||
57 | * | ||
58 | * Do not use this under normal conditions. | ||
59 | */ | ||
60 | struct cmd_results *config_command(char *command, enum cmd_status block); | ||
61 | |||
62 | /** | ||
63 | * Allocates a cmd_results object. | ||
64 | */ | ||
65 | struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...); | ||
66 | /** | ||
67 | * Frees a cmd_results object. | ||
68 | */ | ||
69 | void free_cmd_results(struct cmd_results *results); | ||
70 | /** | ||
71 | * Serializes cmd_results to a JSON string. | ||
72 | * | ||
73 | * Free the JSON string later on. | ||
74 | */ | ||
75 | const char *cmd_results_to_json(struct cmd_results *results); | ||
76 | |||
77 | void remove_view_from_scratchpad(swayc_t *); | ||
78 | |||
79 | /** | ||
80 | * Actual command function signatures for individual .c files in commands/ directory. | ||
81 | */ | ||
82 | |||
83 | typedef struct cmd_results *sway_cmd(int argc, char **argv); | ||
84 | |||
85 | sway_cmd cmd_assign; | ||
86 | sway_cmd cmd_bar; | ||
87 | sway_cmd cmd_bindcode; | ||
88 | sway_cmd cmd_bindsym; | ||
89 | sway_cmd cmd_border; | ||
90 | sway_cmd cmd_client_focused; | ||
91 | sway_cmd cmd_client_focused_inactive; | ||
92 | sway_cmd cmd_client_unfocused; | ||
93 | sway_cmd cmd_client_urgent; | ||
94 | sway_cmd cmd_client_placeholder; | ||
95 | sway_cmd cmd_client_background; | ||
96 | sway_cmd cmd_debuglog; | ||
97 | sway_cmd cmd_exec; | ||
98 | sway_cmd cmd_exec_always; | ||
99 | sway_cmd cmd_exit; | ||
100 | sway_cmd cmd_floating; | ||
101 | sway_cmd cmd_floating_maximum_size; | ||
102 | sway_cmd cmd_floating_minimum_size; | ||
103 | sway_cmd cmd_floating_mod; | ||
104 | sway_cmd cmd_floating_scroll; | ||
105 | sway_cmd cmd_focus; | ||
106 | sway_cmd cmd_focus_follows_mouse; | ||
107 | sway_cmd cmd_font; | ||
108 | sway_cmd cmd_for_window; | ||
109 | sway_cmd cmd_fullscreen; | ||
110 | sway_cmd cmd_gaps; | ||
111 | sway_cmd cmd_hide_edge_borders; | ||
112 | sway_cmd cmd_include; | ||
113 | sway_cmd cmd_input; | ||
114 | sway_cmd cmd_kill; | ||
115 | sway_cmd cmd_layout; | ||
116 | sway_cmd cmd_log_colors; | ||
117 | sway_cmd cmd_mode; | ||
118 | sway_cmd cmd_mouse_warping; | ||
119 | sway_cmd cmd_move; | ||
120 | sway_cmd cmd_new_float; | ||
121 | sway_cmd cmd_new_window; | ||
122 | sway_cmd cmd_orientation; | ||
123 | sway_cmd cmd_output; | ||
124 | sway_cmd cmd_reload; | ||
125 | sway_cmd cmd_resize; | ||
126 | sway_cmd cmd_scratchpad; | ||
127 | sway_cmd cmd_seamless_mouse; | ||
128 | sway_cmd cmd_set; | ||
129 | sway_cmd cmd_smart_gaps; | ||
130 | sway_cmd cmd_split; | ||
131 | sway_cmd cmd_splith; | ||
132 | sway_cmd cmd_splitt; | ||
133 | sway_cmd cmd_splitv; | ||
134 | sway_cmd cmd_sticky; | ||
135 | sway_cmd cmd_workspace; | ||
136 | sway_cmd cmd_ws_auto_back_and_forth; | ||
137 | sway_cmd cmd_workspace_layout; | ||
138 | |||
139 | sway_cmd bar_cmd_binding_mode_indicator; | ||
140 | sway_cmd bar_cmd_bindsym; | ||
141 | sway_cmd bar_cmd_colors; | ||
142 | sway_cmd bar_cmd_font; | ||
143 | sway_cmd bar_cmd_mode; | ||
144 | sway_cmd bar_cmd_modifier; | ||
145 | sway_cmd bar_cmd_output; | ||
146 | sway_cmd bar_cmd_height; | ||
147 | sway_cmd bar_cmd_hidden_state; | ||
148 | sway_cmd bar_cmd_id; | ||
149 | sway_cmd bar_cmd_position; | ||
150 | sway_cmd bar_cmd_separator_symbol; | ||
151 | sway_cmd bar_cmd_status_command; | ||
152 | sway_cmd bar_cmd_pango_markup; | ||
153 | sway_cmd bar_cmd_strip_workspace_numbers; | ||
154 | sway_cmd bar_cmd_swaybar_command; | ||
155 | sway_cmd bar_cmd_tray_output; | ||
156 | sway_cmd bar_cmd_tray_padding; | ||
157 | sway_cmd bar_cmd_wrap_scroll; | ||
158 | sway_cmd bar_cmd_workspace_buttons; | ||
159 | |||
160 | sway_cmd bar_colors_cmd_active_workspace; | ||
161 | sway_cmd bar_colors_cmd_background; | ||
162 | sway_cmd bar_colors_cmd_background; | ||
163 | sway_cmd bar_colors_cmd_binding_mode; | ||
164 | sway_cmd bar_colors_cmd_focused_workspace; | ||
165 | sway_cmd bar_colors_cmd_inactive_workspace; | ||
166 | sway_cmd bar_colors_cmd_separator; | ||
167 | sway_cmd bar_colors_cmd_statusline; | ||
168 | sway_cmd bar_colors_cmd_urgent_workspace; | ||
169 | |||
170 | sway_cmd input_cmd_accel_profile; | ||
171 | sway_cmd input_cmd_click_method; | ||
172 | sway_cmd input_cmd_drag_lock; | ||
173 | sway_cmd input_cmd_dwt; | ||
174 | sway_cmd input_cmd_events; | ||
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 | #endif | ||