diff options
-rw-r--r-- | src/history.rs | 16 |
1 files changed, 12 insertions, 4 deletions
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(); } |