@@ -14,6 +14,7 @@ use std::fmt::Display;
14
14
use std:: ops:: Not ;
15
15
use std:: path:: PathBuf ;
16
16
use unicode_width:: UnicodeWidthStr ;
17
+ use crate :: infra:: str:: StrExt ;
17
18
18
19
pub fn login ( cfg_path : & Result < PathBuf > ) {
19
20
match cfg_path {
@@ -82,10 +83,20 @@ pub fn list_ing(ing_list: &Result<Vec<(IngEntry, Vec<IngCommentEntry>)>>, rev: b
82
83
print ! ( " {}⭐" , star_text. yellow( ) ) ;
83
84
}
84
85
println ! ( " {} {}" , "#" . dimmed( ) , ing. id. to_string( ) . dimmed( ) ) ;
85
- let user_name_width = ing. user_name . width_cjk ( ) ;
86
86
let content = if align {
87
- fmt_content ( & ing. content )
88
- . replace ( '\n' , & format ! ( "\n {}" , " " . repeat( user_name_width + 3 ) ) )
87
+ let user_name_width = ing. user_name . width_cjk ( ) ;
88
+ let ( term_width, _) = term_size:: dimensions ( )
89
+ . expect ( "Can not get terminal size" ) ;
90
+ let left_width = term_width. checked_sub ( user_name_width + 3 ) . unwrap_or ( 0 ) ;
91
+ if let Some ( lines) = fmt_content ( & ing. content ) . width_split ( left_width) {
92
+ if comment_list. len ( ) > 0 {
93
+ lines. join ( "\n " ) . replace ( "\n " , & format ! ( "\n │{}" , " " . repeat( user_name_width - 2 ) ) )
94
+ } else {
95
+ lines. join ( "\n " ) . replace ( "\n " , & format ! ( "\n {}" , " " . repeat( user_name_width + 3 ) ) )
96
+ }
97
+ } else {
98
+ ing. content . clone ( )
99
+ }
89
100
} else {
90
101
fmt_content ( & ing. content )
91
102
} ;
@@ -237,7 +248,7 @@ pub fn list_news(news_list: &Result<Vec<NewsEntry>>, rev: bool) {
237
248
} ;
238
249
239
250
let url = format ! ( "https://news.cnblogs.com/n/{}" , news. id) ;
240
- println ! ( "{} {}" , create_time. dimmed( ) , url. dimmed( ) , ) ;
251
+ println ! ( "{} {}" , create_time. dimmed( ) , url. dimmed( ) , ) ;
241
252
println ! ( " {}" , news. title) ;
242
253
println ! ( " {}{}" , news. summary. dimmed( ) , "..." . dimmed( ) ) ;
243
254
println ! ( ) ;
0 commit comments