From bef25d72aa02066d087599c4b0ca313327979c98 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 10 Jun 2011 16:15:52 +0200 Subject: [PATCH] Implement 'border toggle' (+test) --- docs/userguide | 3 --- src/cmdparse.y | 6 ++++- testcases/t/69-border-toggle.t | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 testcases/t/69-border-toggle.t diff --git a/docs/userguide b/docs/userguide index 0046028a..0cdb2566 100644 --- a/docs/userguide +++ b/docs/userguide @@ -794,10 +794,7 @@ To change the border of the current client, you can use +border normal+ to use t border (including window title), +border 1pixel+ to use a 1-pixel border (no window title) and +border none+ to make the client borderless. -//////////////////////////////////////////////////////////////////////////// -TODO: not yet implemented There is also +border toggle+ which will toggle the different border styles. -//////////////////////////////////////////////////////////////////////////// *Examples*: ---------------------------- diff --git a/src/cmdparse.y b/src/cmdparse.y index 32683112..1c65fbc5 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -597,7 +597,10 @@ border: TAILQ_FOREACH(current, &owindows, owindows) { printf("matching: %p / %s\n", current->con, current->con->name); - current->con->border_style = $2; + if ($2 == TOK_TOGGLE) { + current->con->border_style++; + current->con->border_style %= 3; + } else current->con->border_style = $2; } tree_render(); @@ -608,6 +611,7 @@ border_style: TOK_NORMAL { $$ = BS_NORMAL; } | TOK_NONE { $$ = BS_NONE; } | TOK_1PIXEL { $$ = BS_1PIXEL; } + | TOK_TOGGLE { $$ = TOK_TOGGLE; } ; move: diff --git a/testcases/t/69-border-toggle.t b/testcases/t/69-border-toggle.t new file mode 100644 index 00000000..aec8df6c --- /dev/null +++ b/testcases/t/69-border-toggle.t @@ -0,0 +1,40 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Tests if the 'border toggle' command works correctly +# +use i3test; + +my $tmp = fresh_workspace; + +cmd 'open'; + +my @nodes = @{get_ws_content($tmp)}; +is(@nodes, 1, 'one container on this workspace'); +is($nodes[0]->{border}, 'normal', 'border style normal'); + +cmd 'border 1pixel'; +@nodes = @{get_ws_content($tmp)}; +is($nodes[0]->{border}, '1pixel', 'border style 1pixel'); + +cmd 'border none'; +@nodes = @{get_ws_content($tmp)}; +is($nodes[0]->{border}, 'none', 'border style none'); + +cmd 'border normal'; +@nodes = @{get_ws_content($tmp)}; +is($nodes[0]->{border}, 'normal', 'border style back to normal'); + +cmd 'border toggle'; +@nodes = @{get_ws_content($tmp)}; +is($nodes[0]->{border}, 'none', 'border style none'); + +cmd 'border toggle'; +@nodes = @{get_ws_content($tmp)}; +is($nodes[0]->{border}, '1pixel', 'border style 1pixel'); + +cmd 'border toggle'; +@nodes = @{get_ws_content($tmp)}; +is($nodes[0]->{border}, 'normal', 'border style back to normal'); + +done_testing; -- 2.39.5