diff options
| author | Jonas Maier <jonas@x77.dev> | 2026-05-14 16:37:21 +0200 |
|---|---|---|
| committer | Jonas Maier <jonas@x77.dev> | 2026-05-14 16:37:21 +0200 |
| commit | 843f6a9f7ffed9b1e5843778ce907b6382978f80 (patch) | |
| tree | 41f0e7aff961dbef154ca177ca518d7caebdfce8 /src/lib.rs | |
| parent | 7cb3e5fbf183c24a91c75c9afed85127ebf5123c (diff) | |
| download | pish-843f6a9f7ffed9b1e5843778ce907b6382978f80.tar.gz | |
nicer pipe behavior
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -261,16 +261,16 @@ impl Session { } } - fn type_byte(&mut self, b: u8) { - self.line.add(b); - io::stdout().lock().write_all(&[b]).unwrap(); - self.line.display_post(b""); - } - fn type_bytes(&mut self, bs: &[u8]) { for b in bs.iter() { - self.type_byte(*b); + self.line.add(*b); } + io::stdout().lock().write_all(&bs).unwrap(); + self.line.display_post(b""); + } + + fn type_byte(&mut self, b: u8) { + self.type_bytes(&[b]); } fn del_left(&mut self) { @@ -295,6 +295,16 @@ impl Session { } } + fn prompt_pipe_previous(&mut self) { + if self.line.is_empty() && let Some(prev) = self.history.last() { + let mut cmd = prev.cmd.clone(); + cmd.push_all(b" | "); + self.type_bytes(&cmd); + } else { + self.type_byte(b'|'); + } + } + fn move_to_begin(&mut self) { cursor::move_cursor(Direction::Left, self.line.all_left()); io::stdout().flush().unwrap(); |
