@@ -2,7 +2,7 @@ use super::*;
22use crate :: face:: { Face , FaceAttributes , UnderlineStyle } ;
33use crate :: frame_glyphs:: { CursorStyle , DisplaySlotId , GlyphRowRole , PhysCursor } ;
44use crate :: glyph_matrix:: {
5- FrameDisplayState , Glyph , GlyphArea , GlyphMatrix , GlyphRow , WindowMatrixEntry ,
5+ FaceFillItem , FrameDisplayState , Glyph , GlyphArea , GlyphMatrix , GlyphRow , WindowMatrixEntry ,
66} ;
77use crate :: types:: { Color , DisplayFrameId , DisplayWindowId , Rect } ;
88use std:: collections:: HashMap ;
@@ -304,6 +304,48 @@ fn rasterize_respects_matrix_position() {
304304 assert_eq ! ( rif. desired. cells[ 0 ] . ch, ' ' ) ;
305305}
306306
307+ #[ test]
308+ fn rasterize_face_fill_paints_blank_cells_before_glyphs ( ) {
309+ let mut state = FrameDisplayState :: new ( 8 , 2 , 1.0 , 1.0 ) ;
310+ state. background = Color :: from_pixel ( 0x000000 ) ;
311+ let mut fill_face = Face :: new ( 7 ) ;
312+ fill_face. background = Color :: from_pixel ( 0x112233 ) ;
313+ let mut glyph_face = Face :: new ( 8 ) ;
314+ glyph_face. background = Color :: from_pixel ( 0x445566 ) ;
315+ state. faces . insert ( 7 , fill_face) ;
316+ state. faces . insert ( 8 , glyph_face) ;
317+ state. face_fills . push ( FaceFillItem {
318+ window_id : DisplayWindowId :: new ( 1 ) ,
319+ row_role : GlyphRowRole :: Text ,
320+ clip_rect : Some ( Rect :: new ( 0.0 , 0.0 , 8.0 , 2.0 ) ) ,
321+ bounds : Rect :: new ( 0.0 , 0.0 , 8.0 , 1.0 ) ,
322+ face_id : 7 ,
323+ } ) ;
324+
325+ let mut matrix = GlyphMatrix :: new ( 1 , 6 ) ;
326+ let mut row = GlyphRow :: new ( GlyphRowRole :: Text ) ;
327+ row. glyphs [ GlyphArea :: Text as usize ] . push ( Glyph :: char ( 'X' , 8 , 0 ) ) ;
328+ matrix. rows [ 0 ] = row;
329+ state. window_matrices . push ( WindowMatrixEntry {
330+ window_id : 1 ,
331+ matrix,
332+ pixel_bounds : Rect :: new ( 0.0 , 0.0 , 8.0 , 1.0 ) ,
333+ text_pixel_bounds : Rect :: new ( 2.0 , 0.0 , 6.0 , 1.0 ) ,
334+ selected : true ,
335+ } ) ;
336+
337+ let mut rif = TtyRif :: new ( 8 , 2 ) ;
338+ rif. rasterize ( & state) ;
339+
340+ assert_eq ! ( rif. desired. cells[ 0 ] . ch, ' ' ) ;
341+ assert_eq ! ( rif. desired. cells[ 0 ] . attrs. bg, Some ( ( 0x11 , 0x22 , 0x33 ) ) ) ;
342+ assert_eq ! ( rif. desired. cells[ 1 ] . attrs. bg, Some ( ( 0x11 , 0x22 , 0x33 ) ) ) ;
343+ assert_eq ! ( rif. desired. cells[ 2 ] . ch, 'X' ) ;
344+ assert_eq ! ( rif. desired. cells[ 2 ] . attrs. bg, Some ( ( 0x44 , 0x55 , 0x66 ) ) ) ;
345+ assert_eq ! ( rif. desired. cells[ 7 ] . attrs. bg, Some ( ( 0x11 , 0x22 , 0x33 ) ) ) ;
346+ assert_eq ! ( rif. desired. cells[ 8 ] . attrs. bg, Some ( ( 0 , 0 , 0 ) ) ) ;
347+ }
348+
307349#[ test]
308350fn rasterize_uses_grid_rows_not_pixel_row_metrics ( ) {
309351 let mut state = FrameDisplayState :: new ( 12 , 5 , 1.0 , 1.0 ) ;
0 commit comments