Skip to content

Commit

Permalink
feat: align ing wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaumy committed Sep 15, 2023
1 parent 95b5f41 commit 72e6682
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ getrandom = { version = "0.2.10", features = ["js"] }
rand = { version = "0.8.5" }
regex = "1.9.5"
words-count = "0.1.6"
unicode-width = "0.1.10"

serde = { version = "1.0.188", features = ["derive"] }
serde_qs = "0.12.0"
Expand All @@ -43,5 +44,6 @@ futures = "0.3.28"

clap = { version = "4.4.2", features = ["derive", "wrap_help"] }
colored = "2.0.4"
term_size = "0.3.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 changes: 5 additions & 2 deletions src/display/colorful.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use colored::Colorize;
use std::fmt::Display;
use std::ops::Not;
use std::path::PathBuf;
use unicode_width::UnicodeWidthStr;

pub fn login(cfg_path: &Result<PathBuf>) {
match cfg_path {
Expand Down Expand Up @@ -81,9 +82,11 @@ pub fn list_ing(ing_list: &Result<Vec<(IngEntry, Vec<IngCommentEntry>)>>, rev: b
print!(" {}⭐", star_text.yellow());
}
println!(" {} {}", "#".dimmed(), ing.id.to_string().dimmed());
let content = fmt_content(&ing.content);
let user_name_width = ing.user_name.width_cjk();
let content = fmt_content(&ing.content).replace('\n', &format!("\n{}", " ".repeat(user_name_width + 3)));
println!(" {} {}", ing.user_name.cyan(), content);


let len = comment_list.len();
if len != 0 {
let max_i = len - 1;
Expand Down Expand Up @@ -230,7 +233,7 @@ pub fn list_news(news_list: &Result<Vec<NewsEntry>>, rev: bool) {
};

let url = format!("https://news.cnblogs.com/n/{}", news.id);
println!("{} {}", create_time.dimmed(), url.dimmed(),);
println!("{} {}", create_time.dimmed(), url.dimmed(), );
println!(" {}", news.title);
println!(" {}{}", news.summary.dimmed(), "...".dimmed());
println!();
Expand Down
6 changes: 4 additions & 2 deletions src/display/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use colored::Colorize;
use std::fmt::Display;
use std::ops::Not;
use std::path::PathBuf;
use unicode_width::UnicodeWidthStr;

pub fn login(cfg_path: &Result<PathBuf>) {
match cfg_path {
Expand Down Expand Up @@ -81,8 +82,9 @@ pub fn list_ing(ing_list: &Result<Vec<(IngEntry, Vec<IngCommentEntry>)>>, rev: b
print!(" {}⭐", star_text);
}
println!(" # {}", ing.id);
let content = fmt_content(&ing.content);
println!(" {}: {}", ing.user_name, content);
let user_name_width = ing.user_name.width_cjk();
let content = fmt_content(&ing.content).replace('\n', &format!("\n{}", " ".repeat(user_name_width + 3)));
println!(" {} {}", ing.user_name, content);

let len = comment_list.len();
if len != 0 {
Expand Down

0 comments on commit 72e6682

Please sign in to comment.