]> git.sur5r.net Git - i3/i3/blob - src/config_directives.c
add first bits of a (custom) config parser
[i3/i3] / src / config_directives.c
1 #undef I3__FILE__
2 #define I3__FILE__ "config_directives.c"
3 /*
4  * vim:ts=4:sw=4:expandtab
5  *
6  * i3 - an improved dynamic tiling window manager
7  * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
8  *
9  * config_directives.c: all command functions (see config_parser.c)
10  *
11  */
12 #include <float.h>
13 #include <stdarg.h>
14
15 #include "all.h"
16
17 // Macros to make the YAJL API a bit easier to use.
18 #define y(x, ...) yajl_gen_ ## x (cmd_output->json_gen, ##__VA_ARGS__)
19 #define ystr(str) yajl_gen_string(cmd_output->json_gen, (unsigned char*)str, strlen(str))
20 #define ysuccess(success) do { \
21     y(map_open); \
22     ystr("success"); \
23     y(bool, success); \
24     y(map_close); \
25 } while (0)
26
27 static char *font_pattern;
28
29 void cfg_font(I3_CFG, const char *font) {
30         config.font = load_font(font, true);
31         set_font(&config.font);
32
33         /* Save the font pattern for using it as bar font later on */
34         FREE(font_pattern);
35         font_pattern = sstrdup(font);
36 }
37
38 void cfg_mode_binding(I3_CFG, const char *bindtype, const char *modifiers, const char *key, const char *command) {
39         printf("cfg_mode_binding: got bindtype\n");
40 }
41
42 void cfg_enter_mode(I3_CFG, const char *mode) {
43         // TODO: error handling: if mode == '{', the mode name is missing
44         printf("mode name: %s\n", mode);
45 }
46
47 void cfg_exec(I3_CFG, const char *exectype, const char *no_startup_id, const char *command) {
48         struct Autostart *new = smalloc(sizeof(struct Autostart));
49         new->command = sstrdup(command);
50         new->no_startup_id = (no_startup_id != NULL);
51         if (strcmp(exectype, "exec") == 0) {
52                 TAILQ_INSERT_TAIL(&autostarts, new, autostarts);
53         } else {
54                 TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
55         }
56 }