From 9bbb37bb55bab10d498765cd1d701cffff0ee158 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 10 Jun 2011 01:36:33 +0200 Subject: [PATCH] BREAKS CONFIG: rename 'level up' to 'focus parent' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …and 'level down' to 'focus child'. More intuitive than the old command names. --- docs/userguide | 6 ++--- i3.config | 7 ++++-- src/cmdparse.l | 3 ++- src/cmdparse.y | 37 ++++++++++++---------------- testcases/t/24-move.t | 2 +- testcases/t/29-focus-after-close.t | 4 +-- testcases/t/31-stacking-order.t | 4 +-- testcases/t/55-floating-split-size.t | 2 +- testcases/t/67-workspace_layout.t | 6 ++--- 9 files changed, 35 insertions(+), 36 deletions(-) diff --git a/docs/userguide b/docs/userguide index b7a8ff09..86319974 100644 --- a/docs/userguide +++ b/docs/userguide @@ -237,19 +237,19 @@ unfloat::[] You probably guessed it already: There is no limit on how deep your hierarchy of splits can be. -=== Level up +=== Focus parent Let’s stay with our example from above. We have a terminal on the left and two vertically split terminals on the right, focus is on the bottom right one. When you open a new terminal, it will open below the current one. So, how can you open a new terminal window to the *right* of the current one? -The solution is to use +level up+, which will focus the +Parent Container+ of +The solution is to use +focus parent+, which will focus the +Parent Container+ of the current +Container+. In this case, you would focus the +Vertical Split Container+ which is *inside* the horizontally oriented workspace. Thus, now new windows will be opened to the right of the +Vertical Split Container+: -image::tree-shot3.png["shot3",title="Level Up, then open new terminal"] +image::tree-shot3.png["shot3",title="Focus parent, then open new terminal"] == Configuring i3 diff --git a/i3.config b/i3.config index f726de8c..72399dfa 100644 --- a/i3.config +++ b/i3.config @@ -40,8 +40,11 @@ bindsym Mod1+l layout default # toggle tiling / floating bindsym Mod1+Shift+space mode toggle -bindsym Mod1+u level up -#bindsym Mod1+d level down +# focus the parent container +bindsym Mod1+u focus parent + +# focus the child container +#bindsym Mod1+d focus child # Kill current window bindsym Mod1+c kill diff --git a/src/cmdparse.l b/src/cmdparse.l index ba2789f2..545def7d 100644 --- a/src/cmdparse.l +++ b/src/cmdparse.l @@ -124,11 +124,12 @@ 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; } left { return TOK_LEFT; } right { return TOK_RIGHT; } +parent { return TOK_PARENT; } +child { return TOK_CHILD; } resize { return TOK_RESIZE; } shrink { return TOK_SHRINK; } grow { return TOK_GROW; } diff --git a/src/cmdparse.y b/src/cmdparse.y index c33a145b..8cf7858b 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -144,11 +144,12 @@ char *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_LEFT "left" %token TOK_RIGHT "right" +%token TOK_PARENT "parent" +%token TOK_CHILD "child" %token TOK_RESTORE "restore" %token TOK_MARK "mark" %token TOK_RESIZE "resize" @@ -168,7 +169,7 @@ char *parse_cmd(const char *new) { %token NUMBER "" %type direction -%type level_direction +%type level %type window_mode %type border_style %type layout_mode @@ -345,7 +346,6 @@ operation: | fullscreen | split | mode - | level | mark | resize | nop @@ -441,6 +441,19 @@ focus: tree_render(); } + | TOK_FOCUS level + { + if ($2 == TOK_PARENT) + level_up(); + else level_down(); + + tree_render(); + } + ; + +level: + TOK_PARENT { $$ = TOK_PARENT; } + | TOK_CHILD { $$ = TOK_CHILD; } ; kill: @@ -582,24 +595,6 @@ border_style: | TOK_1PIXEL { $$ = BS_1PIXEL; } ; - -level: - TOK_LEVEL level_direction - { - printf("level %c\n", $2); - if ($2 == 'u') - level_up(); - else level_down(); - - tree_render(); - } - ; - -level_direction: - TOK_UP { $$ = 'u'; } - | TOK_DOWN { $$ = 'd'; } - ; - move: TOK_MOVE direction { diff --git a/testcases/t/24-move.t b/testcases/t/24-move.t index 9d200aa9..b007d5b1 100644 --- a/testcases/t/24-move.t +++ b/testcases/t/24-move.t @@ -75,7 +75,7 @@ is($content->[0]->{id}, $first, 'first container unmodified'); # | | | | # -------------------------- cmd 'split v'; -cmd 'level up'; +cmd 'focus parent'; cmd 'open'; $content = get_ws_content($tmp); diff --git a/testcases/t/29-focus-after-close.t b/testcases/t/29-focus-after-close.t index dec9bb92..5f5ef4af 100644 --- a/testcases/t/29-focus-after-close.t +++ b/testcases/t/29-focus-after-close.t @@ -23,9 +23,9 @@ cmd 'split v'; my ($nodes, $focus) = get_ws_content($tmp); is($nodes->[1]->{focused}, 0, 'split container not focused'); -cmd 'level up'; +cmd 'focus parent'; ($nodes, $focus) = get_ws_content($tmp); -is($nodes->[1]->{focused}, 1, 'split container focused after level up'); +is($nodes->[1]->{focused}, 1, 'split container focused after focus parent'); my $third = open_empty_con($i3); diff --git a/testcases/t/31-stacking-order.t b/testcases/t/31-stacking-order.t index 4ffafa17..ea42596c 100644 --- a/testcases/t/31-stacking-order.t +++ b/testcases/t/31-stacking-order.t @@ -38,9 +38,9 @@ is(get_focused($tmp), $second, 'second container focused again'); # now change the orientation to horizontal and cycle ############################################################## -cmd 'level up'; +cmd 'focus parent'; cmd 'split h'; -cmd 'level down'; +cmd 'focus child'; cmd 'focus down'; is(get_focused($tmp), $first, 'first container focused'); diff --git a/testcases/t/55-floating-split-size.t b/testcases/t/55-floating-split-size.t index 61ceae3c..3ff1d8f3 100644 --- a/testcases/t/55-floating-split-size.t +++ b/testcases/t/55-floating-split-size.t @@ -48,7 +48,7 @@ sleep 0.25; # Set the parent to floating ##################################################################### cmd 'nop setting floating'; -cmd 'level up'; +cmd 'focus parent'; cmd 'mode floating'; ##################################################################### diff --git a/testcases/t/67-workspace_layout.t b/testcases/t/67-workspace_layout.t index 456e7316..46d0c274 100644 --- a/testcases/t/67-workspace_layout.t +++ b/testcases/t/67-workspace_layout.t @@ -79,16 +79,16 @@ ok(@content == 1, 'one con at workspace level'); is($content[0]->{layout}, 'stacked', 'layout stacked'); ##################################################################### -# 3: level up, open two new cons, check that they end up in a stacked +# 3: focus parent, open two new cons, check that they end up in a stacked # con ##################################################################### -cmd 'level up'; +cmd 'focus parent'; my $right_top = open_standard_window($x); my $right_bot = open_standard_window($x); @content = @{get_ws_content($tmp)}; -is(@content, 2, 'two cons at workspace level after level up'); +is(@content, 2, 'two cons at workspace level after focus parent'); is($content[0]->{layout}, 'stacked', 'layout stacked'); is($content[1]->{layout}, 'stacked', 'layout stacked');