diff options
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sway/config.c b/sway/config.c index 23d6ac0d..0026e0af 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -225,14 +225,46 @@ bool read_config(FILE *file, bool is_active) { | |||
225 | config->active = true; | 225 | config->active = true; |
226 | } | 226 | } |
227 | bool success = true; | 227 | bool success = true; |
228 | enum cmd_status block = CMD_BLOCK_END; | ||
228 | 229 | ||
229 | char *line; | 230 | char *line; |
230 | while (!feof(file)) { | 231 | while (!feof(file)) { |
231 | line = read_line(file); | 232 | line = read_line(file); |
232 | line = strip_comments(line); | 233 | line = strip_comments(line); |
233 | if (config_command(line) == CMD_FAILURE) { | 234 | switch(config_command(line)) { |
235 | case CMD_FAILURE: | ||
236 | case CMD_INVALID: | ||
234 | sway_log(L_ERROR, "Error on line '%s'", line); | 237 | sway_log(L_ERROR, "Error on line '%s'", line); |
235 | success = false; | 238 | success = false; |
239 | break; | ||
240 | |||
241 | case CMD_DEFER: | ||
242 | sway_log(L_DEBUG, "Defferring command `%s'", line); | ||
243 | list_add(config->cmd_queue, strdup(line)); | ||
244 | break; | ||
245 | |||
246 | case CMD_BLOCK_MODE: | ||
247 | if (block == CMD_BLOCK_END) { | ||
248 | block = CMD_BLOCK_MODE; | ||
249 | } else { | ||
250 | sway_log(L_ERROR, "Invalid block '%s'", line); | ||
251 | } | ||
252 | break; | ||
253 | |||
254 | case CMD_BLOCK_END: | ||
255 | switch(block) { | ||
256 | case CMD_BLOCK_MODE: | ||
257 | sway_log(L_DEBUG, "End of mode block"); | ||
258 | config->current_mode = config->modes->items[0]; | ||
259 | break; | ||
260 | |||
261 | case CMD_BLOCK_END: | ||
262 | sway_log(L_ERROR, "Unmatched }"); | ||
263 | break; | ||
264 | |||
265 | default:; | ||
266 | } | ||
267 | default:; | ||
236 | } | 268 | } |
237 | free(line); | 269 | free(line); |
238 | } | 270 | } |