1+ use afetch:: config:: deserialize:: ColorWrapper ;
12use afetch:: config:: { Config , Entry , LogoStyle , SeparatorSizing , load_config} ;
23use afetch:: error:: { ErrorType , FetchInfoError } ;
34use afetch:: logos:: get_logo;
@@ -16,11 +17,10 @@ use afetch::system::public_ip::get_public_ip;
1617use afetch:: system:: uptime:: get_uptime;
1718use afetch:: system:: { InfoGroup , InfoKind , InfoResult } ;
1819use afetch:: translations:: get_language;
19- use afetch:: util:: colored:: { ColorWrapper , ColorizeExt } ;
2020use afetch:: util:: count_str_length;
2121#[ cfg( feature = "image" ) ]
2222use afetch:: util:: print_picture;
23- use colored :: Colorize ;
23+ use owo_colors :: { DynColors , OwoColorize , XtermColors } ;
2424use rayon:: iter:: { IntoParallelRefIterator , ParallelIterator } ;
2525use std:: collections:: HashMap ;
2626use std:: fmt:: Write ;
@@ -70,25 +70,38 @@ fn main() -> Result<(), FetchInfoError> {
7070 None
7171 } ;
7272
73- let header_color = match config. colors . header {
74- Some ( color) => color,
73+ let header_color: DynColors = match config. colors . header {
74+ Some ( color) => color. into ( ) ,
7575 None => match logo. as_ref ( ) {
76- Some ( color) => ColorWrapper :: Ansi ( color. 1 ) ,
77- None => ColorWrapper :: Ansi ( 6 ) ,
76+ Some ( color) => DynColors :: Xterm ( color. 1 . into ( ) ) ,
77+ None => DynColors :: Xterm ( XtermColors :: Cyan ) ,
7878 } ,
7979 } ;
80- let header_separator_color = config. colors . header_separator . unwrap_or ( match & logo {
81- Some ( color) => ColorWrapper :: Ansi ( color. 1 ) ,
82- None => ColorWrapper :: Ansi ( 6 ) ,
83- } ) ;
84- let info_color = config. colors . info . unwrap_or ( match & logo {
85- Some ( color) => ColorWrapper :: Ansi ( color. 1 ) ,
86- None => ColorWrapper :: Ansi ( 6 ) ,
87- } ) ;
88- let separator_color = config. colors . separator . unwrap_or ( match & logo {
89- Some ( color) => ColorWrapper :: Ansi ( color. 1 ) ,
90- None => ColorWrapper :: Ansi ( 6 ) ,
91- } ) ;
80+ let header_separator_color: DynColors = config
81+ . colors
82+ . header_separator
83+ . map ( ColorWrapper :: into)
84+ . unwrap_or ( match & logo {
85+ Some ( color) => DynColors :: Xterm ( color. 1 . into ( ) ) ,
86+ None => DynColors :: Xterm ( XtermColors :: Cyan ) ,
87+ } ) ;
88+ let info_color: DynColors = config
89+ . colors
90+ . info
91+ . map ( ColorWrapper :: into)
92+ . unwrap_or ( match & logo {
93+ Some ( color) => DynColors :: Xterm ( color. 1 . into ( ) ) ,
94+ None => DynColors :: Xterm ( XtermColors :: Cyan ) ,
95+ } ) ;
96+ let separator_color: DynColors =
97+ config
98+ . colors
99+ . separator
100+ . map ( ColorWrapper :: into)
101+ . unwrap_or ( match & logo {
102+ Some ( color) => DynColors :: Xterm ( color. 1 . into ( ) ) ,
103+ None => DynColors :: Xterm ( XtermColors :: Cyan ) ,
104+ } ) ;
92105
93106 let mut output: String = String :: default ( ) ;
94107 let mut last_info_len = 0 ;
@@ -153,9 +166,9 @@ fn main() -> Result<(), FetchInfoError> {
153166
154167 formatted_info = format ! (
155168 "{}{}{}" ,
156- formatted_header. custom_color_wrapper ( header_color) . bold( ) ,
157- separator. custom_color_wrapper ( header_separator_color) ,
158- formatted_info. custom_color_wrapper ( info_color)
169+ formatted_header. color ( header_color) . bold( ) ,
170+ separator. color ( header_separator_color) ,
171+ formatted_info. color ( info_color)
159172 ) ;
160173
161174 write_entry ( formatted_info) ;
@@ -174,11 +187,7 @@ fn main() -> Result<(), FetchInfoError> {
174187 }
175188 } ;
176189
177- write_entry (
178- formatted_separator
179- . custom_color_wrapper ( separator_color)
180- . to_string ( ) ,
181- ) ;
190+ write_entry ( formatted_separator. color ( separator_color) . to_string ( ) ) ;
182191 }
183192 Entry :: ColorBlocks { content, display } => {
184193 if display. show_normal ( ) {
@@ -199,11 +208,11 @@ fn main() -> Result<(), FetchInfoError> {
199208 }
200209 }
201210
202- if let Some ( ( _, _, lines) ) = & logo {
203- if i < lines. len ( ) {
204- for logo_line in & lines [ i.. ] {
205- writeln ! ( output , " {}{}" , logo_line, "" . white ( ) ) . ok ( ) ;
206- }
211+ if let Some ( ( _, _, lines) ) = & logo
212+ && i < lines. len ( )
213+ {
214+ for logo_line in & lines [ i.. ] {
215+ writeln ! ( output , " {}{}" , logo_line , "" . white ( ) ) . ok ( ) ;
207216 }
208217 }
209218
0 commit comments