diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-05 22:10:56 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-05 22:10:56 -0400 |
commit | d0f1fb71d11a709c55b0ed56a9f35920c1282ec8 (patch) | |
tree | 32edb44c8f44e3cbe52043566c688de48b795730 /sway/config.c | |
parent | e07c77fbb78b1d57a19904f2f5a7309ddfc40955 (diff) |
Flesh out some command parsing
This implements the `set` command from i3
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 22 |
1 files changed, 17 insertions, 5 deletions
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; } |