@@ -569,6 +569,56 @@ mod tests {
569569 assert_snapshot ! ( "scroll up page" , terminal. backend( ) ) ;
570570 }
571571
572+ #[ test]
573+ fn highlighting ( ) {
574+ let mut terminal = Terminal :: new ( TestBackend :: new ( 20 , 10 ) ) . unwrap ( ) ;
575+
576+ let mut widget = OutputWidget :: default ( ) ;
577+
578+ widget. handle_command_output ( Output :: ok_stdin ( & generate_lines ( 50 ) ) ) ;
579+ terminal
580+ . draw ( |frame| widget. render ( frame. area ( ) , frame. buffer_mut ( ) ) )
581+ . unwrap ( ) ;
582+ assert_snapshot ! ( "highlight base" , terminal. backend( ) ) ;
583+
584+ widget. highlight ( "line2" , false ) ;
585+ terminal
586+ . draw ( |frame| widget. render ( frame. area ( ) , frame. buffer_mut ( ) ) )
587+ . unwrap ( ) ;
588+ assert_snapshot ! ( "highlight" , terminal. backend( ) ) ;
589+
590+ widget. highlight_next ( ) ;
591+ widget. highlight_next ( ) ;
592+ widget. highlight_next ( ) ;
593+ widget. highlight_next ( ) ;
594+ terminal
595+ . draw ( |frame| widget. render ( frame. area ( ) , frame. buffer_mut ( ) ) )
596+ . unwrap ( ) ;
597+ assert_snapshot ! ( "highlight next 4x" , terminal. backend( ) ) ;
598+
599+ // in visible area - should not move offset
600+ widget. highlight_next ( ) ;
601+ terminal
602+ . draw ( |frame| widget. render ( frame. area ( ) , frame. buffer_mut ( ) ) )
603+ . unwrap ( ) ;
604+ assert_snapshot ! ( "highlight next 1x" , terminal. backend( ) ) ;
605+
606+ widget. highlight_prev ( ) ;
607+ widget. highlight_prev ( ) ;
608+ widget. highlight_prev ( ) ;
609+ widget. highlight_prev ( ) ;
610+ terminal
611+ . draw ( |frame| widget. render ( frame. area ( ) , frame. buffer_mut ( ) ) )
612+ . unwrap ( ) ;
613+ assert_snapshot ! ( "highlight prev 4x" , terminal. backend( ) ) ;
614+
615+ widget. highlight ( "line50" , false ) ;
616+ terminal
617+ . draw ( |frame| widget. render ( frame. area ( ) , frame. buffer_mut ( ) ) )
618+ . unwrap ( ) ;
619+ assert_snapshot ! ( "highlight another highlight" , terminal. backend( ) ) ;
620+ }
621+
572622 #[ test]
573623 fn split_line_into_parts_by_ranges_test ( ) {
574624 let str = "01234567890123456789" ;
0 commit comments