From: Michael Stapelberg Date: Fri, 12 Nov 2010 17:41:54 +0000 (+0100) Subject: lexer/parser: implement 'border' command X-Git-Tag: tree-pr1~129 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6eb7f2a01d881470148952d18d42073dc873d6a8;p=i3%2Fi3 lexer/parser: implement 'border' command --- diff --git a/include/data.h b/include/data.h index 3d32a396..ae499126 100644 --- a/include/data.h +++ b/include/data.h @@ -316,6 +316,7 @@ struct Con { enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode; enum { L_DEFAULT = 0, L_STACKED = 1, L_TABBED = 2 } layout; + enum { BS_NORMAL = 0, BS_NONE = 1, BS_1PIXEL = 3 } border_style; /** floating? (= not in tiling layout) This cannot be simply a bool * because we want to keep track of whether the status was set by the * application (by setting _NET_WM_WINDOW_TYPE appropriately) or by the diff --git a/src/cmdparse.l b/src/cmdparse.l index 3b3aefe2..9a236efc 100644 --- a/src/cmdparse.l +++ b/src/cmdparse.l @@ -91,6 +91,7 @@ stacked { return TOK_STACKED; } stacking { return TOK_STACKED; } tabbed { return TOK_TABBED; } border { return TOK_BORDER; } +normal { return TOK_NORMAL; } none { return TOK_NONE; } 1pixel { return TOK_1PIXEL; } mode { return TOK_MODE; } diff --git a/src/cmdparse.y b/src/cmdparse.y index 5dba6f59..a4ed00bb 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -109,6 +109,7 @@ char *parse_cmd(const char *new) { %token TOK_STACKED "stacked" %token TOK_TABBED "tabbed" %token TOK_BORDER "border" +%token TOK_NORMAL "normal" %token TOK_NONE "none" %token TOK_1PIXEL "1pixel" %token TOK_MODE "mode" @@ -284,8 +285,7 @@ operation: | exit | restart | reload - /* - | border */ + | border | layout | restore | move @@ -479,6 +479,31 @@ window_mode: | TOK_TOGGLE { $$ = TOK_TOGGLE; } ; +border: + TOK_BORDER WHITESPACE border_style + { + printf("border style should be changed to %d\n", $3); + owindow *current; + + /* check if the match is empty, not if the result is empty */ + if (match_is_empty(¤t_match)) + focused->border_style = $3; + else { + TAILQ_FOREACH(current, &owindows, owindows) { + printf("matching: %p / %s\n", current->con, current->con->name); + current->con->border_style = $3; + } + } + } + ; + +border_style: + TOK_NORMAL { $$ = BS_NORMAL; } + | TOK_NONE { $$ = BS_NONE; } + | TOK_1PIXEL { $$ = BS_1PIXEL; } + ; + + level: TOK_LEVEL WHITESPACE level_direction {