Skip to content
Open
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
5 changes: 3 additions & 2 deletions crates/edit/src/bin/edit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ impl Drop for RestoreModes {
// Same as in the beginning but in the reverse order.
// It also includes DECSCUSR 0 to reset the cursor style and DECTCEM to show the cursor.
// We specifically don't reset mode 1036, because most applications expect it to be set nowadays.
sys::write_stdout("\x1b[0 q\x1b[?25h\x1b]0;\x07\x1b[?1002;1006;2004l\x1b[?1049l");
sys::write_stdout("\x1b[<u\x1b[0 q\x1b[?25h\x1b]0;\x07\x1b[?1002;1006;2004l\x1b[?1049l");
}
}

Expand All @@ -576,7 +576,8 @@ fn setup_terminal(tui: &mut Tui, state: &mut State, vt_parser: &mut vt::Parser)
// 1006: SGR Mouse Mode
// 2004: Bracketed Paste Mode
// 1036: Xterm: "meta sends escape" (Alt keypresses should be encoded with ESC + char)
"\x1b[?1049h\x1b[?1002;1006;2004h\x1b[?1036h",
// CSI u: Kitty Keyboard Protocol: Push Disambiguate escape codes flag
"\x1b[?1049h\x1b[?1002;1006;2004h\x1b[?1036h\x1b[>1u",
// OSC 4 color table requests for indices 0 through 15 (base colors).
"\x1b]4;0;?;1;?;2;?;3;?;4;?;5;?;6;?;7;?\x07",
"\x1b]4;8;?;9;?;10;?;11;?;12;?;13;?;14;?;15;?\x07",
Expand Down
67 changes: 67 additions & 0 deletions crates/edit/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,73 @@ impl<'input> Iterator for Stream<'_, '_, 'input> {
let height = (csi.params[1] as CoordType).clamp(1, 32767);
return Some(Input::Resize(Size { width, height }));
}
'u' => {
// Kitty keyboard events
let key = match csi.params[0] {
97 ..= 122 => Some(InputKey::new(csi.params[0] as u32 & !0x20)), // Shift a-z to A-Z
127 => Some(vk::BACK),

// F13-F24
57376 => Some(vk::F13),
57377 => Some(vk::F14),
57378 => Some(vk::F15),
57379 => Some(vk::F16),
57380 => Some(vk::F17),
57381 => Some(vk::F18),
57382 => Some(vk::F19),
57383 => Some(vk::F20),
57384 => Some(vk::F21),
57385 => Some(vk::F22),
57386 => Some(vk::F23),
57387 => Some(vk::F24),
57388 ..= 57398 => None, // Ignore F25-F35

// Number pad keys
57399 => Some(vk::NUMPAD0),
57400 => Some(vk::NUMPAD1),
57401 => Some(vk::NUMPAD2),
57402 => Some(vk::NUMPAD3),
57403 => Some(vk::NUMPAD4),
57404 => Some(vk::NUMPAD5),
57405 => Some(vk::NUMPAD6),
57406 => Some(vk::NUMPAD7),
57407 => Some(vk::NUMPAD8),
57408 => Some(vk::NUMPAD9),
57409 => Some(vk::DECIMAL),
57410 => Some(vk::DIVIDE),
57411 => Some(vk::MULTIPLY),
57412 => Some(vk::SUBTRACT),
57413 => Some(vk::ADD),
57414 => Some(vk::RETURN),
57415 => Some(InputKey::new('=' as u32)),
57416 => Some(vk::SEPARATOR),
57417 => Some(vk::LEFT),
57418 => Some(vk::RIGHT),
57419 => Some(vk::UP),
57420 => Some(vk::DOWN),
57421 => Some(vk::PRIOR),
57422 => Some(vk::NEXT),
57423 => Some(vk::HOME),
57424 => Some(vk::END),
57425 => Some(vk::INSERT),
57426 => Some(vk::DELETE),

// Keys to Ignore
57358 => None, // Caps Lock
57359 => None, // Scroll Lock
57360 => None, // Num Lock
57361 => None, // Print Screen
57362 => None, // Pause
57363 => None, // Menu
57428 ..= 57440 => None, // Media and Volume
57441 ..= 57454 => None, // Left/Right Modifiers

_ => Some(InputKey::new(csi.params[0] as u32)),
}?;
return Some(Input::Keyboard(
key | Self::parse_modifiers(csi),
));
}
_ => {}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/edit/src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2723,6 +2723,7 @@ impl<'a> Context<'a, '_> {
},
vk::C => match modifiers {
kbmod::CTRL => tb.copy(self.clipboard_mut()),
kbmod::CTRL_SHIFT => tb.copy(self.clipboard_mut()),
_ => return false,
},
vk::V => match modifiers {
Expand Down