From 6ca82f5be15f1c6c936c82266d1f6dc13185346c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 11 Dec 2021 05:40:06 -0500 Subject: tweak the output a bit more --- src/history.rs | 21 +++++++++++++-------- src/readline.rs | 13 +++++++++---- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/history.rs b/src/history.rs index 3028ef4..9e0215f 100644 --- a/src/history.rs +++ b/src/history.rs @@ -288,6 +288,15 @@ impl Entry { scrolling: bool, offset: time::UtcOffset, ) { + self.set_bgcolor(out, focused); + out.set_fgcolor(textmode::color::YELLOW); + let entry_count_width = format!("{}", entry_count + 1).len(); + let idx_str = format!("{}", idx + 1); + out.write_str(&" ".repeat(entry_count_width - idx_str.len())); + out.write_str(&idx_str); + out.write_str(" "); + out.reset_attributes(); + self.set_bgcolor(out, focused); if let Some(info) = self.exit_info { if info.status.signal().is_some() { @@ -302,25 +311,21 @@ impl Entry { out.write_str(" "); } out.reset_attributes(); + self.set_bgcolor(out, focused); - let entry_count_width = format!("{}", entry_count).len(); - let idx_str = format!("{}", idx + 1); - out.write_str(&" ".repeat(entry_count_width - idx_str.len())); - out.write_str("["); - out.write_str(&idx_str); - out.write_str("]"); out.write_str("$ "); if self.running() { out.set_bgcolor(textmode::Color::Rgb(16, 64, 16)); } out.write_str(&self.cmd); out.reset_attributes(); + self.set_bgcolor(out, focused); let time = if let Some(info) = self.exit_info { format!( - "[{} ({:6})]", + "({}) [{}]", + crate::format::duration(info.instant - self.start_instant), crate::format::time(self.start_time.to_offset(offset)), - crate::format::duration(info.instant - self.start_instant) ) } else { format!( diff --git a/src/readline.rs b/src/readline.rs index 0be2cad..3f71c5a 100644 --- a/src/readline.rs +++ b/src/readline.rs @@ -80,6 +80,14 @@ impl Readline { out.set_bgcolor(textmode::Color::Rgb(32, 32, 32)); } out.write(b"\x1b[K"); + out.set_fgcolor(textmode::color::YELLOW); + out.write_str(&format!("{}", entry_count + 1)); + out.reset_attributes(); + if focus { + out.set_bgcolor(textmode::Color::Rgb(32, 32, 64)); + } else { + out.set_bgcolor(textmode::Color::Rgb(32, 32, 32)); + } out.write_str(" ("); out.write_str(&pwd); out.write_str(")"); @@ -91,16 +99,13 @@ impl Readline { out.move_to(self.size.0 - 1, 0); out.reset_attributes(); - let idx_str = format!("[{}]", entry_count + 1); - let idx_str_len: u16 = idx_str.len().try_into().unwrap(); - out.write_str(&idx_str); out.write_str(&prompt_char); out.write_str(" "); out.reset_attributes(); out.write(b"\x1b[K"); out.write_str(&self.input_line); out.reset_attributes(); - out.move_to(self.size.0 - 1, idx_str_len + 2 + self.pos_width()); + out.move_to(self.size.0 - 1, 2 + self.pos_width()); if focus { out.hide_cursor(false); } -- cgit v1.2.3-54-g00ecf