@@ -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 ;
@@ -310,6 +310,8 @@ pub struct TextRenderer<'a> {
310
310
pub whitespace_style : Style ,
311
311
pub indent_guide_char : String ,
312
312
pub indent_guide_style : Style ,
313
+ pub indent_guide_rainbow : RainbowIndentOptions ,
314
+ pub theme : & ' a Theme ,
313
315
pub newline : String ,
314
316
pub nbsp : String ,
315
317
pub space : String ,
@@ -326,7 +328,7 @@ impl<'a> TextRenderer<'a> {
326
328
pub fn new (
327
329
surface : & ' a mut Surface ,
328
330
doc : & Document ,
329
- theme : & Theme ,
331
+ theme : & ' a Theme ,
330
332
col_offset : usize ,
331
333
viewport : Rect ,
332
334
) -> TextRenderer < ' a > {
@@ -363,12 +365,19 @@ impl<'a> TextRenderer<'a> {
363
365
} ;
364
366
365
367
let text_style = theme. get ( "ui.text" ) ;
368
+ let basic_style = text_style. patch (
369
+ theme
370
+ . try_get ( "ui.virtual.indent-guide" )
371
+ . unwrap_or_else ( || theme. get ( "ui.virtual.whitespace" ) ) ,
372
+ ) ;
366
373
367
374
let indent_width = doc. indent_style . indent_width ( tab_width) as u16 ;
368
375
369
376
TextRenderer {
370
377
surface,
371
378
indent_guide_char : editor_config. indent_guides . character . into ( ) ,
379
+ indent_guide_rainbow : editor_config. indent_guides . rainbow_option . clone ( ) ,
380
+ theme,
372
381
newline,
373
382
nbsp,
374
383
space,
@@ -379,11 +388,7 @@ impl<'a> TextRenderer<'a> {
379
388
starting_indent : col_offset / indent_width as usize
380
389
+ ( col_offset % indent_width as usize != 0 ) as usize
381
390
+ editor_config. indent_guides . skip_levels as usize ,
382
- indent_guide_style : text_style. patch (
383
- theme
384
- . try_get ( "ui.virtual.indent-guide" )
385
- . unwrap_or_else ( || theme. get ( "ui.virtual.whitespace" ) ) ,
386
- ) ,
391
+ indent_guide_style : basic_style,
387
392
text_style,
388
393
draw_indent_guides : editor_config. indent_guides . render ,
389
394
viewport,
@@ -477,8 +482,25 @@ impl<'a> TextRenderer<'a> {
477
482
as u16 ;
478
483
let y = self . viewport . y + row;
479
484
debug_assert ! ( self . surface. in_bounds( x, y) ) ;
480
- self . surface
481
- . set_string ( x, y, & self . indent_guide_char , self . indent_guide_style ) ;
485
+ match self . indent_guide_rainbow {
486
+ RainbowIndentOptions :: None => {
487
+ self . surface
488
+ . set_string ( x, y, & self . indent_guide_char , self . indent_guide_style )
489
+ }
490
+ RainbowIndentOptions :: Dim => {
491
+ let new_style = self
492
+ . indent_guide_style
493
+ . patch ( self . theme . get_rainbow ( i) )
494
+ . add_modifier ( Modifier :: DIM ) ;
495
+ self . surface
496
+ . set_string ( x, y, & self . indent_guide_char , new_style) ;
497
+ }
498
+ RainbowIndentOptions :: Normal => {
499
+ let new_style = self . indent_guide_style . patch ( self . theme . get_rainbow ( i) ) ;
500
+ self . surface
501
+ . set_string ( x, y, & self . indent_guide_char , new_style) ;
502
+ }
503
+ } ;
482
504
}
483
505
}
484
506
}
0 commit comments