diff --git a/src/cfgparse.l b/src/cfgparse.l index 6dfec224..2ba81d33 100644 --- a/src/cfgparse.l +++ b/src/cfgparse.l @@ -128,6 +128,12 @@ EOL (\r?\n) inactive_workspace { BAR_TRIPLE_COLOR; return TOK_BAR_COLOR_INACTIVE_WORKSPACE; } urgent_workspace { BAR_TRIPLE_COLOR; return TOK_BAR_COLOR_URGENT_WORKSPACE; } #[0-9a-fA-F]+ { yy_pop_state(); yylval.string = sstrdup(yytext); return HEXCOLOR; } +{EOL} { + yy_pop_state(); + FREE(context->line_copy); + context->line_number++; + yy_push_state(BUFFER_LINE); + } [a-zA-Z]+ { yylval.string = sstrdup(yytext); return WORD; } diff --git a/src/cfgparse.y b/src/cfgparse.y index 2edc7698..d245db3f 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -1208,8 +1208,16 @@ bar_color_statusline: ; bar_color_focused_workspace: - TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR + TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR { + /* Old syntax: text / background */ + DLOG("focused_ws = %s, %s (old)\n", $2, $3); + current_bar.colors.focused_workspace_bg = $3; + current_bar.colors.focused_workspace_text = $2; + } + | TOK_BAR_COLOR_FOCUSED_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR + { + /* New syntax: border / background / text */ DLOG("focused_ws = %s, %s and %s\n", $2, $3, $4); current_bar.colors.focused_workspace_border = $2; current_bar.colors.focused_workspace_bg = $3; @@ -1218,8 +1226,16 @@ bar_color_focused_workspace: ; bar_color_active_workspace: - TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR + TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR { + /* Old syntax: text / background */ + DLOG("active_ws = %s, %s (old)\n", $2, $3); + current_bar.colors.active_workspace_bg = $3; + current_bar.colors.active_workspace_text = $2; + } + | TOK_BAR_COLOR_ACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR + { + /* New syntax: border / background / text */ DLOG("active_ws = %s, %s and %s\n", $2, $3, $4); current_bar.colors.active_workspace_border = $2; current_bar.colors.active_workspace_bg = $3; @@ -1228,7 +1244,14 @@ bar_color_active_workspace: ; bar_color_inactive_workspace: - TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR + TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR + { + /* Old syntax: text / background */ + DLOG("inactive_ws = %s, %s (old)\n", $2, $3); + current_bar.colors.inactive_workspace_bg = $3; + current_bar.colors.inactive_workspace_text = $2; + } + | TOK_BAR_COLOR_INACTIVE_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR { DLOG("inactive_ws = %s, %s and %s\n", $2, $3, $4); current_bar.colors.inactive_workspace_border = $2; @@ -1238,7 +1261,14 @@ bar_color_inactive_workspace: ; bar_color_urgent_workspace: - TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR + TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR + { + /* Old syntax: text / background */ + DLOG("urgent_ws = %s, %s (old)\n", $2, $3); + current_bar.colors.urgent_workspace_bg = $3; + current_bar.colors.urgent_workspace_text = $2; + } + | TOK_BAR_COLOR_URGENT_WORKSPACE HEXCOLOR HEXCOLOR HEXCOLOR { DLOG("urgent_ws = %s, %s and %s\n", $2, $3, $4); current_bar.colors.urgent_workspace_border = $2; diff --git a/testcases/t/177-bar-config.t b/testcases/t/177-bar-config.t index eb92c751..3caa6696 100644 --- a/testcases/t/177-bar-config.t +++ b/testcases/t/177-bar-config.t @@ -208,4 +208,77 @@ is($bar_config->{colors}->{background}, '#000000', 'background color ok'); exit_gracefully($pid); +##################################################################### +# verify that the old syntax still works +##################################################################### + +$config = <get_bar_config()->recv; +is(@$bars, 1, 'one bar configured'); + +$bar_id = shift @$bars; + +cmd 'nop yeah'; +$bar_config = $i3->get_bar_config($bar_id)->recv; +is($bar_config->{status_command}, 'i3status --bar', 'status_command correct'); +ok($bar_config->{verbose}, 'verbose on'); +ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled'); +is($bar_config->{mode}, 'dock', 'dock mode'); +is($bar_config->{position}, 'top', 'position top'); +is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok'); +is($bar_config->{tray_output}, 'HDMI2', 'tray_output ok'); +is($bar_config->{font}, 'Terminus', 'font ok'); +is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok'); +is_deeply($bar_config->{colors}, + { + background => '#ff0000', + statusline => '#00ff00', + focused_workspace_text => '#ffffff', + focused_workspace_bg => '#285577', + active_workspace_text => '#888888', + active_workspace_bg => '#222222', + inactive_workspace_text => '#888888', + inactive_workspace_bg => '#222222', + urgent_workspace_text => '#ffffff', + urgent_workspace_bg => '#900000', + }, '(old) colors ok'); + +exit_gracefully($pid); + + done_testing;