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; }
%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"
/*| reload
| mark
| layout
- | border
- | move*/
+ | border */
+ | move
| workspace
| attach
| focus
TOK_UP { $<chr>$ = 'u'; }
| TOK_DOWN { $<chr>$ = 'd'; }
;
+
+move:
+ TOK_MOVE WHITESPACE before_after WHITESPACE direction
+ {
+ printf("moving: %s and %c\n", ($<number>3 == TOK_BEFORE ? "before" : "after"), $<chr>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(($<number>3 == TOK_BEFORE ? 'p' : 'n'), ($<chr>5 == 'v' ? VERT : HORIZ));
+ }
+ ;
+
+before_after:
+ TOK_BEFORE { $<number>$ = TOK_BEFORE; }
+ | TOK_AFTER { $<number>$ = TOK_AFTER; }
+ ;
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");