@@ -300,26 +300,31 @@ fn print_node<'a>(
300
300
no_dedupe : bool ,
301
301
display_depth : DisplayDepth ,
302
302
visited_deps : & mut HashSet < NodeId > ,
303
- levels_continue : & mut Vec < bool > ,
303
+ levels_continue : & mut Vec < ( anstyle :: Style , bool ) > ,
304
304
print_stack : & mut Vec < NodeId > ,
305
305
) {
306
306
let new = no_dedupe || visited_deps. insert ( node_index) ;
307
307
308
308
match prefix {
309
309
Prefix :: Depth => drop_print ! ( ws. gctx( ) , "{}" , levels_continue. len( ) ) ,
310
310
Prefix :: Indent => {
311
- if let Some ( ( last_continues, rest) ) = levels_continue. split_last ( ) {
312
- for continues in rest {
311
+ if let Some ( ( ( last_style , last_continues) , rest) ) = levels_continue. split_last ( ) {
312
+ for ( style , continues) in rest {
313
313
let c = if * continues { symbols. down } else { " " } ;
314
- drop_print ! ( ws. gctx( ) , "{} " , c ) ;
314
+ drop_print ! ( ws. gctx( ) , "{style}{c}{style:#} " ) ;
315
315
}
316
316
317
317
let c = if * last_continues {
318
318
symbols. tee
319
319
} else {
320
320
symbols. ell
321
321
} ;
322
- drop_print ! ( ws. gctx( ) , "{0}{1}{1} " , c, symbols. right) ;
322
+ drop_print ! (
323
+ ws. gctx( ) ,
324
+ "{last_style}{0}{1}{1}{last_style:#} " ,
325
+ c,
326
+ symbols. right
327
+ ) ;
323
328
}
324
329
}
325
330
Prefix :: None => { }
@@ -379,7 +384,7 @@ fn print_dependencies<'a>(
379
384
no_dedupe : bool ,
380
385
display_depth : DisplayDepth ,
381
386
visited_deps : & mut HashSet < NodeId > ,
382
- levels_continue : & mut Vec < bool > ,
387
+ levels_continue : & mut Vec < ( anstyle :: Style , bool ) > ,
383
388
print_stack : & mut Vec < NodeId > ,
384
389
kind : & EdgeKind ,
385
390
) {
@@ -390,19 +395,23 @@ fn print_dependencies<'a>(
390
395
391
396
let name = match kind {
392
397
EdgeKind :: Dep ( DepKind :: Normal ) => None ,
393
- EdgeKind :: Dep ( DepKind :: Build ) => Some ( "[build-dependencies]" ) ,
394
- EdgeKind :: Dep ( DepKind :: Development ) => Some ( "[dev-dependencies]" ) ,
398
+ EdgeKind :: Dep ( DepKind :: Build ) => {
399
+ Some ( color_print:: cstr!( "<blue,bold>[build-dependencies]</>" ) )
400
+ }
401
+ EdgeKind :: Dep ( DepKind :: Development ) => {
402
+ Some ( color_print:: cstr!( "<cyan,bold>[dev-dependencies]</>" ) )
403
+ }
395
404
EdgeKind :: Feature => None ,
396
405
} ;
397
406
398
407
if let Prefix :: Indent = prefix {
399
408
if let Some ( name) = name {
400
- for continues in & * * levels_continue {
409
+ for ( style , continues) in & * * levels_continue {
401
410
let c = if * continues { symbols. down } else { " " } ;
402
- drop_print ! ( ws. gctx( ) , "{} " , c ) ;
411
+ drop_print ! ( ws. gctx( ) , "{style}{c}{style:#} " ) ;
403
412
}
404
413
405
- drop_println ! ( ws. gctx( ) , "{}" , name ) ;
414
+ drop_println ! ( ws. gctx( ) , "{name}" ) ;
406
415
}
407
416
}
408
417
@@ -433,7 +442,8 @@ fn print_dependencies<'a>(
433
442
. peekable ( ) ;
434
443
435
444
while let Some ( dependency) = it. next ( ) {
436
- levels_continue. push ( it. peek ( ) . is_some ( ) ) ;
445
+ let style = edge_line_color ( dependency. kind ( ) ) ;
446
+ levels_continue. push ( ( style, it. peek ( ) . is_some ( ) ) ) ;
437
447
print_node (
438
448
ws,
439
449
graph,
@@ -451,3 +461,16 @@ fn print_dependencies<'a>(
451
461
levels_continue. pop ( ) ;
452
462
}
453
463
}
464
+
465
+ fn edge_line_color ( kind : EdgeKind ) -> anstyle:: Style {
466
+ match kind {
467
+ EdgeKind :: Dep ( DepKind :: Normal ) => anstyle:: Style :: new ( ) | anstyle:: Effects :: DIMMED ,
468
+ EdgeKind :: Dep ( DepKind :: Build ) => {
469
+ anstyle:: AnsiColor :: Blue . on_default ( ) | anstyle:: Effects :: BOLD
470
+ }
471
+ EdgeKind :: Dep ( DepKind :: Development ) => {
472
+ anstyle:: AnsiColor :: Cyan . on_default ( ) | anstyle:: Effects :: BOLD
473
+ }
474
+ EdgeKind :: Feature => anstyle:: AnsiColor :: Magenta . on_default ( ) | anstyle:: Effects :: DIMMED ,
475
+ }
476
+ }
0 commit comments