diff options
| author | Jonas Maier <> | 2026-05-24 18:02:04 +0200 |
|---|---|---|
| committer | Jonas Maier <> | 2026-05-24 18:02:04 +0200 |
| commit | 01a198b8ad42680c9333039c75317d1787120c78 (patch) | |
| tree | 96fac6e66a4f454ba0d6a4fc6d61226346c3258a /src/lib.rs | |
| parent | 52e97864d483f1f442e96058a17c159c5be10db3 (diff) | |
| download | pish-01a198b8ad42680c9333039c75317d1787120c78.tar.gz | |
better multiline handling
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 28 |
1 files changed, 6 insertions, 22 deletions
@@ -197,8 +197,11 @@ impl Session { let prompt = this.lock().unwrap().prompt.prompt().to_vec(); io::stdout().write_all(&prompt).unwrap(); let mut this = this.lock().unwrap(); - this.line.display_pre(); - this.line.display_post(b""); + if let Some(ti) = this.terminal_input.as_mut() + && let Some(pos) = ti.query_cursor_position() + { + this.line.set_begin_of_line(pos); + } this.line.mark_dirty(); this.cohere().unwrap(); } @@ -212,8 +215,6 @@ impl Session { .cmd .clone() }; - io::stdout().write_all(&new).unwrap(); - io::stdout().flush().unwrap(); self.line.set_content(new).unwrap(); } @@ -299,7 +300,6 @@ impl Session { Ok(p) => p, Err(_) => { se.line.type_byte(b'\n').unwrap(); - print!("\r\n> "); return; } }; @@ -340,23 +340,7 @@ impl Session { /// do cleanup actions after a bunch of mutations. fn cohere(&mut self) -> io::Result<()> { - if self.line.is_dirty() { - self.line.mark_clean(); - - // overwrite line in terminal with syntax-highlighted line. - if self.highlighter.enabled { - let buf = self.line.into_bytes(); - let mut parser = parse::Cursor::new(&buf, parse::ParseMode::Completion); - let _res = parse::Ast::parse(&mut parser); - let mut stdout = io::stdout().lock(); - cursor::fmove_cursor(cursor::Direction::Left, self.line.left_len(), &mut stdout)?; - self.highlighter - .pretty_print(&buf, parser.highlights, &mut stdout)?; - cursor::fmove_cursor(cursor::Direction::Left, self.line.right_len(), &mut stdout)?; - stdout.flush()?; - } - } - + self.line.highlight_syntax(&mut self.highlighter)?; Ok(()) } } |
