@@ -28,7 +28,6 @@ pub struct LineFragment {
28
28
pub struct ViewportMargins {
29
29
pub top : u64 ,
30
30
pub bottom : u64 ,
31
- pub inferred : bool ,
32
31
}
33
32
34
33
#[ derive( Clone , Debug , PartialEq ) ]
@@ -71,7 +70,6 @@ struct Line {
71
70
line_fragments : Vec < LineFragment > ,
72
71
background_picture : Option < Picture > ,
73
72
foreground_picture : Option < Picture > ,
74
- is_inferred_border : bool ,
75
73
blend : u8 ,
76
74
is_valid : bool ,
77
75
}
@@ -141,11 +139,7 @@ impl RenderedWindow {
141
139
actual_lines : RingBuffer :: new ( grid_size. height as usize , None ) ,
142
140
scrollback_lines : RingBuffer :: new ( 2 * grid_size. height as usize , None ) ,
143
141
scroll_delta : 0 ,
144
- viewport_margins : ViewportMargins {
145
- top : 0 ,
146
- bottom : 0 ,
147
- inferred : true ,
148
- } ,
142
+ viewport_margins : ViewportMargins { top : 0 , bottom : 0 } ,
149
143
150
144
grid_start_position : grid_position. cast ( ) ,
151
145
grid_current_position : grid_position. cast ( ) ,
@@ -455,47 +449,14 @@ impl RenderedWindow {
455
449
} => {
456
450
tracy_zone ! ( "draw_line_cmd" , 0 ) ;
457
451
458
- let mut line = Line {
452
+ let line = Line {
459
453
line_fragments,
460
454
background_picture : None ,
461
455
foreground_picture : None ,
462
- is_inferred_border : false ,
463
456
blend : 0 ,
464
457
is_valid : false ,
465
458
} ;
466
459
467
- if self . viewport_margins . inferred {
468
- let check_border = |fragment : & LineFragment , check : & dyn Fn ( & str ) -> bool | {
469
- fragment. style . as_ref ( ) . map_or ( false , |style| {
470
- style. infos . last ( ) . map_or ( false , |info| {
471
- // The specification seems to indicate that kind should be UI and
472
- // then we only need to test ui_name. But at least for FloatTitle,
473
- // that is not the case, the kind is set to syntax and hi_name is
474
- // set.
475
- check ( & info. ui_name ) || check ( & info. hi_name )
476
- } )
477
- } )
478
- } ;
479
-
480
- let float_border =
481
- |s : & str | matches ! ( s, "FloatBorder" | "FloatTitle" | "FloatFooter" ) ;
482
- let winbar = |s : & str | matches ! ( s, "WinBar" | "WinBarNC" ) ;
483
-
484
- // Lines with purly border highlight groups are considered borders.
485
- line. is_inferred_border = line
486
- . line_fragments
487
- . iter ( )
488
- . map ( |fragment| check_border ( fragment, & float_border) )
489
- . all ( |v| v) ;
490
-
491
- // And also lines with a winbar highlight anywhere
492
- line. is_inferred_border |= line
493
- . line_fragments
494
- . iter ( )
495
- . map ( |fragment| check_border ( fragment, & winbar) )
496
- . any ( |v| v)
497
- }
498
-
499
460
self . actual_lines [ row] = Some ( Rc :: new ( RefCell :: new ( line) ) ) ;
500
461
}
501
462
WindowDrawCommand :: Scroll {
@@ -543,47 +504,13 @@ impl RenderedWindow {
543
504
self . scroll_delta = scroll_delta. round ( ) as isize ;
544
505
}
545
506
WindowDrawCommand :: ViewportMargins { top, bottom, .. } => {
546
- self . viewport_margins = ViewportMargins {
547
- top,
548
- bottom,
549
- inferred : false ,
550
- }
507
+ self . viewport_margins = ViewportMargins { top, bottom }
551
508
}
552
509
_ => { }
553
510
} ;
554
511
}
555
512
556
- fn infer_viewport_margins ( & mut self ) {
557
- if self . viewport_margins . inferred {
558
- self . viewport_margins . top = self
559
- . actual_lines
560
- . iter ( )
561
- . take_while ( |line| {
562
- if let Some ( line) = line {
563
- line. borrow ( ) . is_inferred_border
564
- } else {
565
- false
566
- }
567
- } )
568
- . count ( ) as u64 ;
569
- self . viewport_margins . bottom = ( self . viewport_margins . top as usize
570
- ..self . actual_lines . len ( ) )
571
- . rev ( )
572
- . map ( |i| self . actual_lines [ i] . as_ref ( ) )
573
- . take_while ( |line| {
574
- if let Some ( line) = line {
575
- line. borrow ( ) . is_inferred_border
576
- } else {
577
- false
578
- }
579
- } )
580
- . count ( ) as u64 ;
581
- }
582
- }
583
-
584
513
pub fn flush ( & mut self , renderer_settings : & RendererSettings ) {
585
- self . infer_viewport_margins ( ) ;
586
-
587
514
// If the borders are changed, reset the scrollback to only fit the inner view
588
515
let inner_range = self . viewport_margins . top as isize
589
516
..( self . actual_lines . len ( ) - self . viewport_margins . bottom as usize ) as isize ;
@@ -641,19 +568,10 @@ impl RenderedWindow {
641
568
let actual_line_count = self . actual_lines . len ( ) as isize ;
642
569
let bottom_border_indices =
643
570
actual_line_count - self . viewport_margins . bottom as isize ..actual_line_count;
644
- let margins_inferred = self . viewport_margins . inferred ;
645
571
646
572
top_border_indices
647
573
. chain ( bottom_border_indices)
648
- . filter_map ( move |i| {
649
- self . actual_lines [ i] . as_ref ( ) . and_then ( |line| {
650
- if !margins_inferred || line. borrow ( ) . is_inferred_border {
651
- Some ( ( i, line) )
652
- } else {
653
- None
654
- }
655
- } )
656
- } )
574
+ . filter_map ( move |i| self . actual_lines [ i] . as_ref ( ) . map ( |line| ( i, line) ) )
657
575
}
658
576
659
577
// Iterates over the scrollable lines (excluding the viewport margins). Includes the index for
0 commit comments