Implement 'split'

This commit is contained in:
Michael Stapelberg
2010-05-10 09:33:10 +02:00
parent 145ebc7584
commit 6a1c34d2c5
7 changed files with 86 additions and 8 deletions

View File

@ -101,6 +101,7 @@ move { return TOK_MOVE; }
open { return TOK_OPEN; }
next { return TOK_NEXT; }
prev { return TOK_PREV; }
split { return TOK_SPLIT; }
horizontal { return TOK_HORIZONTAL; }
vertical { return TOK_VERTICAL; }

View File

@ -113,6 +113,7 @@ void parse_cmd(const char *new) {
%token TOK_OPEN "open"
%token TOK_NEXT "next"
%token TOK_PREV "prev"
%token TOK_SPLIT "split"
%token TOK_HORIZONTAL "horizontal"
%token TOK_VERTICAL "vertical"
@ -256,6 +257,7 @@ operation:
| fullscreen
| next
| prev
| split
;
exec:
@ -357,6 +359,14 @@ prev:
}
;
split:
TOK_SPLIT WHITESPACE direction
{
printf("splitting in direction %c\n", $<chr>3);
tree_split(focused, ($<chr>3 == 'v' ? VERT : HORIZ));
}
;
direction:
TOK_HORIZONTAL { $<chr>$ = 'h'; }
| 'h' { $<chr>$ = 'h'; }

View File

@ -167,6 +167,11 @@ void tree_close_con() {
*
*/
void tree_split(Con *con, orientation_t orientation) {
/* for a workspace, we just need to change orientation */
if (con->parent->type == CT_OUTPUT) {
con->orientation = orientation;
return;
}
/* 2: replace it with a new Con */
Con *new = con_new(NULL);
Con *parent = con->parent;