From 49a7def10670fb8c96936d0fba09e3ed2c303f6c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 17 Nov 2021 01:01:26 -0500 Subject: position the cursor correctly for running commands it shouldn't always go at the end --- src/history.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/history.rs') diff --git a/src/history.rs b/src/history.rs index 8652d6b..d2a1b0a 100644 --- a/src/history.rs +++ b/src/history.rs @@ -305,7 +305,9 @@ impl HistoryEntry { } let mut out_row = out.screen().cursor_position().0 + 1; let screen = self.vt.screen(); + let pos = screen.cursor_position(); let mut wrapped = false; + let mut cursor_found = None; for (idx, row) in screen .rows_formatted(0, width) .enumerate() @@ -319,8 +321,23 @@ impl HistoryEntry { } out.write(&row); wrapped = screen.row_wrapped(idx); + if pos.0 == idx { + cursor_found = Some(out_row); + } out_row += 1; } + if focused { + if let Some(row) = cursor_found { + if screen.hide_cursor() { + out.write(b"\x1b[?25l"); + } else { + out.write(b"\x1b[?25h"); + out.move_to(row, pos.1); + } + } else { + out.write(b"\x1b[?25l"); + } + } out.reset_attributes(); } -- cgit v1.2.3-54-g00ecf