summaryrefslogtreecommitdiffstats
path: root/src/history.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-11-16 05:47:45 -0500
committerJesse Luehrs <doy@tozt.net>2021-11-16 05:47:45 -0500
commit0e102f53da61de230de8b4c4879c046b8c6baf4d (patch)
treea38bdb831340e295b6e1cdb84cac099c7a80c852 /src/history.rs
parentc5515216780c4c34914ac6086bb51298a3c44513 (diff)
downloadnbsh-0e102f53da61de230de8b4c4879c046b8c6baf4d.tar.gz
nbsh-0e102f53da61de230de8b4c4879c046b8c6baf4d.zip
improve drawing of command output
in particular, handle line wrapping properly
Diffstat (limited to 'src/history.rs')
-rw-r--r--src/history.rs16
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();
}