From d0f1fb71d11a709c55b0ed56a9f35920c1282ec8 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 5 Aug 2015 22:10:56 -0400 Subject: Flesh out some command parsing This implements the `set` command from i3 --- sway/config.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'sway/config.c') diff --git a/sway/config.c b/sway/config.c index bb6533c2..7242be8d 100644 --- a/sway/config.c +++ b/sway/config.c @@ -11,8 +11,14 @@ struct sway_config *read_config(FILE *file) { struct sway_config *config = malloc(sizeof(struct sway_config)); config->symbols = create_list(); config->modes = create_list(); + config->current_mode = malloc(sizeof(struct sway_mode)); + config->current_mode->name = NULL; + config->current_mode->bindings = create_list(); + list_add(config->modes, config->current_mode); - int temp_braces = 0; // Temporary: skip all config sections with braces + bool success = true; + + int temp_depth = 0; // Temporary: skip all config sections with depth while (!feof(file)) { int _; @@ -22,19 +28,25 @@ struct sway_config *read_config(FILE *file) { if (!line[0]) { goto _continue; } - if (temp_braces && line[0] == '}') { - temp_braces--; + if (temp_depth && line[0] == '}') { + temp_depth--; goto _continue; } - handle_command(config, line); + if (!handle_command(config, line)) { + success = false; + } _continue: if (line && line[strlen(line) - 1] == '{') { - temp_braces++; + temp_depth++; } free(line); } + if (!success) { + exit(1); + } + return config; } -- cgit v1.2.3