diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-12-11 05:27:40 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-12-11 05:27:40 -0500 |
commit | f2e345b01b8b7457bb03b7bee0c825664c95f82d (patch) | |
tree | bc381f99a050f0307edbcb9452118ca9aad6581c /src/readline.rs | |
parent | 7fdbec0826efc577dc743d0240f6665669a1ed5f (diff) | |
download | nbsh-f2e345b01b8b7457bb03b7bee0c825664c95f82d.tar.gz nbsh-f2e345b01b8b7457bb03b7bee0c825664c95f82d.zip |
display the history index as well
Diffstat (limited to 'src/readline.rs')
-rw-r--r-- | src/readline.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/readline.rs b/src/readline.rs index 306fed9..0be2cad 100644 --- a/src/readline.rs +++ b/src/readline.rs @@ -59,6 +59,7 @@ impl Readline { pub async fn render( &self, out: &mut textmode::Output, + entry_count: usize, focus: bool, offset: time::UtcOffset, ) -> anyhow::Result<()> { @@ -90,13 +91,16 @@ 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, 2 + self.pos_width()); + out.move_to(self.size.0 - 1, idx_str_len + 2 + self.pos_width()); if focus { out.hide_cursor(false); } |