R4.11: real-window acceptance; shifted keys bind their characters
A real keyboard reports Shift plus punctuation as the character on every platform, so the Windows key-name bindings never fired. Windows also keeps Ctrl+Shift+0 for Chinese input; Actual Size adds Ctrl+Shift+9. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
65514599fe
commit
4460fd35a6
8 files changed
+72
-34
No files matched your search
@@ -50,14 +50,6 @@ actions!(
|
||||
]
|
||||
);
|
||||
|
||||
/// Shift with punctuation: Windows names the key, others the character.
|
||||
pub(crate) fn shifted(mods: &str, key: char, typed: char) -> String {
|
||||
match cfg!(target_os = "windows") {
|
||||
true => format!("{mods}-shift-{key}"),
|
||||
false => format!("{mods}-{typed}"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bind(cx: &mut App) {
|
||||
let at = Some(commands::CONTEXT);
|
||||
cx.bind_keys([
|
||||
@@ -73,14 +65,14 @@ pub fn bind(cx: &mut App) {
|
||||
KeyBinding::new("secondary-shift-m", MathBlock, at),
|
||||
KeyBinding::new("secondary-shift-k", CodeFences, at),
|
||||
KeyBinding::new("secondary-shift-q", Quote, at),
|
||||
KeyBinding::new(&shifted("secondary", '[', '{'), OrderedList, at),
|
||||
KeyBinding::new(&shifted("secondary", ']', '}'), BulletList, at),
|
||||
KeyBinding::new("secondary-{", OrderedList, at),
|
||||
KeyBinding::new("secondary-}", BulletList, at),
|
||||
KeyBinding::new("secondary-shift-x", TaskList, at),
|
||||
KeyBinding::new("secondary-b", Strong, at),
|
||||
KeyBinding::new("secondary-i", Emphasis, at),
|
||||
KeyBinding::new("secondary-u", Underline, at),
|
||||
KeyBinding::new(&shifted("secondary", '`', '~'), InlineCode, at),
|
||||
KeyBinding::new(&shifted("alt", '5', '%'), Strike, at),
|
||||
KeyBinding::new("secondary-~", InlineCode, at),
|
||||
KeyBinding::new("alt-%", Strike, at),
|
||||
KeyBinding::new("secondary-k", Hyperlink, at),
|
||||
KeyBinding::new("secondary-shift-i", InsertImage, at),
|
||||
KeyBinding::new("secondary-\\", ClearFormat, at),
|
||||
|
||||
@@ -6,7 +6,6 @@ use gpui::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
blocks::shifted,
|
||||
desk::{
|
||||
Desk,
|
||||
tests::{open, start},
|
||||
@@ -83,9 +82,9 @@ fn paragraph_keys_retype_the_caret_block(cx: &mut TestAppContext) {
|
||||
assert_eq!(current(&desk, cx), "# Intro\n");
|
||||
press("secondary-0", cx);
|
||||
assert_eq!(current(&desk, cx), "Intro\n");
|
||||
press(&shifted("secondary", '[', '{'), cx);
|
||||
press("secondary-{", cx);
|
||||
assert_eq!(current(&desk, cx), "1. Intro\n");
|
||||
press(&shifted("secondary", ']', '}'), cx);
|
||||
press("secondary-}", cx);
|
||||
assert_eq!(current(&desk, cx), "- Intro\n");
|
||||
press("secondary-shift-q", cx);
|
||||
assert_eq!(
|
||||
@@ -102,7 +101,7 @@ fn format_keys_wrap_the_caret_word(cx: &mut TestAppContext) {
|
||||
assert_eq!(current(&desk, cx), "**word**\n");
|
||||
press("secondary-\\", cx);
|
||||
assert_eq!(current(&desk, cx), "word\n");
|
||||
press(&shifted("alt", '5', '%'), cx);
|
||||
press("alt-%", cx);
|
||||
assert_eq!(current(&desk, cx), "~~word~~\n");
|
||||
}
|
||||
|
||||
@@ -144,10 +143,10 @@ fn alt_arrows_move_a_table_row(cx: &mut TestAppContext) {
|
||||
#[gpui::test]
|
||||
fn view_keys_follow_typora(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("a\n", cx);
|
||||
press(&format!("f8 f9 {}", shifted("secondary", '=', '+')), cx);
|
||||
press("f8 f9 secondary-+", cx);
|
||||
let look = desk.read_with(cx, |desk, _| desk.look.clone());
|
||||
assert!(look.focus && look.typewriter && look.size > 100, "{look:?}");
|
||||
press(&shifted("secondary", '0', ')'), cx);
|
||||
press("secondary-)", cx);
|
||||
assert_eq!(desk.read_with(cx, |desk, _| desk.look.size), 100);
|
||||
}
|
||||
|
||||
@@ -284,14 +283,14 @@ fn every_command_takes_typoras_windows_key(cx: &mut TestAppContext) {
|
||||
(&MathBlock, "ctrl-shift-m"),
|
||||
(&CodeFences, "ctrl-shift-k"),
|
||||
(&Quote, "ctrl-shift-q"),
|
||||
(&OrderedList, "ctrl-shift-["),
|
||||
(&BulletList, "ctrl-shift-]"),
|
||||
(&OrderedList, "ctrl-{"),
|
||||
(&BulletList, "ctrl-}"),
|
||||
(&TaskList, "ctrl-shift-x"),
|
||||
(&Strong, "ctrl-b"),
|
||||
(&Emphasis, "ctrl-i"),
|
||||
(&Underline, "ctrl-u"),
|
||||
(&InlineCode, "ctrl-shift-`"),
|
||||
(&Strike, "alt-shift-5"),
|
||||
(&InlineCode, "ctrl-~"),
|
||||
(&Strike, "alt-%"),
|
||||
(&Hyperlink, "ctrl-k"),
|
||||
(&InsertImage, "ctrl-shift-i"),
|
||||
(&ClearFormat, "ctrl-\\"),
|
||||
@@ -305,9 +304,9 @@ fn every_command_takes_typoras_windows_key(cx: &mut TestAppContext) {
|
||||
(&ToggleSource, "ctrl-/"),
|
||||
(&look::FocusMode, "f8"),
|
||||
(&look::Typewriter, "f9"),
|
||||
(&look::Larger, "ctrl-shift-="),
|
||||
(&look::Smaller, "ctrl-shift--"),
|
||||
(&look::ActualSize, "ctrl-shift-0"),
|
||||
(&look::Larger, "ctrl-+"),
|
||||
(&look::Smaller, "ctrl-_"),
|
||||
(&look::ActualSize, "ctrl-("),
|
||||
(&CopyMarkdown, "ctrl-shift-c"),
|
||||
(&PastePlain, "ctrl-shift-v"),
|
||||
];
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use ely_ui::{commands, i18n::text};
|
||||
use gpui::{Action, App, Context, InteractiveElement as _, KeyBinding, Menu, MenuItem, actions};
|
||||
|
||||
use crate::{blocks::shifted, desk::Desk, view::Mode};
|
||||
use crate::{desk::Desk, view::Mode};
|
||||
|
||||
actions!(
|
||||
mark,
|
||||
@@ -18,11 +18,14 @@ pub fn bind(cx: &mut App) {
|
||||
KeyBinding::new("secondary-/", ToggleSource, Some("ElyEditor")),
|
||||
KeyBinding::new("f8", crate::look::FocusMode, at),
|
||||
KeyBinding::new("f9", crate::look::Typewriter, at),
|
||||
KeyBinding::new(&shifted("secondary", '=', '+'), crate::look::Larger, at),
|
||||
KeyBinding::new(&shifted("secondary", '-', '_'), crate::look::Smaller, at),
|
||||
KeyBinding::new(&shifted("secondary", '0', ')'), crate::look::ActualSize, at),
|
||||
KeyBinding::new("secondary-+", crate::look::Larger, at),
|
||||
KeyBinding::new("secondary-_", crate::look::Smaller, at),
|
||||
KeyBinding::new("secondary-)", crate::look::ActualSize, at),
|
||||
KeyBinding::new("secondary-f", ely_office::FindReplace, at),
|
||||
]);
|
||||
// Windows' Chinese input keeps Ctrl+Shift+0 for itself.
|
||||
#[cfg(target_os = "windows")]
|
||||
cx.bind_keys([KeyBinding::new("ctrl-(", crate::look::ActualSize, at)]);
|
||||
crate::blocks::bind(cx);
|
||||
crate::tools::bind(cx);
|
||||
crate::clip::bind(cx);
|
||||
|
||||
Reference in new issue
Block a user