From: Michael Stapelberg Date: Mon, 10 May 2010 08:12:35 +0000 (+0200) Subject: Implement exec, exit, level, restart (without testcases for now) X-Git-Tag: tree-pr1~221 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=98dbe63e35a6917020b149f8349c79da3306f07d;p=i3%2Fi3 Implement exec, exit, level, restart (without testcases for now) --- diff --git a/src/cmdparse.l b/src/cmdparse.l index 4a8e01fc..f96d5578 100644 --- a/src/cmdparse.l +++ b/src/cmdparse.l @@ -104,6 +104,9 @@ prev { return TOK_PREV; } split { return TOK_SPLIT; } horizontal { return TOK_HORIZONTAL; } vertical { return TOK_VERTICAL; } +level { return TOK_LEVEL; } +up { return TOK_UP; } +down { return TOK_DOWN; } class { BEGIN(WANT_QSTRING); return TOK_CLASS; } id { BEGIN(WANT_QSTRING); return TOK_ID; } diff --git a/src/cmdparse.y b/src/cmdparse.y index abb30ebe..f42bd072 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -87,6 +87,7 @@ void parse_cmd(const char *new) { %union { char *string; char chr; + int number; } %token TOK_ATTACH "attach" @@ -116,6 +117,9 @@ void parse_cmd(const char *new) { %token TOK_SPLIT "split" %token TOK_HORIZONTAL "horizontal" %token TOK_VERTICAL "vertical" +%token TOK_LEVEL "level" +%token TOK_UP "up" +%token TOK_DOWN "down" %token TOK_CLASS "class" %token TOK_ID "id" @@ -241,13 +245,11 @@ operations: operation: exec | exit - /*| reload | restart + /*| reload | mark | layout | border - | mode - | workspace | move*/ | workspace | attach @@ -258,12 +260,15 @@ operation: | next | prev | split + | mode + | level ; exec: TOK_EXEC WHITESPACE STR { printf("should execute %s\n", $3); + start_application($3); } ; @@ -271,6 +276,15 @@ exit: TOK_EXIT { printf("exit, bye bye\n"); + exit(0); + } + ; + +restart: + TOK_RESTART + { + printf("restarting i3\n"); + i3_restart(); } ; @@ -346,6 +360,7 @@ fullscreen: next: TOK_NEXT WHITESPACE direction { + /* TODO: use matches */ printf("should select next window in direction %c\n", $3); tree_next('n', ($3 == 'v' ? VERT : HORIZ)); } @@ -354,6 +369,7 @@ next: prev: TOK_PREV WHITESPACE direction { + /* TODO: use matches */ printf("should select prev window in direction %c\n", $3); tree_next('p', ($3 == 'v' ? VERT : HORIZ)); } @@ -362,6 +378,7 @@ prev: split: TOK_SPLIT WHITESPACE direction { + /* TODO: use matches */ printf("splitting in direction %c\n", $3); tree_split(focused, ($3 == 'v' ? VERT : HORIZ)); } @@ -373,3 +390,31 @@ direction: | TOK_VERTICAL { $$ = 'v'; } | 'v' { $$ = 'v'; } ; + +mode: + TOK_MODE WHITESPACE layout_mode + { + printf("should switch mode to %s\n", ($3 == TOK_FLOATING ? "floating" : "tiling")); + /* TODO: actually switch mode (not toggle) */ + } + ; + +layout_mode: + TOK_FLOATING { $$ = TOK_FLOATING; } + | TOK_TILING { $$ = TOK_TILING; } + ; + +level: + TOK_LEVEL WHITESPACE level_direction + { + printf("level %c\n", $3); + if ($3 == 'u') + level_up(); + else level_down(); + } + ; + +level_direction: + TOK_UP { $$ = 'u'; } + | TOK_DOWN { $$ = 'd'; } + ;