refactor tree_move() into src/move.c, change config (!), change testcase

Due to lots of cases which were added and added to tree_move(), the function
was not really easy to understand. For this refactoring, I wrote tree_move()
from scratch, thinking about (hopefully) all cases. The testsuite still passes.

The move command also has different parameters now. Instead of the hard to
understand 'before v' stuff, we use 'move [left|right|up|down]'.
This commit is contained in:
Michael Stapelberg
2011-02-14 23:05:20 +01:00
parent 28dd226259
commit 26a416e016
14 changed files with 302 additions and 250 deletions

View File

@ -134,8 +134,6 @@ char *parse_cmd(const char *new) {
%token TOK_DOWN "down"
%token TOK_LEFT "left"
%token TOK_RIGHT "right"
%token TOK_AFTER "after"
%token TOK_BEFORE "before"
%token TOK_RESTORE "restore"
%token TOK_MARK "mark"
%token TOK_RESIZE "resize"
@ -527,12 +525,10 @@ level_direction:
;
move:
TOK_MOVE WHITESPACE before_after WHITESPACE direction
TOK_MOVE 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));
printf("moving in direction %d\n", $<number>3);
tree_move($<number>3);
}
| TOK_MOVE WHITESPACE TOK_WORKSPACE WHITESPACE STR
{
@ -555,11 +551,6 @@ move:
}
;
before_after:
TOK_BEFORE { $<number>$ = TOK_BEFORE; }
| TOK_AFTER { $<number>$ = TOK_AFTER; }
;
restore:
TOK_RESTORE WHITESPACE STR
{