Add support for scrolling left and right. (#788)
This commit is contained in:
parent
db443b08e8
commit
55739aa786
@ -575,6 +575,10 @@ pub enum MouseEventKind {
|
||||
ScrollDown,
|
||||
/// Scrolled mouse wheel upwards (away from the user).
|
||||
ScrollUp,
|
||||
/// Scrolled mouse wheel left (mostly on a laptop touchpad).
|
||||
ScrollLeft,
|
||||
/// Scrolled mouse wheel right (mostly on a laptop touchpad).
|
||||
ScrollRight,
|
||||
}
|
||||
|
||||
/// Represents a mouse button.
|
||||
|
@ -788,6 +788,8 @@ fn parse_cb(cb: u8) -> io::Result<(MouseEventKind, KeyModifiers)> {
|
||||
(3, true) | (4, true) | (5, true) => MouseEventKind::Moved,
|
||||
(4, false) => MouseEventKind::ScrollUp,
|
||||
(5, false) => MouseEventKind::ScrollDown,
|
||||
(6, false) => MouseEventKind::ScrollLeft,
|
||||
(7, false) => MouseEventKind::ScrollRight,
|
||||
// We do not support other buttons.
|
||||
_ => return Err(could_not_parse_event_error()),
|
||||
};
|
||||
|
@ -358,7 +358,15 @@ fn parse_mouse_event_record(
|
||||
}
|
||||
}
|
||||
EventFlags::DoubleClick => None, // double click not supported by unix terminals
|
||||
EventFlags::MouseHwheeled => None, // horizontal scroll not supported by unix terminals
|
||||
EventFlags::MouseHwheeled => {
|
||||
if button_state.scroll_left() {
|
||||
Some(MouseEventKind::ScrollLeft)
|
||||
} else if button_state.scroll_right() {
|
||||
Some(MouseEventKind::ScrollRight)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user