From a0e33c1d683ffe3b67a3967980f61f828b41fef2 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 11 May 2010 22:46:49 +0200 Subject: [PATCH] implement 'move' command in the new parser --- src/cmdparse.l | 2 ++ src/cmdparse.y | 21 +++++++++++++++++++-- src/tree.c | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/cmdparse.l b/src/cmdparse.l index f96d5578..104926dc 100644 --- a/src/cmdparse.l +++ b/src/cmdparse.l @@ -107,6 +107,8 @@ vertical { return TOK_VERTICAL; } level { return TOK_LEVEL; } up { return TOK_UP; } down { return TOK_DOWN; } +before { return TOK_BEFORE; } +after { return TOK_AFTER; } 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 f42bd072..016f19e2 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -120,6 +120,8 @@ void parse_cmd(const char *new) { %token TOK_LEVEL "level" %token TOK_UP "up" %token TOK_DOWN "down" +%token TOK_AFTER "after" +%token TOK_BEFORE "before" %token TOK_CLASS "class" %token TOK_ID "id" @@ -249,8 +251,8 @@ operation: /*| reload | mark | layout - | border - | move*/ + | border */ + | move | workspace | attach | focus @@ -418,3 +420,18 @@ level_direction: TOK_UP { $$ = 'u'; } | TOK_DOWN { $$ = 'd'; } ; + +move: + TOK_MOVE WHITESPACE before_after WHITESPACE direction + { + printf("moving: %s and %c\n", ($3 == TOK_BEFORE ? "before" : "after"), $5); + /* TODO: change API for the next call, we need to convert in both directions while ideally + * we should not need any of both */ + tree_move(($3 == TOK_BEFORE ? 'p' : 'n'), ($5 == 'v' ? VERT : HORIZ)); + } + ; + +before_after: + TOK_BEFORE { $$ = TOK_BEFORE; } + | TOK_AFTER { $$ = TOK_AFTER; } + ; diff --git a/src/tree.c b/src/tree.c index 72e8645c..8a3bdf2d 100644 --- a/src/tree.c +++ b/src/tree.c @@ -271,6 +271,8 @@ void tree_next(char way, orientation_t orientation) { void tree_move(char way, orientation_t orientation) { /* 1: get the first parent with the same orientation */ Con *parent = focused->parent; + if (parent->type == CT_OUTPUT) + return; bool level_changed = false; while (parent->orientation != orientation) { LOG("need to go one level further up\n"); -- 2.39.5