mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-11 13:51:01 -05:00
Fix/add some keybindings
Adds support for pageup, pagedown, home, and end. Fixes delete inserting spaces. Resolves #15.
This commit is contained in:
parent
e4260134aa
commit
6925daa823
2 changed files with 35 additions and 0 deletions
|
@ -41,11 +41,19 @@ impl<N: input::Notify> Processor<N> {
|
|||
match c {
|
||||
// Ignore BACKSPACE and DEL. These are handled specially.
|
||||
'\u{8}' | '\u{7f}' => (),
|
||||
// Extra thing on macOS delete?
|
||||
'\u{f728}' => (),
|
||||
// OSX arrow keys send invalid characters; ignore.
|
||||
'\u{f700}' | '\u{f701}' | '\u{f702}' | '\u{f703}' => (),
|
||||
// Same with home/end. Am I missing something? Would be
|
||||
// nice if glutin provided the received char in
|
||||
// KeyboardInput event so a choice could be made there
|
||||
// instead of having to special case everything.
|
||||
'\u{f72b}' | '\u{f729}' | '\u{f72c}' | '\u{f72d}' => (),
|
||||
// These letters are handled in the bindings system
|
||||
'v' => (),
|
||||
_ => {
|
||||
println!("printing char {:?}", c);
|
||||
let buf = encode_char(c);
|
||||
self.notifier.notify(buf);
|
||||
}
|
||||
|
|
27
src/input.rs
27
src/input.rs
|
@ -187,6 +187,28 @@ static F12_BINDINGS: &'static [Binding] = &[
|
|||
Binding { mods: mods::ANY, action: Action::Esc("\x1b[24~"), mode: mode::ANY, notmode: mode::NONE },
|
||||
];
|
||||
|
||||
/// Bindings for PageUp
|
||||
static PAGEUP_BINDINGS: &'static [Binding] = &[
|
||||
Binding { mods: mods::ANY, action: Action::Esc("\x1b[5~"), mode: mode::ANY, notmode: mode::NONE },
|
||||
];
|
||||
|
||||
/// Bindings for PageDown
|
||||
static PAGEDOWN_BINDINGS: &'static [Binding] = &[
|
||||
Binding { mods: mods::ANY, action: Action::Esc("\x1b[6~"), mode: mode::ANY, notmode: mode::NONE },
|
||||
];
|
||||
|
||||
/// Bindings for Home
|
||||
static HOME_BINDINGS: &'static [Binding] = &[
|
||||
Binding { mods: mods::ANY, action: Action::Esc("\x1b[H"), mode: mode::ANY, notmode: mode::APP_CURSOR },
|
||||
Binding { mods: mods::ANY, action: Action::Esc("\x1b[1~"), mode: mode::APP_CURSOR, notmode: mode::NONE },
|
||||
];
|
||||
|
||||
/// Bindings for End
|
||||
static END_BINDINGS: &'static [Binding] = &[
|
||||
Binding { mods: mods::ANY, action: Action::Esc("\x1b[F"), mode: mode::ANY, notmode: mode::APP_CURSOR },
|
||||
Binding { mods: mods::ANY, action: Action::Esc("\x1b[4~"), mode: mode::APP_CURSOR, notmode: mode::NONE },
|
||||
];
|
||||
|
||||
/// Bindings for the H key
|
||||
///
|
||||
/// Control-H sends 0x08 normally, but we capture that in ReceivedCharacter
|
||||
|
@ -297,6 +319,10 @@ impl Processor {
|
|||
VirtualKeyCode::F10 => F10_BINDINGS,
|
||||
VirtualKeyCode::F11 => F11_BINDINGS,
|
||||
VirtualKeyCode::F12 => F12_BINDINGS,
|
||||
VirtualKeyCode::PageUp => PAGEUP_BINDINGS,
|
||||
VirtualKeyCode::PageDown => PAGEDOWN_BINDINGS,
|
||||
VirtualKeyCode::Home => HOME_BINDINGS,
|
||||
VirtualKeyCode::End => END_BINDINGS,
|
||||
VirtualKeyCode::Back => BACKSPACE_BINDINGS,
|
||||
VirtualKeyCode::Delete => DELETE_BINDINGS,
|
||||
VirtualKeyCode::H => H_BINDINGS,
|
||||
|
@ -346,6 +372,7 @@ impl Processor {
|
|||
// Modifier keys
|
||||
if binding.mods.is_all() || mods == binding.mods {
|
||||
// everything matches; run the binding action
|
||||
println!("{:?}", binding);
|
||||
match binding.action {
|
||||
Action::Esc(s) => notifier.notify(s.as_bytes()),
|
||||
Action::Paste => {
|
||||
|
|
Loading…
Reference in a new issue