mirror of
https://github.com/swaywm/sway.git
synced 2025-11-08 13:29:50 -05:00
Build out command subsystem
Everyone loves code stolen from your own projects
This commit is contained in:
parent
f82660b01e
commit
e07c77fbb7
4 changed files with 125 additions and 2 deletions
|
|
@ -1,8 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include "readline.h"
|
||||
#include "stringop.h"
|
||||
#include "list.h"
|
||||
#include "commands.h"
|
||||
#include "config.h"
|
||||
|
||||
struct sway_config *read_config(FILE *file) {
|
||||
|
|
@ -10,6 +12,8 @@ struct sway_config *read_config(FILE *file) {
|
|||
config->symbols = create_list();
|
||||
config->modes = create_list();
|
||||
|
||||
int temp_braces = 0; // Temporary: skip all config sections with braces
|
||||
|
||||
while (!feof(file)) {
|
||||
int _;
|
||||
char *line = read_line(file);
|
||||
|
|
@ -18,8 +22,17 @@ struct sway_config *read_config(FILE *file) {
|
|||
if (!line[0]) {
|
||||
goto _continue;
|
||||
}
|
||||
printf("Parsing config line %s\n", line);
|
||||
if (temp_braces && line[0] == '}') {
|
||||
temp_braces--;
|
||||
goto _continue;
|
||||
}
|
||||
|
||||
handle_command(config, line);
|
||||
|
||||
_continue:
|
||||
if (line && line[strlen(line) - 1] == '{') {
|
||||
temp_braces++;
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue