@@ -141,6 +141,23 @@ pub fn bar() -> Style {
141141 Style :: default ( )
142142}
143143
144+ /// Raised surface for the prompt composer.
145+ pub fn composer ( ) -> Style {
146+ composer_for ( crossterm:: style:: available_color_count ( ) )
147+ }
148+
149+ fn composer_for ( color_count : u16 ) -> Style {
150+ match color_count {
151+ u16:: MAX => Style :: default ( )
152+ . fg ( Color :: Rgb ( 0xf2 , 0xf2 , 0xf2 ) )
153+ . bg ( Color :: Rgb ( 0x32 , 0x36 , 0x3d ) ) ,
154+ colors if colors >= 256 => Style :: default ( )
155+ . fg ( Color :: Indexed ( 255 ) )
156+ . bg ( Color :: Indexed ( 238 ) ) ,
157+ _ => Style :: default ( ) . fg ( Color :: White ) . bg ( Color :: DarkGray ) ,
158+ }
159+ }
160+
144161pub fn selection ( ) -> Style {
145162 Style :: default ( ) . add_modifier ( Modifier :: REVERSED )
146163}
@@ -183,9 +200,12 @@ pub fn duration(millis: u64) -> String {
183200
184201#[ cfg( test) ]
185202mod tests {
186- use ratatui:: style:: { Color , Modifier } ;
203+ use ratatui:: style:: { Color , Modifier , Style } ;
187204
188- use super :: { BRAND_ANSI , BRAND_RGB , bar, brand_rainbow_for, code, duration, selection, text} ;
205+ use super :: {
206+ BRAND_ANSI , BRAND_RGB , bar, brand_rainbow_for, code, composer, composer_for, duration,
207+ selection, text,
208+ } ;
189209
190210 #[ test]
191211 fn formats_turn_durations_through_weeks ( ) {
@@ -215,6 +235,20 @@ mod tests {
215235 ) ;
216236 }
217237
238+ #[ test]
239+ fn composer_uses_a_contrasting_surface ( ) {
240+ assert ! ( composer( ) . fg. is_some( ) ) ;
241+ assert ! ( composer( ) . bg. is_some( ) ) ;
242+ assert_eq ! (
243+ composer_for( u16 :: MAX ) ,
244+ Style :: default ( )
245+ . fg( Color :: Rgb ( 0xf2 , 0xf2 , 0xf2 ) )
246+ . bg( Color :: Rgb ( 0x32 , 0x36 , 0x3d ) )
247+ ) ;
248+ assert_eq ! ( composer_for( 256 ) . bg, Some ( Color :: Indexed ( 238 ) ) ) ;
249+ assert_eq ! ( composer_for( 8 ) . bg, Some ( Color :: DarkGray ) ) ;
250+ }
251+
218252 #[ test]
219253 fn true_colour_uses_the_speakeasy_brand_ramp ( ) {
220254 assert_eq ! ( brand_rainbow_for( u16 :: MAX ) , & BRAND_RGB ) ;
0 commit comments