From 0e102f53da61de230de8b4c4879c046b8c6baf4d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 16 Nov 2021 05:47:45 -0500 Subject: improve drawing of command output in particular, handle line wrapping properly --- src/history.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/history.rs') diff --git a/src/history.rs b/src/history.rs index 4d1d453..8652d6b 100644 --- a/src/history.rs +++ b/src/history.rs @@ -303,15 +303,23 @@ impl HistoryEntry { out.write(b"..."); out.reset_attributes(); } - for row in self - .vt - .screen() + let mut out_row = out.screen().cursor_position().0 + 1; + let screen = self.vt.screen(); + let mut wrapped = false; + for (idx, row) in screen .rows_formatted(0, width) + .enumerate() .take(last_row) .skip(last_row.saturating_sub(5)) { - out.write(b"\r\n"); + let idx: u16 = idx.try_into().unwrap(); + out.write(b"\x1b[m"); + if !wrapped { + out.write(format!("\x1b[{}H", out_row + 1).as_bytes()); + } out.write(&row); + wrapped = screen.row_wrapped(idx); + out_row += 1; } out.reset_attributes(); } -- cgit v1.2.3-54-g00ecf