diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index 77b9e581d9..aa5b0e8d00 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -122,6 +122,12 @@ impl Session { self.tool.id() } + /// The selection tool chosen last (Selection, Direct Selection or Group Selection), which + /// `tool.selectLastSelection` chooses: the Selection tool until one is chosen. + pub fn last_selection_tool(&self) -> &'static str { + self.last_selection_tool.unwrap_or("selection") + } + /// How many times switching or closing documents, or replacing the active one (File › Revert), /// has started the tool afresh, also inside a `command.batch` or `action.batch`. A frontend /// compares it before and after a command. diff --git a/crates/mcp/src/headless.rs b/crates/mcp/src/headless.rs index 9bae531706..cbd2e8ca87 100644 --- a/crates/mcp/src/headless.rs +++ b/crates/mcp/src/headless.rs @@ -45,6 +45,11 @@ const HOST_COMMANDS: &[(&str, &str, &str)] = &[ "{folder?, zip?, artboards? | range? | fullDocument? | assets?, includeBleed?, includeArtboardFill?, subfolders?, preset?, formats?, settings?, prefix?} = document.exportForScreens (no folder → the files, or one zip, as dataBase64)", ), ("tool.select", "Select Tool", "{tool} e.g. selection, directSelection, pen, rectangle, ellipse, polygon, star, lineSegment"), + ( + "tool.selectLastSelection", + "Select Last Selection Tool", + "{} choose the selection tool chosen last (Selection, Direct Selection or Group Selection; none yet: the Selection tool) → {tool}", + ), ( "tool.setOption", "Tool Option", @@ -165,6 +170,7 @@ impl Headless { "file.export" => self.export(params), "file.exportForScreens" => self.session.execute("document.exportForScreens", params).map_err(|e| e.to_string()), "tool.select" => self.select_tool(params), + "tool.selectLastSelection" => self.select_last_selection_tool(), "tool.setOption" => self.session.set_tool_option_cmd(params), _ => self.session.execute(id, params).map_err(|e| e.to_string()), } @@ -208,6 +214,15 @@ impl Headless { Ok(json!({"tool": self.session.tool_id()})) } + /// `tool.selectLastSelection`: the selection tool chosen last, kept when it is already active. + fn select_last_selection_tool(&mut self) -> Result { + let id = self.session.last_selection_tool(); + if self.session.tool_id() != id { + self.session.select_tool(id, self.view).map_err(|e| e.to_string())?; + } + Ok(json!({"tool": self.session.tool_id()})) + } + fn apply_ui_requests(&mut self, reqs: Vec, out: &mut Vec) -> Result<(), String> { for r in reqs { match r { diff --git a/crates/mcp/src/tests.rs b/crates/mcp/src/tests.rs index aa2cbb69d7..7aba7acc78 100644 --- a/crates/mcp/src/tests.rs +++ b/crates/mcp/src/tests.rs @@ -1894,6 +1894,30 @@ fn e_during_a_marquee_gesture_selects_only_the_objects_inside() { assert_eq!(serde_json::from_str::(&text_of(&r)).unwrap()["handledBy"], "tool.select", "{r}"); } +/// `run_command tool.selectLastSelection` headless: the Selection tool before any selection tool +/// is chosen, then the selection tool chosen last; Magic Wand doesn't count. `list_commands` +/// lists it as a command the headless backend runs. +#[test] +fn select_last_selection_tool_runs_headless() { + let mut s = server(); + let mut id = 0; + let mut run = |s: &mut Server, command: &str, params: Value| { + id += 1; + let r = call(s, id, "run_command", json!({"command": command, "params": params})); + assert_eq!(r["isError"], false, "{command}: {r}"); + serde_json::from_str::(&text_of(&r)).unwrap() + }; + run(&mut s, "tool.select", json!({"tool": "pen"})); + assert_eq!(run(&mut s, "tool.selectLastSelection", json!({})), json!({"tool": "selection"})); + run(&mut s, "tool.select", json!({"tool": "groupSelection"})); + run(&mut s, "tool.select", json!({"tool": "magicWand"})); + assert_eq!(run(&mut s, "tool.selectLastSelection", json!({})), json!({"tool": "groupSelection"})); + let r = call(&mut s, 99, "list_commands", json!({"filter": "selectLastSelection"})); + let v: Value = serde_json::from_str(&text_of(&r)).unwrap(); + let listed = v["commands"].as_array().unwrap().iter().find(|c| c["id"] == "tool.selectLastSelection").cloned().unwrap_or_default(); + assert_eq!((listed["host"].clone(), listed["label"].clone()), (json!(true), json!("Select Last Selection Tool")), "{v}"); +} + /// `press_key {key: "c"}` and `{key: "f"}` while an arc is being dragged go to the Arc tool, and /// the release draws one arc. With nothing dragged, C is a shortcut again. #[test] diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index f1fa07a245..152c1c5462 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -836,6 +836,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "{} make the open document before the current one in tab order the current one, as a click on its tab does (before the first document it goes to the last, and from the Home screen to the last); each view window.newWindow opened is a step of its own; returns {index}, with `view` for a document with more than one view", ), ("tool.select", "Select Tool", "", "{tool: id} (see tools) → {tool}; a tool that cannot be chosen returns the error"), + ( + "tool.selectLastSelection", + "Select Last Selection Tool", + "Cmd+~", + "{} choose the selection tool chosen last (Selection, Direct Selection or Group Selection; none yet: the Selection tool), keeping the active tool when it is that tool; choosing Magic Wand, Lasso or any other tool does not change which one it chooses → {tool}. Default shortcut Ctrl+` on Windows and Linux, none on macOS, where Cmd+` switches windows", + ), ( "tool.setOption", "Tool Option", diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 16fba08a7a..3f8cc4a661 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -1647,6 +1647,37 @@ fn switch_selection_and_drawing_modes_command() { } } +/// Select Last Selection Tool: the Selection tool before any selection tool is chosen, then the +/// one of Selection, Direct Selection and Group Selection chosen last; Magic Wand and Lasso don't +/// count. Running it again keeps that tool, and it changes no art, selection or undo history. +#[test] +fn select_last_selection_tool_command() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let id = app.session.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 50, "height": 40})).unwrap()["id"].clone(); + app.session.execute("select.set", &json!({"ids": [id]})).unwrap(); + let last = |app: &mut VectorcraftApp| app.run("tool.selectLastSelection", json!({})).unwrap(); + let state = |app: &VectorcraftApp| { + let st = app.session.active().unwrap(); + (st.doc.clone(), st.selection.clone(), st.history.undo.len()) + }; + app.select_tool("pen"); + let before = state(&app); + assert_eq!((last(&mut app), app.session.tool_id()), (json!({"tool": "selection"}), "selection"), "none chosen yet: Selection"); + for id in ["directSelection", "groupSelection", "selection"] { + app.select_tool(id); + app.select_tool("pen"); + assert_eq!(last(&mut app), json!({"tool": id}), "{id}"); + } + app.select_tool("directSelection"); + for other in ["magicWand", "lasso", "rectangle", "hand"] { + app.select_tool(other); + } + assert_eq!(last(&mut app), json!({"tool": "directSelection"}), "Magic Wand and Lasso are not remembered"); + assert_eq!(last(&mut app), json!({"tool": "directSelection"}), "again: the same tool, no cycling"); + assert!(state(&app) == before, "no art, selection or undo step changes"); +} + /// A Switch Selection and Drawing Modes whose tool choice fails returns the error, in both /// directions: the tool stays, the drawing tool to return to stays, and no undo step is added. #[test] diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index a2c29fadc4..3e26ff37ec 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -240,6 +240,7 @@ fn wrap(r: Result) -> Outcome { pub fn all_commands(app: &VectorcraftApp) -> Value { let mut v: Vec = app.session.commands().into_iter().map(|c| serde_json::to_value(c).unwrap_or_default()).collect(); for (id, label, sc, params) in crate::menus::UI_COMMANDS { + let sc = crate::shortcut_editor::ui_command_default(id, sc, crate::keymap::platform()); v.push(json!({"id": id, "label": label, "shortcut": sc, "params": params, "enabled": crate::menus::enabled(app, id), "ui": true})); } Value::Array(v) diff --git a/crates/ui-egui/src/control/tests.rs b/crates/ui-egui/src/control/tests.rs index 7aa73e8a7e..96c4880d39 100644 --- a/crates/ui-egui/src/control/tests.rs +++ b/crates/ui-egui/src/control/tests.rs @@ -1426,3 +1426,19 @@ fn dialog_set_refuses_a_field_the_dialog_does_not_have() { app.ui.dialog = None; assert_eq!(input_request(&mut app, "ui.dialog.set", json!({"field": "name", "value": "A"}))["error"], "no dialog open"); } + +/// `engine.commands` lists each UI command's default shortcut on this platform: Select Last +/// Selection Tool shows Ctrl+` (`Cmd+~`) on Windows and Linux and none on macOS. +#[test] +fn the_command_list_shows_this_platforms_default_shortcut() { + let mut app = VectorcraftApp::new(Session::new(), Services::default()); + let r = input_request(&mut app, "engine.commands", json!({})); + let row = r["result"].as_array().unwrap().iter().find(|c| c["id"] == "tool.selectLastSelection").cloned(); + let row = row.unwrap_or_else(|| panic!("listed: {r}")); + assert_eq!(row["shortcut"], if crate::keymap::platform().is_mac() { "" } else { "Cmd+~" }, "{row}"); + for p in [craft_keymap::Platform::Windows, craft_keymap::Platform::Linux] { + assert_eq!(crate::shortcut_editor::ui_command_default("tool.selectLastSelection", "Cmd+~", p), "Cmd+~", "{p:?}"); + } + assert_eq!(crate::shortcut_editor::ui_command_default("tool.selectLastSelection", "Cmd+~", craft_keymap::Platform::Mac), ""); + assert_eq!(crate::shortcut_editor::ui_command_default("view.zoomIn", "Cmd+=", craft_keymap::Platform::Mac), "Cmd+="); +} diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index beec340325..eb95d21db1 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -1044,6 +1044,7 @@ font-technology Variable Променливи Enable text access for screen readers Разрешаване на достъп до текст за екранни четци Enable Touch Gestures Разрешаване на докосващи жестове Switch Selection and Drawing Modes Превключване между режим на селекция и рисуване + Select Last Selection Tool Избор на последния инструмент за селекция Enable Touch Workspace Разрешаване на работно пространство за докосване Encoding Кодиране Encoding: Кодиране: diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index d6f64b51f2..435ee0683b 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -3943,6 +3943,7 @@ theme Appearance Izgled Enable Rubber Band for Omogući gumenu traku za Enable Touch Gestures Omogući pokrete dodirom Switch Selection and Drawing Modes Prebaci između načina odabira i crtanja + Select Last Selection Tool Odaberi posljednji alat za odabir Enable Touch Workspace Omogući radni prostor za dodir English: UK Engleski: UK Every (minutes) Svakih (minuta) diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index fb203a2e2d..638fa9a01d 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -1525,6 +1525,7 @@ antiAlias Sharp Nítid Enable text access for screen readers Activa l’accés al text per als lectors de pantalla Enable Touch Gestures Activa els gestos tàctils Switch Selection and Drawing Modes Canvia entre els modes de selecció i de dibuix + Select Last Selection Tool Tria l'última eina de selecció Enable Touch Workspace Activa l’espai de treball tàctil Encoding Codificació Encoding and writing the file… S’està codificant i escrivint el fitxer… diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 4a4dea6a64..4e24be7305 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -4043,6 +4043,7 @@ theme Appearance Motiv Enable Rubber Band for Povolit gumovou čáru pro Enable Touch Gestures Povolit dotyková gesta Switch Selection and Drawing Modes Přepnout mezi režimem výběru a kreslení + Select Last Selection Tool Vybrat poslední nástroj výběru Enable Touch Workspace Povolit dotykový pracovní prostor English: UK Angličtina: Spojené království Every (minutes) Každých (minut) diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index a322cd9ec4..14909108c5 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -6470,6 +6470,7 @@ theme Appearance Udseende Enable Rubber Band for Aktivér gummibånd for Enable Touch Gestures Aktivér berøringsbevægelser Switch Selection and Drawing Modes Skift mellem markerings- og tegnetilstand + Select Last Selection Tool Vælg det seneste markeringsværktøj Enable Touch Workspace Aktivér touch-arbejdsområde English: UK Engelsk: UK Every (minutes) Hvert (minut) diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index d94d533c22..e3934c9162 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -1055,6 +1055,7 @@ font-technology Variable Variabel Enable text access for screen readers Textzugriff für Bildschirmlesegeräte zulassen Enable Touch Gestures Touch-Gesten aktivieren Switch Selection and Drawing Modes Zwischen Auswahl- und Zeichenmodus wechseln + Select Last Selection Tool Zuletzt verwendetes Auswahl-Werkzeug wählen Enable Touch Workspace Touch-Arbeitsbereich aktivieren Encoding Kodierung Encoding: Kodierung: diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 4db2c9477e..be33c1dd48 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -1021,6 +1021,7 @@ font-technology Variable Μεταβλητές Enable text access for screen readers Ενεργοποίηση πρόσβασης κειμένου για αναγνώστες οθόνης Enable Touch Gestures Ενεργοποίηση χειρονομιών αφής Switch Selection and Drawing Modes Εναλλαγή λειτουργιών επιλογής και σχεδίασης + Select Last Selection Tool Επιλογή του τελευταίου εργαλείου επιλογής Enable Touch Workspace Ενεργοποίηση χώρου εργασίας αφής Encoding Κωδικοποίηση Encoding: Κωδικοποίηση: diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 1d968bbba4..38b031471a 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -1078,6 +1078,7 @@ font-technology Variable Variables Enable text access for screen readers Permitir el acceso al texto para lectores de pantalla Enable Touch Gestures Activar gestos táctiles Switch Selection and Drawing Modes Cambiar entre modos de selección y dibujo + Select Last Selection Tool Elegir la última herramienta de selección Enable Touch Workspace Activar espacio de trabajo táctil Encoding Codificación Encoding: Codificación: diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 11d0351fc2..c33e809e2a 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -3981,6 +3981,7 @@ theme Appearance Ulkoasu Enable Rubber Band for Ota kumilankavalinta käyttöön kohteelle Enable Touch Gestures Ota kosketuseleet käyttöön Switch Selection and Drawing Modes Vaihda valinta- ja piirtotilan välillä + Select Last Selection Tool Valitse viimeksi käytetty valintatyökalu Enable Touch Workspace Ota kosketustyötila käyttöön English: UK Englanti: UK Every (minutes) Välein (minuuttia) diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index a2db90864a..fffd46a40b 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -1069,6 +1069,7 @@ font-technology Variable Variables Enable text access for screen readers Autoriser l’accès au texte pour les lecteurs d’écran Enable Touch Gestures Activer les gestes tactiles Switch Selection and Drawing Modes Basculer entre les modes sélection et dessin + Select Last Selection Tool Choisir le dernier outil de sélection Enable Touch Workspace Activer l’espace de travail tactile Encoding Codage Encoding: Codage : diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 9a8a2a178e..b37c39d584 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -1701,6 +1701,7 @@ antiAlias Sharp शार्प Enable text access for screen readers स्क्रीन रीडर के लिए टेक्स्ट एक्सेस सक्षम करें Enable Touch Gestures टच जेस्चर ऑन करें Switch Selection and Drawing Modes चयन और ड्रॉइंग मोड के बीच बदलें + Select Last Selection Tool पिछला सिलेक्शन टूल चुनें Enable Touch Workspace टच वर्कस्पेस सक्षम करें Enclosing Lasso लासो संलग्न करना Enclosing Lasso Tool लासो टूल संलग्न करना diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 72286810af..9537655bf9 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -1361,6 +1361,7 @@ font-technology Variable Változó Enable text access for screen readers Szöveghozzáférés engedélyezése képernyőolvasóknak Enable Touch Gestures Érintési kézmozdulatok Switch Selection and Drawing Modes Váltás a kijelölési és a rajzolási mód között + Select Last Selection Tool Az utoljára használt kijelölőeszköz kiválasztása Enable Touch Workspace Érintőképernyős munkaterület Encoding Kódolás Encoding: Kódolás: diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 8a29f2c67d..d7effedaa4 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3719,6 +3719,7 @@ theme Appearance Tampilan Enable Rubber Band for Aktifkan rubber band untuk Enable Touch Gestures Aktifkan gestur sentuh Switch Selection and Drawing Modes Beralih antara mode seleksi dan menggambar + Select Last Selection Tool Pilih alat seleksi terakhir Enable Touch Workspace Aktifkan ruang kerja sentuh English: UK Inggris: UK Every (minutes) Setiap (menit) diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index ef5dea5c9b..9ccac81cdb 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -1089,6 +1089,7 @@ font-technology Variable Variabili Enable text access for screen readers Consenti l'accesso al testo per le utilità di lettura dello schermo Enable Touch Gestures Attiva gesti touch Switch Selection and Drawing Modes Passa tra modalità selezione e disegno + Select Last Selection Tool Scegli l'ultimo strumento di selezione Enable Touch Workspace Attiva area di lavoro touch Encoding Codifica Encoding: Codifica: diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 8b1228c575..f77564e19d 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -1702,6 +1702,7 @@ antiAlias Sharp シャープ Enable Rubber Band for ラバーバンドを有効にする対象 Enable Touch Gestures タッチジェスチャーを有効にする Switch Selection and Drawing Modes 選択モードと描画モードを切り替え + Select Last Selection Tool 最後に使用した選択ツールに切り替え Enable Touch Workspace タッチワークスペースを有効にする Enable copying of text, images and other content テキスト、イメージ、その他のコンテンツのコピーを許可 Enable in-menu font previews メニュー内でフォントプレビューを有効にする diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 7faaf49927..9c393c6868 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -5811,6 +5811,7 @@ theme Appearance იერსახე Enable Rubber Band for რეზინის ზოლის ჩართვა: Enable Touch Gestures შეხების ჟესტების ჩართვა Switch Selection and Drawing Modes მონიშვნისა და ხატვის რეჟიმების გადართვა + Select Last Selection Tool ბოლოს გამოყენებული მონიშვნის ხელსაწყოს არჩევა Enable Touch Workspace სენსორული სამუშაო სივრცის ჩართვა English: UK ინგლისური: ბრიტანეთი Every (minutes) ყოველ (წუთში) diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index dd85cb5826..a253214c7d 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -1692,6 +1692,7 @@ antiAlias Sharp 날카롭게 Enable Rubber Band for 러버 밴드 사용 대상 Enable Touch Gestures 터치 제스처 사용 Switch Selection and Drawing Modes 선택 모드와 그리기 모드 전환 + Select Last Selection Tool 마지막으로 사용한 선택 도구로 전환 Enable Touch Workspace 터치 작업 영역 사용 Enable copying of text, images and other content 텍스트, 이미지 및 기타 콘텐츠 복사 허용 Enable in-menu font previews 메뉴에서 글꼴 미리 보기 사용 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index d05b2ca897..760b4d5729 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -4341,6 +4341,7 @@ theme Appearance Vormgeving Enable Rubber Band for Rubberband inschakelen voor Enable Touch Gestures Touchgebaren inschakelen Switch Selection and Drawing Modes Wisselen tussen selectie- en tekenmodus + Select Last Selection Tool Laatst gebruikte selectiegereedschap kiezen Enable Touch Workspace Touch-werkruimte inschakelen English: UK Engels: VK Every (minutes) Elke (minuten) diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index c47971daac..aae6327cf7 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3920,6 +3920,7 @@ theme Appearance Wygląd Enable Rubber Band for Włącz gumkę podglądu dla Enable Touch Gestures Włącz gesty dotykowe Switch Selection and Drawing Modes Przełącz tryby zaznaczania i rysowania + Select Last Selection Tool Wybierz ostatnie narzędzie zaznaczania Enable Touch Workspace Włącz dotykowy obszar roboczy English: UK Angielski: Wielka Brytania Every (minutes) Co (minuty) diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 572e154274..8906e86813 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -966,6 +966,7 @@ antiAlias Sharp Nítido Enable Rubber Band for Habilitar Elástico para Enable Touch Gestures Habilitar Gestos de Toque Switch Selection and Drawing Modes Alternar Modos de Seleção e Desenho + Select Last Selection Tool Selecionar Última Ferramenta de Seleção Enable Touch Workspace Habilitar Espaço de Trabalho de Toque Enable copying of text, images and other content Habilitar cópia de texto, imagens e outro conteúdo Enable in-menu font previews Habilitar visualizações de fonte no menu diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 7b8e8d8da5..ff871df842 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -1076,6 +1076,7 @@ font-technology Variable Вариативные Enable text access for screen readers Разрешить доступ к тексту для программ чтения с экрана Enable Touch Gestures Включить сенсорные жесты Switch Selection and Drawing Modes Переключить режимы выделения и рисования + Select Last Selection Tool Выбрать последний инструмент выделения Enable Touch Workspace Включить сенсорную рабочую среду Encoding Кодировка Encoding: Кодировка: diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 8b8389debd..0289b173e6 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -1053,6 +1053,7 @@ font-technology Variable Variabla Enable text access for screen readers Ge skärmläsare åtkomst till text Enable Touch Gestures Aktivera pekgester Switch Selection and Drawing Modes Växla mellan markerings- och ritläge + Select Last Selection Tool Välj det senaste markeringsverktyget Enable Touch Workspace Aktivera arbetslayout för pekskärm Encoding Kodning Encoding: Kodning: diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 58446fdf3f..3bfd2d8b61 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -1045,6 +1045,7 @@ font-technology Variable Değişken Enable text access for screen readers Ekran okuyucular için metin erişimini etkinleştirin Enable Touch Gestures Dokunma Hareketlerini Etkinleştir Switch Selection and Drawing Modes Seçim ve Çizim Modları Arasında Geçiş Yap + Select Last Selection Tool Son Kullanılan Seçim Aracını Seç Enable Touch Workspace Dokunmatik Çalışma Alanını Etkinleştir Encoding Kodlama Encoding: Kodlama: diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index a547f9c2d3..b4791c460f 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -1083,6 +1083,7 @@ font-technology Variable Варіативні Enable text access for screen readers Дозволити доступ до тексту для програм читання з екрану Enable Touch Gestures Увімкнути сенсорні жести Switch Selection and Drawing Modes Перемкнути режими виділення та малювання + Select Last Selection Tool Вибрати останній інструмент виділення Enable Touch Workspace Включити сенсорне робоче середовище Encoding Кодування Encoding: Кодування: diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 849e6773fa..7a99dd59a9 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -1253,6 +1253,7 @@ font-technology Variable Biến thiên Enable text access for screen readers Bật truy cập văn bản cho trình đọc màn hình Enable Touch Gestures Bật cử chỉ cảm ứng Switch Selection and Drawing Modes Chuyển giữa chế độ chọn và vẽ + Select Last Selection Tool Chọn công cụ chọn dùng gần nhất Enable Touch Workspace Bật không gian làm việc cảm ứng Encoding Mã hóa Encoding: Mã hóa: diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index e7087fec09..7cadacf3ef 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -1020,6 +1020,7 @@ antiAlias Sharp 锐利 Enable text access for screen readers 启用屏幕阅读器的文字访问 Enable Touch Gestures 启用触控手势 Switch Selection and Drawing Modes 切换选择与绘图模式 + Select Last Selection Tool 切换到上次使用的选择工具 Enable Touch Workspace 启用触控工作区 Encoding 编码 Encoding: 编码: diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 5d67aea4dc..2b9196ef8c 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -1051,6 +1051,7 @@ font-technology Variable 可變 Enable text access for screen readers 啟用螢幕閱讀器的文字存取 Enable Touch Gestures 啟用觸控手勢 Switch Selection and Drawing Modes 切換選取與繪圖模式 + Select Last Selection Tool 切換到上次使用的選取工具 Enable Touch Workspace 啟用觸控工作區 Encoding 編碼 Encoding: 編碼: diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs index d32ae53d5d..79e53edfdd 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -216,7 +216,7 @@ fn catalogue(snapshot: &Snapshot, p: Platform) -> Vec { if TOGGLES.contains(&e.key.as_str()) { b = b.toggle(); } - if let Some(d) = shortcut_editor::default_of(&e.key).and_then(vc_binding) { + if let Some(d) = shortcut_editor::default_on(&e.key, p).and_then(vc_binding) { b = b.with_default(d); } for alias in default_aliases(&e.key, p) { @@ -639,6 +639,26 @@ mod tests { } } + /// Select Last Selection Tool is Ctrl+` on Windows and Linux. macOS takes Cmd+` to switch + /// between an app's windows, so there the command has no default and takes a chord the user + /// assigns. + #[test] + fn last_selection_tool_default_follows_the_platform() { + let snapshot = shortcut_editor::snapshot(); + let command = command_of("tool.selectLastSelection"); + let chord = vc_chord("Cmd+~").unwrap(); + for p in [Platform::Windows, Platform::Linux] { + let km = keymap_for(p, &snapshot); + assert_eq!(lookup(&km, &chord), Some(command.clone()), "{p:?}"); + assert_eq!(shortcut_editor::default_on("tool.selectLastSelection", p), Some("Cmd+~"), "{p:?}"); + } + let mut mac = keymap_for(Platform::Mac, &snapshot); + assert_eq!(mac.bindings(&command), vec![], "no default on macOS"); + assert_eq!(shortcut_editor::default_on("tool.selectLastSelection", Platform::Mac), None); + shortcut_editor::assign_in(&mut mac, "tool.selectLastSelection", Some("Alt+~"), true).unwrap(); + assert_eq!(lookup(&mac, &vc_chord("Alt+~").unwrap()), Some(command)); + } + #[test] fn panel_entries_bridge_to_window_panel() { let c = command_of("panel:layers"); diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs index 7fba89ddcb..704fb1ada3 100644 --- a/crates/ui-egui/src/menus/run.rs +++ b/crates/ui-egui/src/menus/run.rs @@ -685,6 +685,11 @@ fn run_ui_part6(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option Err(format!("unknown tool `{t}`")), None => Err("missing `tool`".into()), }, + "tool.selectLastSelection" => { + let id = app.session.last_selection_tool(); + let switched = if app.session.tool_id() == id { Ok(()) } else { app.try_select_tool(id) }; + switched.map(|()| json!({"tool": app.session.tool_id()})) + } crate::touch::TOGGLE_MODE => crate::touch::toggle_mode(app), crate::addons::pathtools::corner::COMMAND => crate::addons::pathtools::corner::open(app), crate::addons::pathtools::shared_edge::COMMAND => crate::addons::pathtools::shared_edge::open(app), diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 58af432625..97f477ebd1 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -837,6 +837,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "{} make the open document before the current one in tab order the current one, as a click on its tab does (before the first document it goes to the last, and from the Home screen to the last); each view window.newWindow opened is a step of its own; returns {index}, with `view` for a document with more than one view", ), ("tool.select", "Select Tool", "", "{tool: id} (see tools) → {tool}; a tool that cannot be chosen returns the error"), + ( + "tool.selectLastSelection", + "Select Last Selection Tool", + "Cmd+~", + "{} choose the selection tool chosen last (Selection, Direct Selection or Group Selection; none yet: the Selection tool), keeping the active tool when it is that tool; choosing Magic Wand, Lasso or any other tool does not change which one it chooses → {tool}. Default shortcut Ctrl+` on Windows and Linux, none on macOS, where Cmd+` switches windows", + ), ( "tool.setOption", "Tool Option", diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index 84c1ff4fa0..7fc38179f4 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -152,12 +152,23 @@ pub fn sync(ui: &UiState) { crate::custom_toolbars::sync(ui); } -/// Registry default shortcut of a command (engine or UI command). +/// Registry default shortcut of a command (engine or UI command) on [`crate::keymap::platform`]. pub fn default_command_shortcut(id: &str) -> Option<&'static str> { + default_command_shortcut_on(id, crate::keymap::platform()) +} + +/// Registry default shortcut of a command on platform `p`. +fn default_command_shortcut_on(id: &str, p: craft_keymap::Platform) -> Option<&'static str> { if let Some(c) = vectorcraft_engine::find_command(id) { return c.shortcut; } - menus::UI_COMMANDS.iter().find(|c| c.0 == id).map(|c| c.2).filter(|s| !s.is_empty()) + menus::UI_COMMANDS.iter().find(|c| c.0 == id).map(|c| ui_command_default(c.0, c.2, p)).filter(|s| !s.is_empty()) +} + +/// The default shortcut `sc` of UI command `id` on platform `p` (empty for none). Select Last +/// Selection Tool has none on macOS, which takes Cmd+` to switch between an app's windows. +pub(crate) fn ui_command_default(id: &str, sc: &'static str, p: craft_keymap::Platform) -> &'static str { + if id == "tool.selectLastSelection" && p.is_mac() { "" } else { sc } } /// Window menu items that show a panel (`window.panel {panel}`) with a default shortcut: (panel @@ -184,15 +195,21 @@ pub const PANEL_SHORTCUTS: &[(&str, &str)] = &[ ("openType", "Cmd+Alt+Shift+T"), ]; -/// Default shortcut of an entry key (`tool:`, `panel:` or a command id). +/// Default shortcut of an entry key (`tool:`, `panel:` or a command id) on +/// [`crate::keymap::platform`]. pub fn default_of(key: &str) -> Option<&'static str> { + default_on(key, crate::keymap::platform()) +} + +/// Default shortcut of an entry key on platform `p`. +pub(crate) fn default_on(key: &str, p: craft_keymap::Platform) -> Option<&'static str> { if let Some(t) = key.strip_prefix("tool:") { return vectorcraft_tools::tool_info(t).and_then(|t| t.shortcut); } - if let Some(p) = key.strip_prefix("panel:") { - return PANEL_SHORTCUTS.iter().find(|(id, _)| *id == p).map(|(_, sc)| *sc); + if let Some(panel) = key.strip_prefix("panel:") { + return PANEL_SHORTCUTS.iter().find(|(id, _)| *id == panel).map(|(_, sc)| *sc); } - default_command_shortcut(key) + default_command_shortcut_on(key, p) } /// Effective shortcut of an entry key, honouring the user's overrides. diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index f78805903a..a74bfd8b4a 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -3394,3 +3394,27 @@ fn artboard_navigation_commands_can_be_given_keys() { frame(&mut app, press(Key::PageUp)); assert_eq!(at(&app), 1, "Page Up goes to the previous artboard"); } + +/// Ctrl+` (Windows and Linux) chooses the selection tool chosen last; macOS gives the command no +/// default key. Edit › Keyboard Shortcuts lists it, and a chord the user assigns runs it. +#[test] +fn ctrl_backtick_chooses_the_last_selection_tool() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 200, "height": 200})).unwrap(); + let mac = crate::keymap::platform().is_mac(); + let list = app.run("shortcuts.list", json!({ "query": "tool.selectLastSelection" })).unwrap(); + let listed = list.as_array().unwrap().iter().find(|e| e["id"] == "tool.selectLastSelection").cloned(); + let listed = listed.unwrap_or_else(|| panic!("listed: {list}")); + assert_eq!(listed["label"], "Select Last Selection Tool"); + assert_eq!(listed["default"], if mac { json!(null) } else { json!("Cmd+~") }); + app.select_tool("directSelection"); + app.select_tool("pen"); + frame(&mut app, press(Key::Backtick, cmd())); + assert_eq!(app.session.tool_id(), if mac { "pen" } else { "directSelection" }); + crate::keymap::set_override(&mut app.ui.shortcut_overrides, "tool.selectLastSelection", "Alt+~"); + app.select_tool("groupSelection"); + app.select_tool("rectangle"); + frame(&mut app, press(Key::Backtick, Modifiers::ALT)); + assert_eq!(app.session.tool_id(), "groupSelection", "the user's chord"); + crate::shortcut_editor::sync(&crate::state::UiState::default()); +} diff --git a/docs/mcp.md b/docs/mcp.md index db6deab5a8..a98e9a588f 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1767,7 +1767,8 @@ vectorcraft-cli run --cmd file.new --params '{"width":800,"height":600}' \ `run` prints one JSON line per step (`open`, `cmd`, `export`) and exits non-zero on the first failure, naming the step (counting from 0, as `"$N"` references do) and its command. `--params` applies to the `--cmd` just before it. `run` -also accepts the host commands `file.open`, `file.save`, `file.export`, `file.exportForScreens` and `tool.select`. +also accepts the host commands `file.open`, `file.save`, `file.export`, `file.exportForScreens`, `tool.select` and +`tool.selectLastSelection`. `run --in`, `convert` and `info` read every format `document.open` reads (`vectorcraft-cli --help` lists them). ### Steps from a file or standard input @@ -6194,6 +6195,15 @@ macOS, Ctrl elsewhere), drags with the selection tool chosen last (`select_tool` Curvature and anchor tools until one is chosen; the release gives the tool back as it was, so the Pen goes on drawing the path it had begun while that stays selected. Its reply's `tool` is the tool given back. +`tool.selectLastSelection` (Select Last Selection Tool, `{}`) chooses the selection tool chosen last, as Ctrl+` does on +Windows and Linux ([the help page](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) lists the +shortcut among those for selections). Only Selection, Direct Selection and Group Selection count: choosing Magic Wand, +Lasso or any other tool leaves the remembered one as it was. Before any of the three is chosen it chooses the Selection +tool; with the remembered tool already active it keeps it, so running it again does not cycle. It returns `{tool}` and +adds no undo step. On macOS it has no default shortcut, because the system uses Command+` to switch between an app's +windows; Edit › Keyboard Shortcuts can assign one. The Selection tool as the first choice and the macOS default are +VectorCraft's own rules. The headless backend and `vectorcraft-cli run` run it too. + ```json {"name":"pointer_gesture","arguments":{"tool":"pen","events":[{"kind":"down","x":100,"y":300},{"kind":"up","x":100,"y":300},{"kind":"down","x":200,"y":300},{"kind":"drag","x":250,"y":300},{"kind":"up","x":250,"y":300}]}} {"name":"pointer_gesture","arguments":{"mods":{"cmd":true},"events":[{"kind":"down","x":250,"y":300},{"kind":"drag","x":250,"y":260},{"kind":"up","x":250,"y":260}]}} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index a02e99651c..927874d942 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1190,6 +1190,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Cmd/Ctrl+Alt+N (`file.newWithoutDialog`) makes a document without opening the New Document dialog, on the key the reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page assigns to creating a document directly. The page does not say which settings the document gets. VectorCraft gives it the settings the dialog opens on (the first Recent entry, or the Print category's Letter while Recent is empty) and the next untitled name. - Cmd/Ctrl+F6 (`window.nextDocument`) and Cmd/Ctrl+Shift+F6 (`window.previousDocument`) make the next and the previous open document the current one, in tab order and as a click on its tab does, on the keys the reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists for navigating to the next and the previous document. After the last document comes the first, and before the first document comes the last. From the Home screen the keys go to the first and the last document. Keyboard Shortcuts lists both under Window. - Cmd/Ctrl+Alt+Shift+U (`document.switchUnits`) switches the document to the next unit of measurement, in one undo step, on the key the reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists for switching units of measurement. The page does not give an order. VectorCraft steps through the units in the order a right-click on a ruler lists them (Points, Picas, Inches, Millimeters, Centimeters, Pixels, Feet & Inches, Meters, Yards, Feet) and goes from Feet back to Points. + - Ctrl+` (`tool.selectLastSelection`, Select Last Selection Tool) on Windows and Linux chooses the selection tool chosen last of Selection, Direct Selection and Group Selection, on the key [the help page](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) lists for switching to the last-used selection tool; Magic Wand and Lasso do not count. Before one is chosen it chooses the Selection tool, and it keeps the remembered tool when that tool is already active. On macOS it has no default shortcut, because the system uses Command+` to switch between an app's windows; Edit › Keyboard Shortcuts can assign one. The first choice and the macOS default are VectorCraft's own rules. - Shortcut sets other apps save as text (`.kys`) open in Import Shortcut Set from File › Open, from Edit › Keyboard Shortcuts › Import… in the desktop app, or from a drop on the window. It matches each entry to a tool, command or panel by name and decodes the file's key and modifier codes where VectorCraft's default shortcuts agree on them; the user answers the rest, and Apply fills the Keyboard Shortcuts dialog's working set. The answers are kept with the preferences for the next import (`shortcutSet.read`, `importMatches.*`). - Edit › Keyboard Shortcuts › Export Text… saves the set shown in the dialog as a UTF-8 text file, as the reference app's [Export keyboard shortcuts list as a text document](https://helpx.adobe.com/illustrator/desktop/get-started/preferences-and-settings/export-keyboard-shortcuts-list.html) page describes (`shortcuts.exportText {path?, format?, pageSize?}`). The layout is VectorCraft's own: the set's name, then the Tools and Menu Commands rows in the dialog's order, each with its name, a tab and its shortcuts as the dialog shows them, and nothing after the tab for a row with no shortcut. In the desktop app its save dialog also offers a printable shortcut sheet as a PDF, which `format: "sheet"` also picks (`pageSize: "letter" | "a4"`, A4 when the current document prints on A4): the rows with a shortcut under a colored band per group, in columns on landscape pages, a layout of VectorCraft's own. It also offers a CSV file of the same rows (`format: "csv"`; Group, Command and Shortcut columns). Tests `shortcut_editor::tests::export_text_*`, `shortcut_editor::tests::export_sections_*`, `shortcut_editor::tests::the_save_dialogs_answer_picks_the_export_text_format`, `shortcut_editor::tests::the_sheet_is_on_a4_when_the_document_prints_on_a4`, `shortcut_sheet::tests::*`, `tests::picks::keyboard_shortcuts_export_text_*` and `tests::picks::export_text_with_a_format_gives_the_answered_name_its_extension`. - On Windows and Linux the app bar is the window's title bar (its own minimize, maximize and close buttons, drag to move, edges to resize), with the dragon app icon as the brand mark; dialogs and menus size to their content. As on a native menu bar, once one menu is open, moving the pointer onto another title opens that one.