Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): add support for mapping # #2278

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/remapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Control, Shift and Alt modifiers are encoded respectively with the prefixes
| \- | `"minus"` |
| ; | `"semicolon"` |
| % | `"percent"` |
| # | `"hash"` |
| Left | `"left"` |
| Right | `"right"` |
| Up | `"up"` |
Expand Down
4 changes: 4 additions & 0 deletions helix-view/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub(crate) mod keys {
pub(crate) const MINUS: &str = "minus";
pub(crate) const SEMICOLON: &str = "semicolon";
pub(crate) const PERCENT: &str = "percent";
pub(crate) const HASH: &str = "hash";
}

impl fmt::Display for KeyEvent {
Expand Down Expand Up @@ -92,6 +93,7 @@ impl fmt::Display for KeyEvent {
KeyCode::Char('-') => f.write_str(keys::MINUS)?,
KeyCode::Char(';') => f.write_str(keys::SEMICOLON)?,
KeyCode::Char('%') => f.write_str(keys::PERCENT)?,
KeyCode::Char('#') => f.write_str(keys::HASH)?,
KeyCode::F(i) => f.write_fmt(format_args!("F{}", i))?,
KeyCode::Char(c) => f.write_fmt(format_args!("{}", c))?,
};
Expand Down Expand Up @@ -125,6 +127,7 @@ impl UnicodeWidthStr for KeyEvent {
KeyCode::Char('-') => keys::MINUS.len(),
KeyCode::Char(';') => keys::SEMICOLON.len(),
KeyCode::Char('%') => keys::PERCENT.len(),
KeyCode::Char('#') => keys::HASH.len(),
KeyCode::F(1..=9) => 2,
KeyCode::F(_) => 3,
KeyCode::Char(c) => c.width().unwrap_or(0),
Expand Down Expand Up @@ -174,6 +177,7 @@ impl std::str::FromStr for KeyEvent {
keys::MINUS => KeyCode::Char('-'),
keys::SEMICOLON => KeyCode::Char(';'),
keys::PERCENT => KeyCode::Char('%'),
keys::HASH => 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();
Expand Down