From: Michael Stapelberg Date: Sun, 13 Sep 2009 20:13:28 +0000 (+0200) Subject: Implement most code to actually set the configuration settings X-Git-Tag: 3.d~90^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=207ad0a7dfdd51ec364e14275aeded14fabfe800;p=i3%2Fi3 Implement most code to actually set the configuration settings --- diff --git a/src/cfgparse.y b/src/cfgparse.y index 59ecd977..f3c552f9 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -11,8 +11,10 @@ #include "data.h" #include "config.h" +#include "i3.h" #include "util.h" #include "queue.h" +#include "table.h" extern int yylex(void); extern FILE *yyin; @@ -210,6 +212,13 @@ bind: TOKBIND WHITESPACE binding_modifiers NUMBER WHITESPACE command { printf("\tFound binding mod%d with key %d and command %s\n", $3, $4, $6); + Binding *new = scalloc(sizeof(Binding)); + + new->keycode = $4; + new->mods = $3; + new->command = sstrdup($6); + + TAILQ_INSERT_TAIL(&bindings, new, bindings); } ; @@ -217,30 +226,42 @@ bindsym: TOKBINDSYM WHITESPACE binding_modifiers WORD WHITESPACE command { printf("\tFound symbolic mod%d with key %s and command %s\n", $3, $4, $6); + Binding *new = scalloc(sizeof(Binding)); + + new->symbol = sstrdup($4); + new->mods = $3; + new->command = sstrdup($6); + + TAILQ_INSERT_TAIL(&bindings, new, bindings); } ; floating_modifier: TOKFLOATING_MODIFIER WHITESPACE binding_modifiers { - printf("\tfloating modifier %d\n", $3); + LOG("floating modifier = %d\n", $3); + config.floating_modifier = $3; } ; workspace: - TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen - { - printf("\t workspace %d to screen %s\n", $3, $7); - } - | TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen WHITESPACE workspace_name + TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen workspace_name { - printf("\t quoted: %s\n", $9); + int ws_num = $3; + if (ws_num < 1 || ws_num > 10) { + LOG("Invalid workspace assignment, workspace number %d out of range\n", ws_num); + } else { + workspaces[ws_num - 1].preferred_screen = sstrdup($7); + if ($8 != NULL) + workspace_set_name(&(workspaces[ws_num - 1]), $8); + } } ; workspace_name: - QUOTEDSTRING - | STR + /* NULL */ { $$ = NULL; } + | WHITESPACE QUOTEDSTRING { $$ = $2; } + | WHITESPACE STR { $$ = $2; } ; screen: @@ -253,6 +274,7 @@ screen: assign: TOKASSIGN WHITESPACE window_class WHITESPACE optional_arrow NUMBER { + /* TODO */ printf("assignment of %s to %d\n", $3, $6); } ; @@ -270,39 +292,51 @@ optional_arrow: ipcsocket: TOKIPCSOCKET WHITESPACE STR { - printf("ipc %s\n", $3); + config.ipc_socket_path = sstrdup($3); } ; exec: TOKEXEC WHITESPACE STR { - printf("exec %s\n", $3); + struct Autostart *new = smalloc(sizeof(struct Autostart)); + new->command = sstrdup($3); + TAILQ_INSERT_TAIL(&autostarts, new, autostarts); } ; terminal: TOKTERMINAL WHITESPACE STR { - printf("terminal %s\n", $3); + config.terminal = sstrdup($3); + printf("terminal %s\n", config.terminal); } ; font: TOKFONT WHITESPACE STR { - printf("font %s\n", $3); + config.font = sstrdup($3); + printf("font %s\n", config.font); } ; color: - TOKCOLOR WHITESPACE '#' HEX WHITESPACE '#' HEX WHITESPACE '#' HEX + TOKCOLOR WHITESPACE colorpixel WHITESPACE colorpixel WHITESPACE colorpixel { - printf("color %p, %s and %s and %s\n", $1, $4, $7, $10); + struct Colortriple *dest = $1; + + dest->border = $3; + dest->background = $5; + dest->text = $7; } ; +colorpixel: + '#' HEX { $$ = get_colorpixel(global_conn, $2); } + ; + binding_modifiers: /* NULL */ { $$ = 0; }