]> git.sur5r.net Git - i3/i3/blobdiff - src/cfgparse.y
Only resize when the left/right mouse button is used, not when scrolling (Thanks...
[i3/i3] / src / cfgparse.y
index 7a6a73984731e50901f8b2ff3b2fe9bfcf5e9169..7aeb0a7eb48eb6a37394680db480603b8081ce64 100644 (file)
@@ -51,7 +51,7 @@ void yyerror(const char *error_message) {
     ELOG("\n");
 }
 
-int yywrap() {
+int yywrap(void) {
     return 1;
 }
 
@@ -479,6 +479,8 @@ void parse_file(const char *f) {
                 v_value = strstr(value, "\t");
 
             *(v_value++) = '\0';
+            while (*v_value == '\t' || *v_value == ' ')
+                v_value++;
 
             struct Variable *new = scalloc(sizeof(struct Variable));
             new->key = sstrdup(v_key);
@@ -662,6 +664,8 @@ void parse_file(const char *f) {
 %token                  TOKCONTROL                  "control"
 %token                  TOKSHIFT                    "shift"
 %token                  TOKFLOATING_MODIFIER        "floating_modifier"
+%token                  TOKFLOATING_MAXIMUM_SIZE    "floating_maximum_size"
+%token                  TOKFLOATING_MINIMUM_SIZE    "floating_minimum_size"
 %token  <string>        QUOTEDSTRING                "<quoted string>"
 %token                  TOKWORKSPACE                "workspace"
 %token                  TOKOUTPUT                   "output"
@@ -706,10 +710,19 @@ void parse_file(const char *f) {
 %token                  TOK_BAR_MODE                "mode (bar)"
 %token                  TOK_BAR_HIDE                "hide"
 %token                  TOK_BAR_DOCK                "dock"
+%token                  TOK_BAR_MODIFIER            "modifier (bar)"
+%token                  TOK_BAR_CONTROL             "shift (bar)"
+%token                  TOK_BAR_SHIFT               "control (bar)"
+%token                  TOK_BAR_MOD1                "Mod1"
+%token                  TOK_BAR_MOD2                "Mod2"
+%token                  TOK_BAR_MOD3                "Mod3"
+%token                  TOK_BAR_MOD4                "Mod4"
+%token                  TOK_BAR_MOD5                "Mod5"
 %token                  TOK_BAR_POSITION            "position"
 %token                  TOK_BAR_BOTTOM              "bottom"
 %token                  TOK_BAR_TOP                 "top"
 %token                  TOK_BAR_STATUS_COMMAND      "status_command"
+%token                  TOK_BAR_I3BAR_COMMAND       "i3bar_command"
 %token                  TOK_BAR_FONT                "font (bar)"
 %token                  TOK_BAR_WORKSPACE_BUTTONS   "workspace_buttons"
 %token                  TOK_BAR_VERBOSE             "verbose"
@@ -729,6 +742,7 @@ void parse_file(const char *f) {
 %token              TOK_ID              "id"
 %token              TOK_CON_ID          "con_id"
 %token              TOK_TITLE           "title"
+%token              TOK_URGENT          "urgent"
 
 %type   <binding>       binding
 %type   <binding>       bindcode
@@ -745,6 +759,7 @@ void parse_file(const char *f) {
 %type   <number>        popup_setting
 %type   <number>        bar_position_position
 %type   <number>        bar_mode_mode
+%type   <number>        bar_modifier_modifier
 %type   <number>        optional_no_startup_id
 %type   <string>        command
 %type   <string>        word_or_number
@@ -765,6 +780,8 @@ line:
     | for_window
     | mode
     | bar
+    | floating_maximum_size
+    | floating_minimum_size
     | floating_modifier
     | orientation
     | workspace_layout
@@ -941,6 +958,20 @@ criterion:
         current_match.title = regex_new($3);
         free($3);
     }
+    | TOK_URGENT '=' STR
+    {
+        printf("criteria: urgent = %s\n", $3);
+        if (strcasecmp($3, "latest") == 0 ||
+            strcasecmp($3, "newest") == 0 ||
+            strcasecmp($3, "recent") == 0 ||
+            strcasecmp($3, "last") == 0) {
+            current_match.urgent = U_LATEST;
+        } else if (strcasecmp($3, "oldest") == 0 ||
+                   strcasecmp($3, "first") == 0) {
+            current_match.urgent = U_OLDEST;
+        }
+        free($3);
+    }
     ;
 
 qstring_or_number:
@@ -1034,10 +1065,12 @@ barlines:
 barline:
     comment
     | bar_status_command
+    | bar_i3bar_command
     | bar_output
     | bar_tray_output
     | bar_position
     | bar_mode
+    | bar_modifier
     | bar_font
     | bar_workspace_buttons
     | bar_verbose
@@ -1060,6 +1093,15 @@ bar_status_command:
     }
     ;
 
+bar_i3bar_command:
+    TOK_BAR_I3BAR_COMMAND STR
+    {
+        DLOG("should add i3bar_command %s\n", $2);
+        FREE(current_bar.i3bar_command);
+        current_bar.i3bar_command = $2;
+    }
+    ;
+
 bar_output:
     TOK_BAR_OUTPUT STR
     {
@@ -1106,6 +1148,23 @@ bar_mode_mode:
     | TOK_BAR_DOCK { $$ = M_DOCK; }
     ;
 
+bar_modifier:
+    TOK_BAR_MODIFIER bar_modifier_modifier
+    {
+        DLOG("modifier %d\n", $2);
+        current_bar.modifier = $2;
+    };
+
+bar_modifier_modifier:
+    TOK_BAR_CONTROL { $$ = M_CONTROL; }
+    | TOK_BAR_SHIFT { $$ = M_SHIFT; }
+    | TOK_BAR_MOD1  { $$ = M_MOD1; }
+    | TOK_BAR_MOD2  { $$ = M_MOD2; }
+    | TOK_BAR_MOD3  { $$ = M_MOD3; }
+    | TOK_BAR_MOD4  { $$ = M_MOD4; }
+    | TOK_BAR_MOD5  { $$ = M_MOD5; }
+    ;
+
 bar_font:
     TOK_BAR_FONT STR
     {
@@ -1170,36 +1229,90 @@ bar_color_statusline:
 bar_color_focused_workspace:
     TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR
     {
-        DLOG("focused_ws = %s and %s\n", $2, $3);
+        /* Old syntax: text / background */
+        DLOG("focused_ws = %s, %s (old)\n", $2, $3);
+        current_bar.colors.focused_workspace_bg = $3;
         current_bar.colors.focused_workspace_text = $2;
+    }
+    | TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
+    {
+        /* New syntax: border / background / text */
+        DLOG("focused_ws = %s, %s and %s\n", $2, $3, $4);
+        current_bar.colors.focused_workspace_border = $2;
         current_bar.colors.focused_workspace_bg = $3;
+        current_bar.colors.focused_workspace_text = $4;
     }
     ;
 
 bar_color_active_workspace:
     TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
     {
-        DLOG("active_ws = %s and %s\n", $2, $3);
+        /* Old syntax: text / background */
+        DLOG("active_ws = %s, %s (old)\n", $2, $3);
+        current_bar.colors.active_workspace_bg = $3;
         current_bar.colors.active_workspace_text = $2;
+    }
+    | TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
+    {
+        /* New syntax: border / background / text */
+        DLOG("active_ws = %s, %s and %s\n", $2, $3, $4);
+        current_bar.colors.active_workspace_border = $2;
         current_bar.colors.active_workspace_bg = $3;
+        current_bar.colors.active_workspace_text = $4;
     }
     ;
 
 bar_color_inactive_workspace:
     TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR
     {
-        DLOG("inactive_ws = %s and %s\n", $2, $3);
+        /* Old syntax: text / background */
+        DLOG("inactive_ws = %s, %s (old)\n", $2, $3);
+        current_bar.colors.inactive_workspace_bg = $3;
         current_bar.colors.inactive_workspace_text = $2;
+    }
+    | TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
+    {
+        DLOG("inactive_ws = %s, %s and %s\n", $2, $3, $4);
+        current_bar.colors.inactive_workspace_border = $2;
         current_bar.colors.inactive_workspace_bg = $3;
+        current_bar.colors.inactive_workspace_text = $4;
     }
     ;
 
 bar_color_urgent_workspace:
     TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR
     {
-        DLOG("urgent_ws = %s and %s\n", $2, $3);
+        /* Old syntax: text / background */
+        DLOG("urgent_ws = %s, %s (old)\n", $2, $3);
+        current_bar.colors.urgent_workspace_bg = $3;
         current_bar.colors.urgent_workspace_text = $2;
+    }
+    | TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR
+    {
+        DLOG("urgent_ws = %s, %s and %s\n", $2, $3, $4);
+        current_bar.colors.urgent_workspace_border = $2;
         current_bar.colors.urgent_workspace_bg = $3;
+        current_bar.colors.urgent_workspace_text = $4;
+    }
+    ;
+
+floating_maximum_size:
+    TOKFLOATING_MAXIMUM_SIZE NUMBER WORD NUMBER
+    {
+        printf("floating_maximum_width = %d\n", $2);
+        printf("floating_maximum_height = %d\n", $4);
+        config.floating_maximum_width = $2;
+        config.floating_maximum_height = $4;
+    }
+    ;
+
+floating_minimum_size:
+    TOKFLOATING_MINIMUM_SIZE NUMBER WORD NUMBER
+    {
+        printf("floating_minimum_width = %d\n", $2);
+        printf("floating_minimum_height = %d\n", $4);
+        config.floating_minimum_width = $2;
+        config.floating_minimum_height = $4;
     }
     ;
 
@@ -1551,6 +1664,7 @@ font:
     TOKFONT STR
     {
         config.font = load_font($2, true);
+        set_font(&config.font);
         printf("font %s\n", $2);
         FREE(font_pattern);
         font_pattern = $2;
@@ -1574,6 +1688,15 @@ color:
         dest->background = $3;
         dest->text = $4;
     }
+    | TOKCOLOR colorpixel colorpixel colorpixel colorpixel
+    {
+        struct Colortriple *dest = $1;
+
+        dest->border = $2;
+        dest->background = $3;
+        dest->text = $4;
+        dest->indicator = $5;
+    }
     ;
 
 colorpixel: