aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--book/src/remapping.md5
-rw-r--r--helix-view/src/input.rs38
2 files changed, 18 insertions, 25 deletions
diff --git a/book/src/remapping.md b/book/src/remapping.md
index 1cdf9b1f..bd4ac7f8 100644
--- a/book/src/remapping.md
+++ b/book/src/remapping.md
@@ -33,12 +33,7 @@ Control, Shift and Alt modifiers are encoded respectively with the prefixes
| Backspace | `"backspace"` |
| Space | `"space"` |
| Return/Enter | `"ret"` |
-| < | `"lt"` |
-| \> | `"gt"` |
-| \+ | `"plus"` |
| \- | `"minus"` |
-| ; | `"semicolon"` |
-| % | `"percent"` |
| Left | `"left"` |
| Right | `"right"` |
| Up | `"up"` |
diff --git a/helix-view/src/input.rs b/helix-view/src/input.rs
index 14dadc3b..b4875d49 100644
--- a/helix-view/src/input.rs
+++ b/helix-view/src/input.rs
@@ -41,12 +41,7 @@ pub(crate) mod keys {
pub(crate) const NULL: &str = "null";
pub(crate) const ESC: &str = "esc";
pub(crate) const SPACE: &str = "space";
- pub(crate) const LESS_THAN: &str = "lt";
- pub(crate) const GREATER_THAN: &str = "gt";
- pub(crate) const PLUS: &str = "plus";
pub(crate) const MINUS: &str = "minus";
- pub(crate) const SEMICOLON: &str = "semicolon";
- pub(crate) const PERCENT: &str = "percent";
}
impl fmt::Display for KeyEvent {
@@ -86,12 +81,7 @@ impl fmt::Display for KeyEvent {
KeyCode::Null => f.write_str(keys::NULL)?,
KeyCode::Esc => f.write_str(keys::ESC)?,
KeyCode::Char(' ') => f.write_str(keys::SPACE)?,
- KeyCode::Char('<') => f.write_str(keys::LESS_THAN)?,
- KeyCode::Char('>') => f.write_str(keys::GREATER_THAN)?,
- KeyCode::Char('+') => f.write_str(keys::PLUS)?,
KeyCode::Char('-') => f.write_str(keys::MINUS)?,
- KeyCode::Char(';') => f.write_str(keys::SEMICOLON)?,
- KeyCode::Char('%') => f.write_str(keys::PERCENT)?,
KeyCode::F(i) => f.write_fmt(format_args!("F{}", i))?,
KeyCode::Char(c) => f.write_fmt(format_args!("{}", c))?,
};
@@ -119,12 +109,7 @@ impl UnicodeWidthStr for KeyEvent {
KeyCode::Null => keys::NULL.len(),
KeyCode::Esc => keys::ESC.len(),
KeyCode::Char(' ') => keys::SPACE.len(),
- KeyCode::Char('<') => keys::LESS_THAN.len(),
- KeyCode::Char('>') => keys::GREATER_THAN.len(),
- KeyCode::Char('+') => keys::PLUS.len(),
KeyCode::Char('-') => keys::MINUS.len(),
- KeyCode::Char(';') => keys::SEMICOLON.len(),
- KeyCode::Char('%') => keys::PERCENT.len(),
KeyCode::F(1..=9) => 2,
KeyCode::F(_) => 3,
KeyCode::Char(c) => c.width().unwrap_or(0),
@@ -168,12 +153,7 @@ impl std::str::FromStr for KeyEvent {
keys::NULL => KeyCode::Null,
keys::ESC => KeyCode::Esc,
keys::SPACE => KeyCode::Char(' '),
- keys::LESS_THAN => KeyCode::Char('<'),
- keys::GREATER_THAN => KeyCode::Char('>'),
- keys::PLUS => KeyCode::Char('+'),
keys::MINUS => KeyCode::Char('-'),
- keys::SEMICOLON => KeyCode::Char(';'),
- keys::PERCENT => KeyCode::Char('%'),
single if single.chars().count() == 1 => KeyCode::Char(single.chars().next().unwrap()),
function if function.len() > 1 && function.starts_with('F') => {
let function: String = function.chars().skip(1).collect();
@@ -336,6 +316,14 @@ mod test {
modifiers: KeyModifiers::NONE
}
);
+
+ assert_eq!(
+ str::parse::<KeyEvent>("%").unwrap(),
+ KeyEvent {
+ code: KeyCode::Char('%'),
+ modifiers: KeyModifiers::NONE
+ }
+ )
}
#[test]
@@ -375,6 +363,16 @@ mod test {
assert!(str::parse::<KeyEvent>("FU").is_err());
assert!(str::parse::<KeyEvent>("123").is_err());
assert!(str::parse::<KeyEvent>("S--").is_err());
+ assert!(str::parse::<KeyEvent>("S-percent").is_err());
+ }
+
+ #[test]
+ fn parsing_unsupported_named_keys() {
+ assert!(str::parse::<KeyEvent>("lt").is_err());
+ assert!(str::parse::<KeyEvent>("gt").is_err());
+ assert!(str::parse::<KeyEvent>("plus").is_err());
+ assert!(str::parse::<KeyEvent>("percent").is_err());
+ assert!(str::parse::<KeyEvent>("semicolon").is_err());
}
#[test]