@@ -9,13 +9,13 @@ use std::{
99} ;
1010
1111pub ( crate ) use self :: render_action:: RenderAction ;
12- use crate :: view:: { LineSegment , ScrollPosition , ViewData , ViewLine } ;
12+ use crate :: view:: { LineSegment , ScrollPosition , ViewData , ViewLine , ViewLines } ;
1313
1414#[ derive( Debug ) ]
1515pub ( crate ) struct RenderSlice {
1616 actions : VecDeque < RenderAction > ,
1717 height : usize ,
18- lines : Vec < ViewLine > ,
18+ lines : ViewLines ,
1919 lines_count : usize ,
2020 lines_leading_count : usize ,
2121 lines_trailing_count : usize ,
@@ -36,7 +36,7 @@ impl RenderSlice {
3636 Self {
3737 actions : VecDeque :: new ( ) ,
3838 height : 0 ,
39- lines : vec ! [ ] ,
39+ lines : ViewLines :: new ( ) ,
4040 lines_count : 0 ,
4141 lines_leading_count : 0 ,
4242 lines_trailing_count : 0 ,
@@ -187,7 +187,7 @@ impl RenderSlice {
187187 self . lines_trailing_count
188188 }
189189
190- pub ( crate ) const fn get_lines ( & self ) -> & Vec < ViewLine > {
190+ pub ( crate ) const fn view_lines ( & self ) -> & ViewLines {
191191 & self . lines
192192 }
193193
@@ -214,8 +214,8 @@ impl RenderSlice {
214214
215215 fn set_padding_height ( & mut self , view_data : & ViewData ) {
216216 let padding_height = if view_data. show_title ( ) { 1 } else { 0 }
217- + view_data. get_leading_lines ( ) . len ( )
218- + view_data. get_trailing_lines ( ) . len ( ) ;
217+ + view_data. leading_lines ( ) . count ( ) as usize
218+ + view_data. trailing_lines ( ) . count ( ) as usize ;
219219
220220 if self . padding_height != padding_height {
221221 self . padding_height = padding_height;
@@ -261,11 +261,10 @@ impl RenderSlice {
261261 ) ;
262262 }
263263
264- #[ expect( clippy:: too_many_lines, reason = "Legacy, needs refactor" ) ]
265264 fn rebuild ( & mut self , view_data : & ViewData ) {
266- let leading_lines_length = view_data. get_leading_lines ( ) . len ( ) ;
267- let trailing_lines_length = view_data. get_trailing_lines ( ) . len ( ) ;
268- let lines_length = view_data. get_lines ( ) . len ( ) ;
265+ let leading_lines_length = view_data. leading_lines ( ) . count ( ) as usize ;
266+ let trailing_lines_length = view_data. trailing_lines ( ) . count ( ) as usize ;
267+ let lines_length = view_data. lines ( ) . count ( ) as usize ;
269268
270269 self . version += 1 ;
271270 self . view_data_name = String :: from ( view_data. get_name ( ) ) ;
@@ -301,7 +300,7 @@ impl RenderSlice {
301300
302301 (
303302 leading_lines_end,
304- Self :: calculate_max_line_length ( view_data. get_leading_lines ( ) , 0 , leading_lines_end) ,
303+ Self :: calculate_max_line_length ( view_data. leading_lines ( ) , 0 , leading_lines_end) ,
305304 )
306305 } ;
307306
@@ -327,7 +326,7 @@ impl RenderSlice {
327326
328327 (
329328 trailing_lines_end,
330- Self :: calculate_max_line_length ( view_data. get_trailing_lines ( ) , 0 , trailing_lines_end) ,
329+ Self :: calculate_max_line_length ( view_data. trailing_lines ( ) , 0 , trailing_lines_end) ,
331330 )
332331 } ;
333332
@@ -352,7 +351,7 @@ impl RenderSlice {
352351 available_height
353352 } ;
354353
355- let max_line_length = Self :: calculate_max_line_length ( view_data. get_lines ( ) , lines_start, lines_end) ;
354+ let max_line_length = Self :: calculate_max_line_length ( view_data. lines ( ) , lines_start, lines_end) ;
356355 (
357356 lines_start,
358357 lines_end,
@@ -373,17 +372,12 @@ impl RenderSlice {
373372 }
374373
375374 self . lines . clear ( ) ;
376- self . push_lines ( view_data. get_leading_lines ( ) , 0 , leading_lines_end, false ) ;
377- self . push_lines (
378- view_data. get_lines ( ) ,
379- lines_start,
380- lines_end,
381- self . should_show_scrollbar ,
382- ) ;
383- self . push_lines ( view_data. get_trailing_lines ( ) , 0 , trailing_lines_end, false ) ;
375+ self . push_lines ( view_data. leading_lines ( ) , 0 , leading_lines_end, false ) ;
376+ self . push_lines ( view_data. lines ( ) , lines_start, lines_end, self . should_show_scrollbar ) ;
377+ self . push_lines ( view_data. trailing_lines ( ) , 0 , trailing_lines_end, false ) ;
384378 }
385379
386- fn calculate_max_line_length ( view_lines : & [ ViewLine ] , start : usize , length : usize ) -> usize {
380+ fn calculate_max_line_length ( view_lines : & ViewLines , start : usize , length : usize ) -> usize {
387381 view_lines
388382 . iter ( )
389383 . skip ( start)
@@ -400,7 +394,7 @@ impl RenderSlice {
400394 } )
401395 }
402396
403- fn push_lines ( & mut self , view_lines : & [ ViewLine ] , start : usize , end : usize , scroll_bar : bool ) {
397+ fn push_lines ( & mut self , view_lines : & ViewLines , start : usize , end : usize , scroll_bar : bool ) {
404398 let window_width = if scroll_bar && self . width > 0 {
405399 self . width - 1
406400 }
0 commit comments