bhcli

A TUI for chatting on LE PHP Chats (onion)
git clone https://git.dasho.dev/n0tr1v/bhcli.git
Log | Files | Refs | README

commit bdf203d56bb9296b4719a7c0c6a59b5fc0d72f6b
parent 0875d3f01427b8c7d68acfbe4dea98327a0ffdbb
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun,  2 Apr 2023 04:58:48 -0700

cleanup

Diffstat:
Msrc/main.rs | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -2426,7 +2426,7 @@ fn draw_terminal_frame( } } -fn gen_lines(msg_txt: &StyledText, w: usize, line_prefix: String) -> Vec<Vec<(tuiColor, String)>> { +fn gen_lines(msg_txt: &StyledText, w: usize, line_prefix: &str) -> Vec<Vec<(tuiColor, String)>> { let txt = msg_txt.text(); let wrapped = textwrap::fill(&txt, w); let splits = wrapped.split("\n").collect::<Vec<&str>>(); @@ -2457,7 +2457,7 @@ fn gen_lines(msg_txt: &StyledText, w: usize, line_prefix: String) -> Vec<Vec<(tu line.push((color, txt[0..remain].to_owned())); new_lines.push(line.clone()); line.clear(); - line.push((tuiColor::White, line_prefix.clone())); + line.push((tuiColor::White, line_prefix.to_owned())); ctxt.push((color, txt[(remain)..].to_owned())); ptr = 0; split_idx += 1; @@ -2474,7 +2474,7 @@ fn gen_lines(msg_txt: &StyledText, w: usize, line_prefix: String) -> Vec<Vec<(tu fn render_long_message(f: &mut Frame<CrosstermBackend<io::Stdout>>, app: &mut App, r: Rect) { if let Some(m) = &app.long_message { - let new_lines = gen_lines(&m.text, (r.width - 2) as usize, "".to_owned()); + let new_lines = gen_lines(&m.text, (r.width - 2) as usize, ""); let mut rows = vec![]; for line in new_lines.into_iter() { @@ -2634,7 +2634,7 @@ fn render_messages( app.items.items.push(m.clone()); - let new_lines = gen_lines(&m.text, (r.width - 20) as usize, " ".repeat(17)); + let new_lines = gen_lines(&m.text, (r.width - 20) as usize, " ".repeat(17).as_str()); let mut rows = vec![]; let date_style = match (m.deleted, m.hide) { @@ -2909,7 +2909,7 @@ mod tests { ), ], ); - let lines = gen_lines(&txt, 71, "".to_owned()); + let lines = gen_lines(&txt, 71, ""); assert_eq!(lines.len(), 2); } }