@@ -158,7 +158,10 @@ impl QuestionPromptView<'_> {
158158 // The active tab is the focused selection: banner green on the gray bar,
159159 // never inverted onto the accent. Answered tabs read white.
160160 let ( fg, bg) = if is_active {
161- ( colors. accent , cortex_core:: style:: TEXT )
161+ (
162+ colors. accent ,
163+ crate :: ui:: colors:: focus_background ( colors. accent ) ,
164+ )
162165 } else if is_hovered {
163166 ( colors. text , colors. user_bg )
164167 } else {
@@ -193,7 +196,10 @@ impl QuestionPromptView<'_> {
193196 let is_hovered = self . hovered_tab == Some ( self . state . request . questions . len ( ) ) ;
194197
195198 let ( fg, bg) = if is_active {
196- ( colors. accent , cortex_core:: style:: TEXT )
199+ (
200+ colors. accent ,
201+ crate :: ui:: colors:: focus_background ( colors. accent ) ,
202+ )
197203 } else if is_hovered {
198204 ( colors. text , colors. user_bg )
199205 } else {
@@ -267,7 +273,10 @@ impl QuestionPromptView<'_> {
267273 // Focused option: banner green on the gray selection bar; a picked option
268274 // stays white — its `✓` carries the green.
269275 let ( fg, bg) = if is_selected {
270- ( colors. accent , cortex_core:: style:: TEXT )
276+ (
277+ colors. accent ,
278+ crate :: ui:: colors:: focus_background ( colors. accent ) ,
279+ )
271280 } else if is_hovered {
272281 ( colors. text , colors. user_bg )
273282 } else {
@@ -330,7 +339,10 @@ impl QuestionPromptView<'_> {
330339 let label = "Type your own answer" ;
331340
332341 let ( fg, bg) = if is_selected {
333- ( colors. accent , cortex_core:: style:: TEXT )
342+ (
343+ colors. accent ,
344+ crate :: ui:: colors:: focus_background ( colors. accent ) ,
345+ )
334346 } else if is_hovered {
335347 ( colors. text , colors. user_bg )
336348 } else {
@@ -687,4 +699,60 @@ mod tests {
687699 . expect ( "title" ) ;
688700 assert_eq ! ( buf[ ( title_x, title_y) ] . style( ) . fg, Some ( TEXT ) ) ;
689701 }
702+ #[ test]
703+ fn focus_tabs_and_options_are_accessible_in_every_builtin_theme ( ) {
704+ for name in AdaptiveColors :: available_themes ( ) {
705+ let colors = AdaptiveColors :: from_theme_name ( name) ;
706+ let expected_bg = match * name {
707+ "ocean_dark" | "monokai" => Color :: Black ,
708+ _ => TEXT ,
709+ } ;
710+ for width in [ 40 , 120 ] {
711+ let mut req = request ( ) ;
712+ req. questions [ 0 ] . allow_custom = true ;
713+ req. questions [ 0 ] . question = "Home" . into ( ) ;
714+ req. questions . push ( req. questions [ 0 ] . clone ( ) ) ;
715+ let mut state = QuestionState :: new ( req) ;
716+ for confirm in [ false , true ] {
717+ state. on_confirm_tab = confirm;
718+ let view = QuestionPromptView :: new ( & state) . with_colors ( colors. clone ( ) ) ;
719+ let area = Rect :: new ( 0 , 0 , width, 12 ) ;
720+ let mut buf = Buffer :: empty ( area) ;
721+ view. render_tabs ( & Rect :: new ( 0 , 0 , width, 1 ) , & mut buf, & colors) ;
722+ let label = if confirm {
723+ "Confirm" . to_string ( )
724+ } else {
725+ state. get_header ( 0 )
726+ } ;
727+ let row: String = ( 0 ..width) . map ( |x| buf[ ( x, 0 ) ] . symbol ( ) ) . collect ( ) ;
728+ let start = row. find ( & label) . expect ( "active tab label" ) as u16 ;
729+ for x in start..start + label. chars ( ) . count ( ) as u16 {
730+ assert_eq ! ( buf[ ( x, 0 ) ] . fg, colors. accent, "{name}: {label}" ) ;
731+ assert_eq ! ( buf[ ( x, 0 ) ] . bg, expected_bg, "{name}: {label}" ) ;
732+ }
733+ }
734+ state. on_confirm_tab = false ;
735+ for selected in [ 0 , 2 ] {
736+ state. selected_index [ 0 ] = selected;
737+ let view = QuestionPromptView :: new ( & state) . with_colors ( colors. clone ( ) ) ;
738+ let mut buf = Buffer :: empty ( Rect :: new ( 0 , 0 , width, 12 ) ) ;
739+ view. render_question (
740+ & Rect :: new ( 0 , 0 , width, 1 ) ,
741+ & Rect :: new ( 0 , 2 , width, 10 ) ,
742+ & mut buf,
743+ & colors,
744+ ) ;
745+ let focused: Vec < _ > = buf
746+ . content
747+ . iter ( )
748+ . filter ( |cell| cell. fg == colors. accent && cell. symbol ( ) != " " )
749+ . collect ( ) ;
750+ assert ! ( !focused. is_empty( ) , "{name}: option {selected}" ) ;
751+ for cell in focused {
752+ assert_eq ! ( cell. bg, expected_bg, "{name}: option {selected}" ) ;
753+ }
754+ }
755+ }
756+ }
757+ }
690758}
0 commit comments