@@ -7,9 +7,9 @@ use helix_core::syntax::Highlight;
7
7
use helix_core:: syntax:: HighlightEvent ;
8
8
use helix_core:: text_annotations:: TextAnnotations ;
9
9
use helix_core:: { visual_offset_from_block, Position , RopeSlice } ;
10
- use helix_view:: editor:: { WhitespaceConfig , WhitespaceRenderValue } ;
10
+ use helix_view:: editor:: { RainbowIndentOptions , WhitespaceConfig , WhitespaceRenderValue } ;
11
11
use helix_view:: graphics:: Rect ;
12
- use helix_view:: theme:: Style ;
12
+ use helix_view:: theme:: { Modifier , Style } ;
13
13
use helix_view:: view:: ViewPosition ;
14
14
use helix_view:: Document ;
15
15
use helix_view:: Theme ;
@@ -318,6 +318,8 @@ pub struct TextRenderer<'a> {
318
318
pub whitespace_style : Style ,
319
319
pub indent_guide_char : String ,
320
320
pub indent_guide_style : Style ,
321
+ pub indent_guide_rainbow : RainbowIndentOptions ,
322
+ pub theme : & ' a Theme ,
321
323
pub newline : String ,
322
324
pub nbsp : String ,
323
325
pub space : String ,
@@ -333,7 +335,7 @@ impl<'a> TextRenderer<'a> {
333
335
pub fn new (
334
336
surface : & ' a mut Surface ,
335
337
doc : & Document ,
336
- theme : & Theme ,
338
+ theme : & ' a Theme ,
337
339
col_offset : usize ,
338
340
viewport : Rect ,
339
341
) -> TextRenderer < ' a > {
@@ -369,10 +371,17 @@ impl<'a> TextRenderer<'a> {
369
371
} ;
370
372
371
373
let text_style = theme. get ( "ui.text" ) ;
374
+ let basic_style = text_style. patch (
375
+ theme
376
+ . try_get ( "ui.virtual.indent-guide" )
377
+ . unwrap_or_else ( || theme. get ( "ui.virtual.whitespace" ) ) ,
378
+ ) ;
372
379
373
380
TextRenderer {
374
381
surface,
375
382
indent_guide_char : editor_config. indent_guides . character . into ( ) ,
383
+ indent_guide_rainbow : editor_config. indent_guides . rainbow_option . clone ( ) ,
384
+ theme,
376
385
newline,
377
386
nbsp,
378
387
space,
@@ -381,11 +390,7 @@ impl<'a> TextRenderer<'a> {
381
390
whitespace_style : theme. get ( "ui.virtual.whitespace" ) ,
382
391
starting_indent : ( col_offset / tab_width)
383
392
+ editor_config. indent_guides . skip_levels as usize ,
384
- indent_guide_style : text_style. patch (
385
- theme
386
- . try_get ( "ui.virtual.indent-guide" )
387
- . unwrap_or_else ( || theme. get ( "ui.virtual.whitespace" ) ) ,
388
- ) ,
393
+ indent_guide_style : basic_style,
389
394
text_style,
390
395
draw_indent_guides : editor_config. indent_guides . render ,
391
396
viewport,
@@ -471,8 +476,25 @@ impl<'a> TextRenderer<'a> {
471
476
( self . viewport . x as usize + ( i * self . tab_width as usize ) - self . col_offset ) as u16 ;
472
477
let y = self . viewport . y + row;
473
478
debug_assert ! ( self . surface. in_bounds( x, y) ) ;
474
- self . surface
475
- . set_string ( x, y, & self . indent_guide_char , self . indent_guide_style ) ;
479
+ match self . indent_guide_rainbow {
480
+ RainbowIndentOptions :: None => {
481
+ self . surface
482
+ . set_string ( x, y, & self . indent_guide_char , self . indent_guide_style )
483
+ }
484
+ RainbowIndentOptions :: Dim => {
485
+ let new_style = self
486
+ . indent_guide_style
487
+ . patch ( self . theme . get_rainbow ( i) )
488
+ . add_modifier ( Modifier :: DIM ) ;
489
+ self . surface
490
+ . set_string ( x, y, & self . indent_guide_char , new_style) ;
491
+ }
492
+ RainbowIndentOptions :: Normal => {
493
+ let new_style = self . indent_guide_style . patch ( self . theme . get_rainbow ( i) ) ;
494
+ self . surface
495
+ . set_string ( x, y, & self . indent_guide_char , new_style) ;
496
+ }
497
+ } ;
476
498
}
477
499
}
478
500
}
0 commit comments