summaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-05 22:10:56 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-05 22:10:56 -0400
commitd0f1fb71d11a709c55b0ed56a9f35920c1282ec8 (patch)
tree32edb44c8f44e3cbe52043566c688de48b795730 /sway/config.c
parentBuild out command subsystem (diff)
downloadsway-d0f1fb71d11a709c55b0ed56a9f35920c1282ec8.tar.gz
sway-d0f1fb71d11a709c55b0ed56a9f35920c1282ec8.tar.zst
sway-d0f1fb71d11a709c55b0ed56a9f35920c1282ec8.zip
Flesh out some command parsing
This implements the `set` command from i3
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c22
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) {
11 struct sway_config *config = malloc(sizeof(struct sway_config)); 11 struct sway_config *config = malloc(sizeof(struct sway_config));
12 config->symbols = create_list(); 12 config->symbols = create_list();
13 config->modes = create_list(); 13 config->modes = create_list();
14 config->current_mode = malloc(sizeof(struct sway_mode));
15 config->current_mode->name = NULL;
16 config->current_mode->bindings = create_list();
17 list_add(config->modes, config->current_mode);
14 18
15 int temp_braces = 0; // Temporary: skip all config sections with braces 19 bool success = true;
20
21 int temp_depth = 0; // Temporary: skip all config sections with depth
16 22
17 while (!feof(file)) { 23 while (!feof(file)) {
18 int _; 24 int _;
@@ -22,19 +28,25 @@ struct sway_config *read_config(FILE *file) {
22 if (!line[0]) { 28 if (!line[0]) {
23 goto _continue; 29 goto _continue;
24 } 30 }
25 if (temp_braces && line[0] == '}') { 31 if (temp_depth && line[0] == '}') {
26 temp_braces--; 32 temp_depth--;
27 goto _continue; 33 goto _continue;
28 } 34 }
29 35
30 handle_command(config, line); 36 if (!handle_command(config, line)) {
37 success = false;
38 }
31 39
32_continue: 40_continue:
33 if (line && line[strlen(line) - 1] == '{') { 41 if (line && line[strlen(line) - 1] == '{') {
34 temp_braces++; 42 temp_depth++;
35 } 43 }
36 free(line); 44 free(line);
37 } 45 }
38 46
47 if (!success) {
48 exit(1);
49 }
50
39 return config; 51 return config;
40} 52}