Bugfix: properly handle comments in colors {} blocks of bar config (+test) (Thanks fernandotcl)

This commit is contained in:
Michael Stapelberg 2011-10-25 22:31:57 +01:00
parent 704c9967b2
commit e710477a07
2 changed files with 36 additions and 0 deletions

View File

@ -106,6 +106,7 @@ EOL (\r?\n)
<BAR>colors { yy_push_state(BAR_COLORS); return TOK_BAR_COLORS; } <BAR>colors { yy_push_state(BAR_COLORS); return TOK_BAR_COLORS; }
<BAR_COLORS>"{" { return '{'; } <BAR_COLORS>"{" { return '{'; }
<BAR_COLORS>"}" { yy_pop_state(); return '}'; } <BAR_COLORS>"}" { yy_pop_state(); return '}'; }
<BAR_COLORS>^[ \t]*#[^\n]* { return TOKCOMMENT; }
<BAR_COLORS>background { yy_push_state(BAR_COLOR); return TOK_BAR_COLOR_BACKGROUND; } <BAR_COLORS>background { yy_push_state(BAR_COLOR); return TOK_BAR_COLOR_BACKGROUND; }
<BAR_COLORS>statusline { yy_push_state(BAR_COLOR); return TOK_BAR_COLOR_STATUSLINE; } <BAR_COLORS>statusline { yy_push_state(BAR_COLOR); return TOK_BAR_COLOR_STATUSLINE; }
<BAR_COLORS>focused_workspace { BAR_DOUBLE_COLOR; return TOK_BAR_COLOR_FOCUSED_WORKSPACE; } <BAR_COLORS>focused_workspace { BAR_DOUBLE_COLOR; return TOK_BAR_COLOR_FOCUSED_WORKSPACE; }

View File

@ -170,4 +170,39 @@ isnt($bar1_config->{outputs}, $bar2_config->{outputs}, 'outputs different');
exit_gracefully($pid); exit_gracefully($pid);
#####################################################################
# make sure comments work properly
#####################################################################
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
bar {
# Start a default instance of i3bar which provides workspace buttons.
# Additionally, i3status will provide a statusline.
status_command i3status --bar
#status_command i3status --qux
#status_command i3status --qux
output HDMI1
colors {
background #000000
#background #ffffff
}
}
EOT
$pid = launch_with_config($config);
$i3 = i3(get_socket_path(0));
$bars = $i3->get_bar_config()->recv;
$bar_id = shift @$bars;
$bar_config = $i3->get_bar_config($bar_id)->recv;
is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
is($bar_config->{colors}->{background}, '#000000', 'background color ok');
exit_gracefully($pid);
done_testing; done_testing;