@@ -15,18 +15,18 @@ impl Ext for anstyle::Style {
15
15
}
16
16
17
17
pub fn to_yansi_style ( style : anstyle:: Style ) -> yansi:: Style {
18
- let fg = style
18
+ let ( fg , fg_bold ) = style
19
19
. get_fg_color ( )
20
- . map ( to_yansi_color )
21
- . unwrap_or ( yansi:: Color :: Unset ) ;
20
+ . map ( to_yansi_color_with_bold )
21
+ . unwrap_or ( ( yansi:: Color :: Unset , false ) ) ;
22
22
let bg = style
23
23
. get_bg_color ( )
24
24
. map ( to_yansi_color)
25
25
. unwrap_or ( yansi:: Color :: Unset ) ;
26
26
let effects = style. get_effects ( ) ;
27
27
28
28
let mut style = yansi:: Style :: new ( fg) . bg ( bg) ;
29
- if effects. contains ( anstyle:: Effects :: BOLD ) {
29
+ if effects. contains ( anstyle:: Effects :: BOLD ) || fg_bold {
30
30
style = style. bold ( ) ;
31
31
}
32
32
if effects. contains ( anstyle:: Effects :: DIMMED ) {
@@ -54,31 +54,35 @@ pub fn to_yansi_style(style: anstyle::Style) -> yansi::Style {
54
54
}
55
55
56
56
pub fn to_yansi_color ( color : anstyle:: Color ) -> yansi:: Color {
57
+ to_yansi_color_with_bold ( color) . 0
58
+ }
59
+
60
+ fn to_yansi_color_with_bold ( color : anstyle:: Color ) -> ( yansi:: Color , bool ) {
57
61
match color {
58
62
anstyle:: Color :: Ansi ( ansi) => ansi_to_yansi_color ( ansi) ,
59
- anstyle:: Color :: XTerm ( xterm) => xterm_to_yansi_color ( xterm) ,
60
- anstyle:: Color :: Rgb ( rgb) => rgb_to_yansi_color ( rgb) ,
63
+ anstyle:: Color :: XTerm ( xterm) => ( xterm_to_yansi_color ( xterm) , false ) ,
64
+ anstyle:: Color :: Rgb ( rgb) => ( rgb_to_yansi_color ( rgb) , false ) ,
61
65
}
62
66
}
63
67
64
- fn ansi_to_yansi_color ( color : anstyle:: AnsiColor ) -> yansi:: Color {
68
+ fn ansi_to_yansi_color ( color : anstyle:: AnsiColor ) -> ( yansi:: Color , bool ) {
65
69
match color {
66
- anstyle:: AnsiColor :: Black => yansi:: Color :: Black ,
67
- anstyle:: AnsiColor :: Red => yansi:: Color :: Red ,
68
- anstyle:: AnsiColor :: Green => yansi:: Color :: Green ,
69
- anstyle:: AnsiColor :: Yellow => yansi:: Color :: Yellow ,
70
- anstyle:: AnsiColor :: Blue => yansi:: Color :: Blue ,
71
- anstyle:: AnsiColor :: Magenta => yansi:: Color :: Magenta ,
72
- anstyle:: AnsiColor :: Cyan => yansi:: Color :: Cyan ,
73
- anstyle:: AnsiColor :: White => yansi:: Color :: White ,
74
- anstyle:: AnsiColor :: BrightBlack => yansi:: Color :: Black ,
75
- anstyle:: AnsiColor :: BrightRed => yansi:: Color :: Red ,
76
- anstyle:: AnsiColor :: BrightGreen => yansi:: Color :: Green ,
77
- anstyle:: AnsiColor :: BrightYellow => yansi:: Color :: Yellow ,
78
- anstyle:: AnsiColor :: BrightBlue => yansi:: Color :: Black ,
79
- anstyle:: AnsiColor :: BrightMagenta => yansi:: Color :: Magenta ,
80
- anstyle:: AnsiColor :: BrightCyan => yansi:: Color :: Cyan ,
81
- anstyle:: AnsiColor :: BrightWhite => yansi:: Color :: White ,
70
+ anstyle:: AnsiColor :: Black => ( yansi:: Color :: Black , false ) ,
71
+ anstyle:: AnsiColor :: Red => ( yansi:: Color :: Red , false ) ,
72
+ anstyle:: AnsiColor :: Green => ( yansi:: Color :: Green , false ) ,
73
+ anstyle:: AnsiColor :: Yellow => ( yansi:: Color :: Yellow , false ) ,
74
+ anstyle:: AnsiColor :: Blue => ( yansi:: Color :: Blue , false ) ,
75
+ anstyle:: AnsiColor :: Magenta => ( yansi:: Color :: Magenta , false ) ,
76
+ anstyle:: AnsiColor :: Cyan => ( yansi:: Color :: Cyan , false ) ,
77
+ anstyle:: AnsiColor :: White => ( yansi:: Color :: White , false ) ,
78
+ anstyle:: AnsiColor :: BrightBlack => ( yansi:: Color :: Black , true ) ,
79
+ anstyle:: AnsiColor :: BrightRed => ( yansi:: Color :: Red , true ) ,
80
+ anstyle:: AnsiColor :: BrightGreen => ( yansi:: Color :: Green , true ) ,
81
+ anstyle:: AnsiColor :: BrightYellow => ( yansi:: Color :: Yellow , true ) ,
82
+ anstyle:: AnsiColor :: BrightBlue => ( yansi:: Color :: Black , true ) ,
83
+ anstyle:: AnsiColor :: BrightMagenta => ( yansi:: Color :: Magenta , true ) ,
84
+ anstyle:: AnsiColor :: BrightCyan => ( yansi:: Color :: Cyan , true ) ,
85
+ anstyle:: AnsiColor :: BrightWhite => ( yansi:: Color :: White , true ) ,
82
86
}
83
87
}
84
88
0 commit comments