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 426487d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 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
5 changes: 4 additions & 1 deletion 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,7 +82,9 @@ 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();
Expand Down
7 changes: 5 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,10 @@ 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 426487d

Please sign in to comment.