@@ -446,6 +446,15 @@ pub enum IndexType {
446446 Char ,
447447}
448448
449+ /// Whether rendering of ANSI styling, such as color and font weight, is enabled.
450+ #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
451+ pub enum AnsiMode {
452+ /// ANSI styling is disabled, diagnostics will display without styling.
453+ Off ,
454+ /// ANSI styling is disabled, diagnostics will have ANSI styling escape codes included.
455+ On ,
456+ }
457+
449458/// A type used to configure a report
450459#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
451460pub struct Config {
@@ -460,6 +469,7 @@ pub struct Config {
460469 index_type : IndexType ,
461470 minimise_crossings : bool ,
462471 context_lines : usize ,
472+ ansi_mode : AnsiMode ,
463473}
464474
465475impl Config {
@@ -544,6 +554,13 @@ impl Config {
544554 self . context_lines = context_lines;
545555 self
546556 }
557+ /// Should ANSI escape code styling be included in the diagnostic after writing?
558+ ///
559+ /// If unspecified, this defaults to `AnsiMode::On`.
560+ pub const fn with_ansi_mode ( mut self , ansi_mode : AnsiMode ) -> Self {
561+ self . ansi_mode = ansi_mode;
562+ self
563+ }
547564
548565 fn error_color ( & self ) -> Option < Color > {
549566 Some ( Color :: Red ) . filter ( |_| self . color )
@@ -597,6 +614,7 @@ impl Config {
597614 index_type : IndexType :: Char ,
598615 minimise_crossings : false ,
599616 context_lines : 0 ,
617+ ansi_mode : AnsiMode :: On ,
600618 }
601619 }
602620}
0 commit comments