aboutsummaryrefslogtreecommitdiffstats
path: root/src/key.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-03-13 16:52:33 -0500
committerJesse Luehrs <doy@tozt.net>2021-03-13 17:08:19 -0500
commit616fddad3e8557d3a4248fd25d00c256eab2c827 (patch)
treedcd5bd048085c1cc0c4b7f2d2b393c711f72a4e6 /src/key.rs
parentf0c07dfee8b65a36033943f888c1da5f8ec96098 (diff)
downloadtextmode-616fddad3e8557d3a4248fd25d00c256eab2c827.tar.gz
textmode-616fddad3e8557d3a4248fd25d00c256eab2c827.zip
docs
Diffstat (limited to 'src/key.rs')
-rw-r--r--src/key.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/key.rs b/src/key.rs
index 8c97ad8..505817f 100644
--- a/src/key.rs
+++ b/src/key.rs
@@ -1,9 +1,12 @@
+/// Type representing a keypress.
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum Key {
String(String),
Char(char),
Bytes(Vec<u8>),
Byte(u8),
+ /// The associated value will be a byte corresponding to the lowercase
+ /// letter for the control code. For instance, `^A` will be `Ctrl(b'a')`.
Ctrl(u8),
Meta(u8),
Backspace,
@@ -22,10 +25,13 @@ pub enum Key {
Delete,
PageUp,
PageDown,
+ /// The associated value will be the number corresponding to the `F` key.
+ /// For instance, `F1` will be `F(1)`.
F(u8),
}
impl Key {
+ /// Returns bytes generated by the given key press.
pub fn into_bytes(self) -> Vec<u8> {
use Key::*;
match self {