]> git.sur5r.net Git - i3/i3/blobdiff - src/cfgparse.y
Merge branch 'next'
[i3/i3] / src / cfgparse.y
index bcd7d20c5e5c8964cab7cf830d405cf1b208e581..2a22aae4ef6bef8197ceb65121bff3dd43bb569b 100644 (file)
@@ -13,6 +13,8 @@
 
 #include "all.h"
 
+bool force_old_config_parser = false;
+
 static pid_t configerror_pid = -1;
 
 static Match current_match;
@@ -108,6 +110,7 @@ static int detect_version(char *buf) {
                 strncasecmp(bind, "focus down", strlen("focus down")) == 0 ||
                 strncasecmp(bind, "border normal", strlen("border normal")) == 0 ||
                 strncasecmp(bind, "border 1pixel", strlen("border 1pixel")) == 0 ||
+                strncasecmp(bind, "border pixel", strlen("border pixel")) == 0 ||
                 strncasecmp(bind, "border borderless", strlen("border borderless")) == 0 ||
                 strncasecmp(bind, "--no-startup-id", strlen("--no-startup-id")) == 0 ||
                 strncasecmp(bind, "bar", strlen("bar")) == 0) {
@@ -624,15 +627,20 @@ void parse_file(const char *f) {
         }
     }
 
-    /* now lex/parse it */
-    yy_scan_string(new);
 
     context = scalloc(sizeof(struct context));
     context->filename = f;
 
-    if (yyparse() != 0) {
-        fprintf(stderr, "Could not parse configfile\n");
-        exit(1);
+    if (force_old_config_parser) {
+        /* now lex/parse it */
+        yy_scan_string(new);
+        if (yyparse() != 0) {
+            fprintf(stderr, "Could not parse configfile\n");
+            exit(1);
+        }
+    } else {
+        struct ConfigResult *config_output = parse_config(new, context);
+        yajl_gen_free(config_output->json_gen);
     }
 
     check_for_duplicate_bindings(context);
@@ -668,7 +676,8 @@ void parse_file(const char *f) {
         start_configerror_nagbar(f);
     }
 
-    yylex_destroy();
+    if (force_old_config_parser)
+        yylex_destroy();
     FREE(context->line_copy);
     free(context);
     FREE(font_pattern);
@@ -739,6 +748,7 @@ void parse_file(const char *f) {
 %token                  TOKNEWFLOAT                 "new_float"
 %token                  TOK_NORMAL                  "normal"
 %token                  TOK_NONE                    "none"
+%token                  TOK_PIXEL                   "pixel"
 %token                  TOK_1PIXEL                  "1pixel"
 %token                  TOK_HIDE_EDGE_BORDERS       "hide_edge_borders"
 %token                  TOK_BOTH                    "both"
@@ -818,6 +828,7 @@ void parse_file(const char *f) {
 %type   <number>        bar_mode_mode
 %type   <number>        bar_modifier_modifier
 %type   <number>        optional_no_startup_id
+%type   <number>        optional_border_width
 %type   <number>        optional_release
 %type   <string>        command
 %type   <string>        word_or_number
@@ -1057,7 +1068,8 @@ word_or_number:
     ;
 
 duration:
-    NUMBER TOK_TIME_MS { sasprintf(&$$, "%d", $1); }
+    NUMBER { sasprintf(&$$, "%d", $1); }
+    | NUMBER TOK_TIME_MS { sasprintf(&$$, "%d", $1); }
     ;
 
 mode:
@@ -1479,9 +1491,27 @@ new_float:
     ;
 
 border_style:
-    TOK_NORMAL      { $$ = BS_NORMAL; }
-    | TOK_NONE      { $$ = BS_NONE; }
-    | TOK_1PIXEL    { $$ = BS_1PIXEL; }
+    TOK_NORMAL optional_border_width
+    {
+        /* FIXME: the whole border_style thing actually screws up when new_float is used because it overwrites earlier values :-/ */
+        config.default_border_width = $2;
+        $$ = BS_NORMAL;
+    }
+    | TOK_1PIXEL
+    {
+        config.default_border_width = 1;
+        $$ = BS_PIXEL;
+    }
+    | TOK_NONE
+    {
+        config.default_border_width = 0;
+        $$ = BS_NONE;
+    }
+    | TOK_PIXEL optional_border_width
+    {
+        config.default_border_width = $2;
+        $$ = BS_PIXEL;
+    }
     ;
 
 bool:
@@ -1752,6 +1782,11 @@ exec_always:
     }
     ;
 
+optional_border_width:
+    /* empty */ { $$ = 2; } // 2 pixels is the default value for any type of border
+    | NUMBER  { $$ = $1; }
+    ;
+
 optional_no_startup_id:
     /* empty */ { $$ = false; }
     | TOK_NO_STARTUP_ID  { $$ = true; }