diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-17 01:01:26 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-17 01:01:26 -0500 |
commit | 49a7def10670fb8c96936d0fba09e3ed2c303f6c (patch) | |
tree | bf0a9d033921cc7123bc5b1d119ddf2b06c6b81b /src/history.rs | |
parent | e8c3b3537fee65813cb914077234aaa46e68916e (diff) | |
download | nbsh-49a7def10670fb8c96936d0fba09e3ed2c303f6c.tar.gz nbsh-49a7def10670fb8c96936d0fba09e3ed2c303f6c.zip |
position the cursor correctly for running commands
it shouldn't always go at the end
Diffstat (limited to 'src/history.rs')
-rw-r--r-- | src/history.rs | 17 |
1 files changed, 17 insertions, 0 deletions
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(); } |