X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcfgparse.y;h=d706b4001b6157f2822fa3bd62ebabad87709065;hb=e101940c5edd3094463fea362fc21e924a46eca4;hp=15f0df8b8b302d03771e731878de6d853d214197;hpb=d916e075c3188b25e54a771f9bfcad9f84739ea4;p=i3%2Fi3 diff --git a/src/cfgparse.y b/src/cfgparse.y index 15f0df8b..d706b400 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -189,6 +189,9 @@ void parse_file(const char *f) { %token TOKCOLOR %token TOKARROW %token TOKMODE +%token TOKNEWCONTAINER +%token TOKCONTAINERMODE +%token TOKSTACKLIMIT %% @@ -201,6 +204,7 @@ line: bindline | mode | floating_modifier + | new_container | workspace | assign | ipcsocket @@ -222,7 +226,7 @@ command: bindline: binding { - TAILQ_INSERT_TAIL(&bindings, $1, bindings); + TAILQ_INSERT_TAIL(bindings, $1, bindings); } ; @@ -262,8 +266,23 @@ bindsym: mode: TOKMODE WHITESPACE QUOTEDSTRING WHITESPACE '{' modelines '}' { + if (strcasecmp($3, "default") == 0) { + printf("You cannot use the name \"default\" for your mode\n"); + exit(1); + } printf("\t now in mode %s\n", $3); printf("\t current bindings = %p\n", current_bindings); + Binding *binding; + TAILQ_FOREACH(binding, current_bindings, bindings) { + printf("got binding on mods %d, keycode %d, symbol %s, command %s\n", + binding->mods, binding->keycode, binding->symbol, binding->command); + } + + struct Mode *mode = scalloc(sizeof(struct Mode)); + mode->name = strdup($3); + mode->bindings = current_bindings; + current_bindings = NULL; + SLIST_INSERT_HEAD(&modes, mode, modes); } ; @@ -294,26 +313,66 @@ floating_modifier: } ; +new_container: + TOKNEWCONTAINER WHITESPACE TOKCONTAINERMODE + { + LOG("new containers will be in mode %d\n", $3); + config.container_mode = $3; + + /* We also need to change the layout of the already existing + * workspaces here. Workspaces may exist at this point because + * of the other directives which are modifying workspaces + * (setting the preferred screen or name). While the workspace + * objects are already created, they have never been used. + * Thus, the user very likely awaits the default container mode + * to trigger in this case, regardless of where it is inside + * his configuration file. */ + for (int c = 0; c < num_workspaces; c++) { + if (workspaces[c].table == NULL) + continue; + switch_layout_mode(global_conn, + workspaces[c].table[0][0], + config.container_mode); + } + } + | TOKNEWCONTAINER WHITESPACE TOKSTACKLIMIT WHITESPACE TOKSTACKLIMIT WHITESPACE NUMBER + { + LOG("stack-limit %d with val %d\n", $5, $7); + config.container_stack_limit = $5; + config.container_stack_limit_value = $7; + + /* See the comment above */ + for (int c = 0; c < num_workspaces; c++) { + if (workspaces[c].table == NULL) + continue; + Container *con = workspaces[c].table[0][0]; + con->stack_limit = config.container_stack_limit; + con->stack_limit_value = config.container_stack_limit_value; + } + } + ; + workspace: TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen workspace_name { int ws_num = $3; - if (ws_num < 1 || ws_num > 10) { + if (ws_num < 1) { LOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num); } else { - workspaces[ws_num - 1].preferred_screen = sstrdup($7); + Workspace *ws = workspace_get(ws_num - 1); + ws->preferred_screen = sstrdup($7); if ($8 != NULL) - workspace_set_name(&(workspaces[ws_num - 1]), $8); + workspace_set_name(ws, $8); } } | TOKWORKSPACE WHITESPACE NUMBER workspace_name { int ws_num = $3; - if (ws_num < 1 || ws_num > 10) { + if (ws_num < 1) { LOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num); } else { if ($4 != NULL) - workspace_set_name(&(workspaces[ws_num - 1]), $4); + workspace_set_name(workspace_get(ws_num - 1), $4); } } ;