sysutils/top: add down/up keys
This commit is contained in:
@@ -8,6 +8,8 @@ pub const KEY_ENTER: &[u8] = b"\x0D";
|
||||
pub const KEY_ESCAPE: &[u8] = b"\x1B";
|
||||
pub const KEY_HOME: &[u8] = b"\x1B[H";
|
||||
pub const KEY_END: &[u8] = b"\x1B[F";
|
||||
pub const KEY_PAGEUP: &[u8] = b"\x1B[5~";
|
||||
pub const KEY_PAGEDOWN: &[u8] = b"\x1B[6~";
|
||||
|
||||
pub fn map(modifier: KeyModifiers, key: Key) -> Option<&'static [u8]> {
|
||||
match (modifier, key) {
|
||||
@@ -19,6 +21,8 @@ pub fn map(modifier: KeyModifiers, key: Key) -> Option<&'static [u8]> {
|
||||
(KeyModifiers::NONE, Key::Left) => Some(KEY_LEFT),
|
||||
(KeyModifiers::NONE, Key::Home) => Some(KEY_HOME),
|
||||
(KeyModifiers::NONE, Key::End) => Some(KEY_END),
|
||||
(KeyModifiers::NONE, Key::PageUp) => Some(KEY_PAGEUP),
|
||||
(KeyModifiers::NONE, Key::PageDown) => Some(KEY_PAGEDOWN),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,15 +156,7 @@ impl Term {
|
||||
}
|
||||
|
||||
pub fn set_cursor_visible(&mut self, visible: bool) -> io::Result<()> {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
self.stdout.raw_set_cursor_visible(visible)
|
||||
}
|
||||
#[cfg(target_os = "yggdrasil")]
|
||||
{
|
||||
let _ = visible;
|
||||
Ok(())
|
||||
}
|
||||
self.stdout.raw_set_cursor_visible(visible)
|
||||
}
|
||||
pub fn set_cursor_style(&mut self, style: CursorStyle) -> io::Result<()> {
|
||||
self.stdout.raw_set_cursor_style(style)
|
||||
|
||||
@@ -262,10 +262,10 @@ fn run() -> io::Result<()> {
|
||||
log::error!("Kill: {error}");
|
||||
}
|
||||
}
|
||||
TermKey::Char('k') => {
|
||||
TermKey::Char('k') | TermKey::Up => {
|
||||
state.prev();
|
||||
}
|
||||
TermKey::Char('j') => {
|
||||
TermKey::Char('j') | TermKey::Down => {
|
||||
state.next();
|
||||
}
|
||||
_ => (),
|
||||
|
||||
@@ -13,9 +13,6 @@ fn main() {
|
||||
term.set_cursor_position(i, 0).ok();
|
||||
write!(term, "{key:?}").ok();
|
||||
}
|
||||
let (row, column) = term.report_cursor_position().unwrap().unwrap();
|
||||
term.set_cursor_position(25, 0).ok();
|
||||
write!(term, "row = {row}, column = {column}").ok();
|
||||
term.flush().ok();
|
||||
|
||||
let key = term.read_key().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user