The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
feat(timeline): Q and W delete left and right of the playhead, as in CapCut (#400)
Jareerdce4ad08c1f7
diff --git a/docs/KEYBOARD_SHORTCUTS.md b/docs/KEYBOARD_SHORTCUTS.mdindex e55d3b50..4b5da33b 100644--- a/docs/KEYBOARD_SHORTCUTS.md+++ b/docs/KEYBOARD_SHORTCUTS.md@@ -2,9 +2,11 @@Shortcuts work when the editor window has focus. On macOS, `Ctrl` below means `⌘`.-Single-key shortcuts don't fire while typing in a text field. Letter shortcuts also don't fire while holding `Ctrl`/`⌘`, `Alt` or `Shift`.+These are the keys Concat ships with. Every one in the tables below except the window's own (see [Fixed keys](#fixed-keys)) can be changed in **Settings > Shortcuts**: click a row, press the new keys, or press `Escape` to cancel. A key another action already has moves to the new one, and the old action is left with no key until its row's Reset gives it back; **Reset all** puts every key back as shipped. The menus and the timeline's tooltips show the keys as they are now bound. The Shortcuts page is a desktop one; phones have no keyboard to bind.-On the start screen only `Ctrl` + `O`, `Ctrl` + `Q` (Windows/Linux) and `Ctrl` + `W` (macOS) work.+Single-key shortcuts don't fire while typing in a text field.++On the start screen only `Ctrl` + `O`, `Ctrl` + `Q` (Windows/Linux) and `Ctrl` + `W` (macOS) work. `Escape` closes the sheet or dialog on top.## Playback and navigation@@ -13,14 +15,17 @@ On the start screen only `Ctrl` + `O`, `Ctrl` + `Q` (Windows/Linux) and `Ctrl` +| `Space` | Play / pause || `Home` / `End` | Go to start / end of timeline || `←` / `→` | Step one frame back / forward |-| `Shift` + `←` / `→` | Step ten frames back / forward |+| `Shift` + `←` / `→` | Step ten frames back / forward (follows whatever key steps one) |## Editing| Shortcut | Action || --- | --- |-| `Ctrl` + `B` | Split every clip under the playhead |+| `Ctrl` + `B` | Split the selected clips at the playhead (every clip under it when nothing is selected) || `B` | Toggle the split (razor) tool |+| `Q` | Delete left: cut the clip from its start up to the playhead |+| `W` | Delete right: cut the clip from the playhead to its end |+| `F` | Freeze frame at the playhead || `Delete` / `Backspace` | Delete selection || `Shift` + `Delete` / `Backspace` | Ripple delete (close the gap) || `Ctrl` + `Z` | Undo |@@ -33,17 +38,27 @@ On the start screen only `Ctrl` + `O`, `Ctrl` + `Q` (Windows/Linux) and `Ctrl` +| `M` | Mute / unmute the selected clip || `S` | Toggle preview axis overlay |+`Q` and `W` are CapCut's keys for the same thing. They cut the selected clips the playhead is over, as one undo step; with nothing selected they cut the one clip under the playhead, and ask you to select one when there are several. On a magnetic timeline the gap closes up, and after `Q` the playhead lands on the frame it was showing. Both are also in a clip's right-click menu, which is the **More** menu on a phone.+## Project and app| Shortcut | Action || --- | --- || `Ctrl` + `S` | Save project |-| `Ctrl` + `O` | Open project |-| `Ctrl` + `W` | Close project (close window on macOS) |-| `Ctrl` + `Q` | Quit (Windows/Linux) || `Ctrl` + `E` | Export || `Ctrl` + `I` | Import media || `Ctrl` + `,` | Settings || `Ctrl` + `=` / `Ctrl` + `+` | Zoom timeline in || `Ctrl` + `-` | Zoom timeline out |++## Fixed keys++These belong to the window and can't be rebound; Settings > Shortcuts refuses them.++| Shortcut | Action |+| --- | --- |+| `Ctrl` + `O` | Open project |+| `Ctrl` + `W` | Close project (close window on macOS) |+| `Ctrl` + `Q` | Quit (Windows/Linux) || `F10`, `Alt` + `F` / `E` / `V` | Open app menus (Windows/Linux) |+| `Escape` | Close the sheet on top; cancel a rebind in Settings > Shortcuts |diff --git a/src/crates/concat-project/src/commands/clips.rs b/src/crates/concat-project/src/commands/clips.rsindex 40eb5b80..7b51ed0d 100644--- a/src/crates/concat-project/src/commands/clips.rs+++ b/src/crates/concat-project/src/commands/clips.rs@@ -832,6 +832,63 @@ fn first_free_track_above(timeline: &Timeline, start: f64, duration: f64) -> Opt.map(|track| track.id.clone())}+/// Which side of the playhead [`delete_to_playhead`] takes away.+#[derive(Clone, Copy, PartialEq, Eq, Debug)]+pub enum PlayheadSide {+ /// From the clip's start up to the playhead: CapCut's Delete Left (Q).+ Left,+ /// From the playhead to the clip's end: CapCut's Delete Right (W).+ Right,+}++/// Delete Left / Delete Right: each named clip that `at` runs through loses+/// what lies on `side` of it, as trims of the edge on that side brought to+/// `at` - so a head cut keeps the frames after the playhead where they+/// were in the source. More than one clip is one [`Command::Batch`], one+/// undo step. `ripple` closes each lane behind the cut, as a trim on the+/// magnetic timeline does.+///+/// A clip the instant misses, or grazes within [`MIN_CLIP_DURATION`] of an+/// end, is skipped, the way [`Command::SplitClips`] skips it: there is+/// nothing to take. So is a second clip on a lane that already has one:+/// a magnetic cut moves what comes after it, and the second clip's cut+/// was measured before that move. None when nothing is left to cut.+pub fn delete_to_playhead(+ timeline: &Timeline,+ clip_ids: &[String],+ at: f64,+ side: PlayheadSide,+ ripple: bool,+) -> Option<Command> {+ let mut lanes = HashSet::new();+ let mut trims: Vec<Command> = clip_ids+ .iter()+ .filter_map(|id| timeline.clip(id))+ .filter(|clip| {+ clip.start + MIN_CLIP_DURATION < at+ && at < clip.start + clip.duration - MIN_CLIP_DURATION+ })+ .filter(|clip| lanes.insert(clip.track_id.clone()))+ .map(|clip| {+ let (edge, delta) = match side {+ PlayheadSide::Left => (TrimEdge::Start, at - clip.start),+ PlayheadSide::Right => (TrimEdge::End, at - (clip.start + clip.duration)),+ };+ Command::TrimClip {+ clip_id: clip.id.clone(),+ edge,+ delta,+ ripple,+ }+ })+ .collect();+ match trims.len() {+ 0 => None,+ 1 => trims.pop(),+ _ => Some(Command::Batch { commands: trims }),+ }+}+/// Where each piece of a clip cut at `offset` begins in the source: the/// head keeps its in-point and the tail starts `offset × speed` later, so/// the two pieces together show exactly what the whole did.diff --git a/src/crates/concat-project/src/commands/mod.rs b/src/crates/concat-project/src/commands/mod.rsindex 2dba7c05..68212129 100644--- a/src/crates/concat-project/src/commands/mod.rs+++ b/src/crates/concat-project/src/commands/mod.rs@@ -20,7 +20,7 @@ use crate::model::{mod audio;mod clips;-pub use clips::{consolidation_clips, why_not_merge};+pub use clips::{PlayheadSide, consolidation_clips, delete_to_playhead, why_not_merge};mod media;mod properties;mod timelines;diff --git a/src/crates/concat-project/src/lib.rs b/src/crates/concat-project/src/lib.rsindex 767804de..bf488194 100644--- a/src/crates/concat-project/src/lib.rs+++ b/src/crates/concat-project/src/lib.rs@@ -28,7 +28,10 @@ pub mod model;pub mod placement;pub mod speed;-pub use commands::{Command, CommandError, Outcome, consolidation_clips, why_not_merge};+pub use commands::{+ Command, CommandError, Outcome, PlayheadSide, consolidation_clips, delete_to_playhead,+ why_not_merge,+};pub use doc::{DOCUMENT_VERSION, DocumentSettings, document_version, from_document, to_document};pub use editor::{Editor, RetiredFields};pub use model::Project;@@ -37,7 +40,9 @@ pub use model::Project;mod tests {use serde_json::json;- use crate::commands::{ClipMove, ClipPatch, Command, NewMedia, TrackFlag, TrimEdge};+ use crate::commands::{+ ClipMove, ClipPatch, Command, NewMedia, PlayheadSide, TrackFlag, TrimEdge,+ };use crate::doc::DocumentSettings;use crate::editor::Editor;use crate::model::{@@ -4530,4 +4535,111 @@ mod tests {.expect("no-op");assert!(!off.applied);}++ // ── Delete Left / Delete Right (Q / W) ──+ // https://github.com/jub0t/Concat/issues/400++ fn span(editor: &Editor, id: &str) -> (f64, f64, f64) {+ let clip = editor.project().active().clip(id).expect("clip");+ (clip.start, clip.duration, clip.source_start)+ }++ fn close(a: (f64, f64, f64), b: (f64, f64, f64)) -> bool {+ (a.0 - b.0).abs() < 1e-9 && (a.1 - b.1).abs() < 1e-9 && (a.2 - b.2).abs() < 1e-9+ }++ fn cut(editor: &Editor, ids: &[String], at: f64, side: PlayheadSide, ripple: bool) -> Command {+ crate::delete_to_playhead(editor.project().active(), ids, at, side, ripple).expect("a cut")+ }++ #[test]+ fn delete_left_takes_the_clip_from_its_start_to_the_playhead() {+ let (mut editor, media_id, _) = fixture();+ let track = editor.project().active().tracks[0].id.clone();+ let ids = lane(&mut editor, &media_id, &track, &[20.0, 30.0]);+ let command = cut(&editor, &ids[..1], 24.0, PlayheadSide::Left, false);+ editor.apply(command).expect("cuts");+ // The frames after the playhead stay where they were, on the+ // timeline and in the source; the hole stays on a plain timeline.+ let first = span(&editor, &ids[0]);+ assert!(close(first, (24.0, 6.0, 4.0)), "{first:?}");+ assert!(close(span(&editor, &ids[1]), (30.0, 10.0, 0.0)));+ }++ #[test]+ fn delete_right_takes_the_clip_from_the_playhead_to_its_end() {+ let (mut editor, media_id, _) = fixture();+ let track = editor.project().active().tracks[0].id.clone();+ let ids = lane(&mut editor, &media_id, &track, &[20.0, 30.0]);+ let command = cut(&editor, &ids[..1], 24.0, PlayheadSide::Right, false);+ editor.apply(command).expect("cuts");+ assert!(close(span(&editor, &ids[0]), (20.0, 4.0, 0.0)));+ assert!(+ close(span(&editor, &ids[1]), (30.0, 10.0, 0.0)),+ "the gap stays"+ );+ }++ /// On a magnetic timeline the lane closes up behind the cut, as any+ /// trim there does: a Delete Left keeps the clip's start and pulls+ /// what follows in by what came off its head; a Delete Right pulls it+ /// in by what came off the tail.+ #[test]+ fn a_magnetic_delete_closes_the_lane() {+ let (mut editor, media_id, _) = fixture();+ let track = editor.project().active().tracks[0].id.clone();+ let ids = lane(&mut editor, &media_id, &track, &[20.0, 30.0]);+ let left = cut(&editor, &ids[..1], 24.0, PlayheadSide::Left, true);+ editor.apply(left).expect("cuts");+ let (first, second) = (span(&editor, &ids[0]), span(&editor, &ids[1]));+ assert!(close(first, (20.0, 6.0, 4.0)), "{first:?}");+ assert!(close(second, (26.0, 10.0, 0.0)), "{second:?}");++ let right = cut(&editor, &ids[..1], 22.0, PlayheadSide::Right, true);+ editor.apply(right).expect("cuts");+ let (first, second) = (span(&editor, &ids[0]), span(&editor, &ids[1]));+ assert!(close(first, (20.0, 2.0, 4.0)), "{first:?}");+ assert!(close(second, (22.0, 10.0, 0.0)), "{second:?}");+ }++ /// Clips on several lanes are cut together, as one undo step.+ #[test]+ fn a_delete_across_lanes_is_one_undo_step() {+ let (mut editor, media_id, first) = fixture();+ let tracks = editor.project().active().tracks.clone();+ let above = lane(&mut editor, &media_id, &tracks[1].id, &[2.0]);+ let ids = vec![first.clone(), above[0].clone()];+ let command = cut(&editor, &ids, 5.0, PlayheadSide::Right, false);+ assert!(matches!(&command, Command::Batch { commands } if commands.len() == 2));+ editor.apply(command).expect("cuts");+ assert!(close(span(&editor, &first), (0.0, 5.0, 0.0)));+ assert!(close(span(&editor, &above[0]), (2.0, 3.0, 0.0)));+ assert!(editor.undo());+ assert!(+ close(span(&editor, &first), (0.0, 10.0, 0.0)),+ "both back at once"+ );+ assert!(close(span(&editor, &above[0]), (2.0, 10.0, 0.0)));+ }++ /// A playhead outside the clip, or on its very edge, has nothing to+ /// take: no command at all, rather than an undo step that did nothing.+ #[test]+ fn a_playhead_outside_the_clip_cuts_nothing() {+ let (editor, _, clip) = fixture();+ let timeline = editor.project().active();+ let ids = [clip];+ for at in [-1.0, 0.0, 10.0, 12.0] {+ for side in [PlayheadSide::Left, PlayheadSide::Right] {+ assert!(+ crate::delete_to_playhead(timeline, &ids, at, side, true).is_none(),+ "{at} {side:?}"+ );+ }+ }+ let gone = ["nobody".to_owned()];+ assert!(+ crate::delete_to_playhead(timeline, &gone, 5.0, PlayheadSide::Left, false).is_none()+ );+ }}diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.jsonindex 62cfa330..2adbfde5 100644--- a/src/crates/concat/locales/de.json+++ b/src/crates/concat/locales/de.json@@ -443,8 +443,8 @@"settings.voices": "Stimmen","settings.whatConnectionMustPresent": "Was eine Verbindung vor ihrem ersten Aufruf vorzeigen muss. Bleibt es leer, denkt sich der Server bei jedem Start eines aus und zeigt es hier.","settings.whereEachModelCame": "Wo jedes Modell herkommt",- "shortcuts.cutLeft": "Links vom Abspielkopf schneiden",- "shortcuts.cutRight": "Rechts vom Abspielkopf schneiden",+ "shortcuts.deleteLeft": "Links vom Abspielkopf schneiden",+ "shortcuts.deleteRight": "Rechts vom Abspielkopf schneiden","shortcuts.hint": "Klicke eine Zeile an und drücke dann die Tasten, auf die sie reagieren soll. Escape bricht ab, und eine Tastenkombination, die eine andere Aktion hält, wird übernommen - diese Aktion bleibt ohne Taste, bis ihr eigenes Zurücksetzen wieder eine gibt. Einige Kombinationen gehören dem Fenster und können nicht belegt werden.","shortcuts.press": "Taste drücken…","shortcuts.previewAxis": "Vorschauachse",diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.jsonindex 04efde13..05b4342c 100644--- a/src/crates/concat/locales/en.json+++ b/src/crates/concat/locales/en.json@@ -443,8 +443,8 @@"settings.voices": "Voices","settings.whatConnectionMustPresent": "What a connection must present before its first call. Left empty, the server makes one up each time it starts and shows it here.","settings.whereEachModelCame": "Where each model came from",- "shortcuts.cutLeft": "Cut left of playhead",- "shortcuts.cutRight": "Cut right of playhead",+ "shortcuts.deleteLeft": "Delete left",+ "shortcuts.deleteRight": "Delete right","shortcuts.hint": "Click a row, then press the keys it should answer to. Escape cancels, and a chord another action holds moves over, leaving that action with no key until its own Reset puts one back. A few chords belong to the window and cannot be bound.","shortcuts.pan": "Pan tool","shortcuts.press": "Press a key…",@@ -586,6 +586,7 @@"studio.noRoomForTransition": "There's no room for a transition here: both clips need to be at least a frame long","studio.notAFont": "{0} is not a font Concat can read","studio.openProject": "Open project…",+ "studio.parkPlayheadInsideClip": "Put the playhead inside the clip to cut it there","studio.paste": "Paste","studio.projectOpenThroughRemote": "This project is open through the Remote API","studio.projectSaved": "Project saved",@@ -604,6 +605,7 @@"studio.savedTemplate": "Saved template “{0}”","studio.savingFrame": "Saving the frame…","studio.selectClipTimelineFirst": "Select a clip on the timeline first",+ "studio.selectClipToCut": "More than one clip is under the playhead: select the one to cut","studio.selectTwoAdjacentClips": "Select two clips that meet on the same track, then pick a transition","studio.selectVideoImageClip": "Select a video or image clip on the timeline first","studio.selectVideoImageText": "Select a video, image or text clip on the timeline first",diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.jsonindex 2195aefa..83d09cf6 100644--- a/src/crates/concat/locales/es.json+++ b/src/crates/concat/locales/es.json@@ -443,8 +443,8 @@"settings.voices": "Voces","settings.whatConnectionMustPresent": "Lo que una conexión debe presentar antes de su primera llamada. Si se deja vacío, el servidor inventa uno cada vez que arranca y lo muestra aquí.","settings.whereEachModelCame": "De donde salió cada modelo",- "shortcuts.cutLeft": "Cortar a la izquierda del cabezal",- "shortcuts.cutRight": "Cortar a la derecha del cabezal",+ "shortcuts.deleteLeft": "Cortar a la izquierda del cabezal",+ "shortcuts.deleteRight": "Cortar a la derecha del cabezal","shortcuts.hint": "Haz clic en una fila y pulsa después las teclas a las que debe responder. Escape cancela, y una combinación que tiene otra acción pasa a esta, dejando a esa acción sin tecla hasta que su propio Restablecer devuelva una. Algunas combinaciones pertenecen a la ventana y no se pueden asignar.","shortcuts.press": "Pulsa una tecla…","shortcuts.previewAxis": "Eje de previsualización",diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.jsonindex b450a7f0..9f0ca8f2 100644--- a/src/crates/concat/locales/fa.json+++ b/src/crates/concat/locales/fa.json@@ -443,8 +443,8 @@"settings.voices": "صداها","settings.whatConnectionMustPresent": "چیزی که اتصال باید پیش از اولین درخواست ارائه کند. اگر خالی بماند، سرور هر بار هنگام راهاندازی یک Token جدید میسازد و آن را اینجا نشان میدهد.","settings.whereEachModelCame": "منبع هر مدل",- "shortcuts.cutLeft": "بریدن در سمت چپ نشانگر پخش",- "shortcuts.cutRight": "بریدن در سمت راست نشانگر پخش",+ "shortcuts.deleteLeft": "بریدن در سمت چپ نشانگر پخش",+ "shortcuts.deleteRight": "بریدن در سمت راست نشانگر پخش","shortcuts.hint": "روی یک ردیف کلیک کنید، سپس کلیدهایی را بزنید که باید به آنها پاسخ دهد. Escape انصراف میدهد؛ ترکیبی که عمل دیگری در اختیار دارد به اینجا منتقل میشود و آن عمل را تا زمانی که بازنشانیِ خودش کلیدی برگرداند، بدون کلید میگذارد. چند ترکیب متعلق به پنجره است و قابل تخصیص نیست.","shortcuts.pan": "ابزار Pan","shortcuts.press": "یک کلید را بزنید…",diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.jsonindex 78bd3fe7..6641925d 100644--- a/src/crates/concat/locales/fr.json+++ b/src/crates/concat/locales/fr.json@@ -443,8 +443,8 @@"settings.voices": "Voix","settings.whatConnectionMustPresent": "Ce qu'une connexion doit présenter avant son premier appel. Laissé vide, le serveur en invente un à chaque démarrage et l'affiche ici.","settings.whereEachModelCame": "D'où vient chaque modèle",- "shortcuts.cutLeft": "Couper à gauche de la tête de lecture",- "shortcuts.cutRight": "Couper à droite de la tête de lecture",+ "shortcuts.deleteLeft": "Couper à gauche de la tête de lecture",+ "shortcuts.deleteRight": "Couper à droite de la tête de lecture","shortcuts.hint": "Cliquez sur une ligne, puis appuyez sur les touches auxquelles elle doit répondre. Échap annule, et une combinaison détenue par une autre action passe ici, laissant cette action sans touche jusqu'à ce que sa propre réinitialisation en remette une. Certaines combinaisons appartiennent à la fenêtre et ne peuvent pas être attribuées.","shortcuts.press": "Appuyez sur une touche…","shortcuts.previewAxis": "Axe d'aperçu",diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.jsonindex f570640f..b97754c3 100644--- a/src/crates/concat/locales/hr.json+++ b/src/crates/concat/locales/hr.json@@ -443,8 +443,8 @@"settings.voices": "Glasovi","settings.whatConnectionMustPresent": "Što veza mora predočiti prije prvog poziva. Ostane li prazno, poslužitelj ga sam smisli pri svakom pokretanju i prikaže ovdje.","settings.whereEachModelCame": "Odakle svaki model dolazi",- "shortcuts.cutLeft": "Reži lijevo od playheada",- "shortcuts.cutRight": "Reži desno od playheada",+ "shortcuts.deleteLeft": "Reži lijevo od playheada",+ "shortcuts.deleteRight": "Reži desno od playheada","shortcuts.hint": "Klikni red, a zatim pritisni tipke na koje treba odgovarati. Escape odustaje, a kombinacija koju drži druga akcija prelazi ovdje, ostavljajući tu akciju bez tipke dok je njezino vraćanje na zadano ponovno ne vrati. Neke kombinacije pripadaju prozoru i ne mogu se vezati.","shortcuts.press": "Pritisni tipku…","shortcuts.previewAxis": "Os pregleda",diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.jsonindex 2ff1e400..355a512c 100644--- a/src/crates/concat/locales/it.json+++ b/src/crates/concat/locales/it.json@@ -443,8 +443,8 @@"settings.voices": "Voci","settings.whatConnectionMustPresent": "Ciò che una connessione deve presentare prima della prima chiamata. Se lasciato vuoto, il server ne inventa uno a ogni avvio e lo mostra qui.","settings.whereEachModelCame": "Da dove viene ogni modello",- "shortcuts.cutLeft": "Taglia a sinistra della testina",- "shortcuts.cutRight": "Taglia a destra della testina",+ "shortcuts.deleteLeft": "Taglia a sinistra della testina",+ "shortcuts.deleteRight": "Taglia a destra della testina","shortcuts.hint": "Clicca una riga, poi premi i tasti a cui deve rispondere. Esc annulla, e una combinazione tenuta da un'altra azione passa qui, lasciando quell'azione senza tasto finché il suo Reimposta non ne rimette una. Alcune combinazioni appartengono alla finestra e non possono essere assegnate.","shortcuts.press": "Premi un tasto…","shortcuts.previewAxis": "Asse di anteprima",diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.jsonindex 6d2e0e0b..52fa7b1b 100644--- a/src/crates/concat/locales/ja.json+++ b/src/crates/concat/locales/ja.json@@ -443,8 +443,8 @@"settings.voices": "声","settings.whatConnectionMustPresent": "接続が最初の呼び出しの前に提示するもの。空のままにすると、サーバーは起動のたびに自分で作り、ここに表示します。","settings.whereEachModelCame": "各モデルの元の場所",- "shortcuts.cutLeft": "再生ヘッドの左側を切り取る",- "shortcuts.cutRight": "再生ヘッドの右側を切り取る",+ "shortcuts.deleteLeft": "再生ヘッドの左側を切り取る",+ "shortcuts.deleteRight": "再生ヘッドの右側を切り取る","shortcuts.hint": "行をクリックしてから、応答すべきキーを押してください。Esc でキャンセルします。他のアクションが保持しているキー組み合わせはここに移動し、そのアクションは独自のリセットでキーが戻るまで割り当てなしになります。ウィンドウ専用の組み合わせは割り当てられません。","shortcuts.press": "キーを押してください…","shortcuts.previewAxis": "プレビュー軸",diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.jsonindex e0d55fff..163125fd 100644--- a/src/crates/concat/locales/ko.json+++ b/src/crates/concat/locales/ko.json@@ -443,8 +443,8 @@"settings.voices": "목소리","settings.whatConnectionMustPresent": "연결이 첫 호출 전에 제시해야 하는 값입니다. 비워 두면 서버가 시작할 때마다 하나를 만들어 여기에 표시합니다.","settings.whereEachModelCame": "각 모델의 원래 출처",- "shortcuts.cutLeft": "재생 헤드 왼쪽 자르기",- "shortcuts.cutRight": "재생 헤드 오른쪽 자르기",+ "shortcuts.deleteLeft": "재생 헤드 왼쪽 자르기",+ "shortcuts.deleteRight": "재생 헤드 오른쪽 자르기","shortcuts.hint": "행을 클릭한 다음, 그 행이 응답할 키를 누르세요. Esc는 취소하고, 다른 작업이 쓰고 있는 조합은 여기로 넘어가 해당 작업은 자체 초기화로 키를 되찾을 때까지 연결되지 않습니다. 일부 조합은 창에 속해 있어 지정할 수 없습니다.","shortcuts.press": "키를 누르세요…","shortcuts.previewAxis": "미리보기 축",diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.jsonindex 9e963950..4251eb54 100644--- a/src/crates/concat/locales/pt-BR.json+++ b/src/crates/concat/locales/pt-BR.json@@ -443,8 +443,8 @@"settings.voices": "Vozes","settings.whatConnectionMustPresent": "O que uma conexão precisa apresentar antes da primeira chamada. Se ficar vazio, o servidor inventa um a cada início e o mostra aqui.","settings.whereEachModelCame": "De onde cada modelo veio",- "shortcuts.cutLeft": "Cortar à esquerda do cursor",- "shortcuts.cutRight": "Cortar à direita do cursor",+ "shortcuts.deleteLeft": "Cortar à esquerda do cursor",+ "shortcuts.deleteRight": "Cortar à direita do cursor","shortcuts.hint": "Clique em uma linha e depois pressione as teclas a que ela deve responder. Esc cancela, e uma combinação que outra ação detém passa para cá, deixando essa ação sem tecla até que o próprio Redefinir devolva uma. Algumas combinações pertencem à janela e não podem ser atribuídas.","shortcuts.press": "Pressione uma tecla…","shortcuts.previewAxis": "Eixo de prévia",diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.jsonindex 710f3d34..38e7f9f9 100644--- a/src/crates/concat/locales/ru.json+++ b/src/crates/concat/locales/ru.json@@ -443,8 +443,8 @@"settings.voices": "Голоса","settings.whatConnectionMustPresent": "Что соединение должно предъявить перед первым вызовом. Если оставить пустым, сервер сам придумает его при каждом запуске и покажет здесь.","settings.whereEachModelCame": "Откуда взята каждая модель",- "shortcuts.cutLeft": "Резать слева от курсора",- "shortcuts.cutRight": "Резать справа от курсора",+ "shortcuts.deleteLeft": "Резать слева от курсора",+ "shortcuts.deleteRight": "Резать справа от курсора","shortcuts.hint": "Нажмите на строку, затем задайте клавиши, на которые она должна отзываться. Esc отменяет, а комбинация, занятая другим действием, переходит сюда, оставляя это действие без клавиши, пока его собственный Сброс не вернёт одну. Некоторые комбинации принадлежат окну и не назначаются.","shortcuts.pan": "Инструмент «Рука»","shortcuts.press": "Нажмите клавишу…",diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.jsonindex 5eba9232..0328ce74 100644--- a/src/crates/concat/locales/tr.json+++ b/src/crates/concat/locales/tr.json@@ -443,8 +443,8 @@"settings.voices": "Sesler","settings.whatConnectionMustPresent": "Bir bağlantının ilk çağrısından önce sunması gereken şey. Boş bırakılırsa sunucu her başlatıldığında bir tane uydurur ve burada gösterir.","settings.whereEachModelCame": "Her modelin geldiği yer",- "shortcuts.cutLeft": "Oynatma imlecinin solundan kes",- "shortcuts.cutRight": "Oynatma imlecinin sağından kes",+ "shortcuts.deleteLeft": "Oynatma imlecinin solundan kes",+ "shortcuts.deleteRight": "Oynatma imlecinin sağından kes","shortcuts.hint": "Bir satıra tıklayın, sonra yanıt vermesi gereken tuşlara basın. Esc iptal eder; başka bir eylemin tuttuğu kombinasyon buraya taşınır ve o eylem, kendi Sıfırlaması bir tuş geri getirene kadar tuşsuz kalır. Bazı kombinasyonlar pencereye aittir ve bağlanamaz.","shortcuts.press": "Bir tuşa basın…","shortcuts.previewAxis": "Önizleme ekseni",diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.jsonindex b1401e43..ea85b83f 100644--- a/src/crates/concat/locales/zh-Hans.json+++ b/src/crates/concat/locales/zh-Hans.json@@ -443,8 +443,8 @@"settings.voices": "语音","settings.whatConnectionMustPresent": "连接在首次调用前必须提供的凭据。留空时,服务器每次启动都会自动生成一个并显示在此处。","settings.whereEachModelCame": "各模型的来源",- "shortcuts.cutLeft": "剪切播放头左侧",- "shortcuts.cutRight": "剪切播放头右侧",+ "shortcuts.deleteLeft": "剪切播放头左侧",+ "shortcuts.deleteRight": "剪切播放头右侧","shortcuts.hint": "点击一行,然后按下它应响应的按键。Esc 取消;其他操作占用的组合键会移到这里,该操作将没有按键,直到它自己的重置把按键放回。有些组合键属于窗口,无法绑定。","shortcuts.pan": "平移工具","shortcuts.press": "按下按键…",diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.jsonindex 897dd89d..8b18bf71 100644--- a/src/crates/concat/locales/zh-TW.json+++ b/src/crates/concat/locales/zh-TW.json@@ -443,8 +443,8 @@"settings.voices": "語音","settings.whatConnectionMustPresent": "連線在首次呼叫前必須提供的憑證。留空時,伺服器每次啟動都會自動產生一個並顯示在此處。","settings.whereEachModelCame": "各模型的來源",- "shortcuts.cutLeft": "剪切播放磁頭左側",- "shortcuts.cutRight": "剪切播放磁頭右側",+ "shortcuts.deleteLeft": "剪切播放磁頭左側",+ "shortcuts.deleteRight": "剪切播放磁頭右側","shortcuts.hint": "點擊一列,然後按下它應回應的按鍵。Esc 取消;其他操作佔用的組合鍵會移到這裡,該操作將沒有按鍵,直到它自己的重設把按鍵放回。有些組合鍵屬於視窗,無法綁定。","shortcuts.pan": "平移工具","shortcuts.press": "按下按鍵…",diff --git a/src/crates/concat/src/keymap.rs b/src/crates/concat/src/keymap.rsindex 38dbfc29..d5818650 100644--- a/src/crates/concat/src/keymap.rs+++ b/src/crates/concat/src/keymap.rs@@ -108,15 +108,16 @@ pub const ACTIONS: &[Action] = &[id: "freeze",defaults: &["f"],},- // The big editors' trim keys: the selected clip is cut at the- // playhead, Q dropping its left, E its right.+ // CapCut's Delete Left and Delete Right, on its keys: the clip under+ // the playhead loses everything before it (Q) or after it (W).+ // https://github.com/jub0t/Concat/issues/400Action {- id: "cut-left",+ id: "delete-left",defaults: &["q"],},Action {- id: "cut-right",- defaults: &["e"],+ id: "delete-right",+ defaults: &["w"],},Action {id: "split-tool",@@ -200,8 +201,8 @@ pub fn name(id: &str) -> String {"delete" => i18n::t("common.delete"),"ripple-delete" => i18n::t("shortcuts.rippleDelete"),"freeze" => i18n::t("timelinePane.freeze"),- "cut-left" => i18n::t("shortcuts.cutLeft"),- "cut-right" => i18n::t("shortcuts.cutRight"),+ "delete-left" => i18n::t("shortcuts.deleteLeft"),+ "delete-right" => i18n::t("shortcuts.deleteRight"),"split-tool" => i18n::t("shortcuts.splitTool"),"mute" => i18n::t("studio.mute"),"pan" => i18n::t("shortcuts.pan"),@@ -608,7 +609,10 @@ mod tests {#[test]fn the_defaults_resolve_to_their_actions() {let prefs = Preferences::default();- assert_eq!(resolve(&prefs, "q"), Some("cut-left"));+ // CapCut's Delete Left and Right; E is nobody's.+ assert_eq!(resolve(&prefs, "q"), Some("delete-left"));+ assert_eq!(resolve(&prefs, "w"), Some("delete-right"));+ assert_eq!(resolve(&prefs, "e"), None);assert_eq!(resolve(&prefs, "ctrl+shift+z"), Some("redo"));assert_eq!(resolve(&prefs, "backspace"), Some("delete"));assert_eq!(resolve(&prefs, "shift+delete"), Some("ripple-delete"));@@ -653,16 +657,16 @@ mod tests {#[test]fn a_rebind_moves_the_chord_and_leaves_the_loser_none() {let mut prefs = Preferences::default();- // Mute ships on M; taking M for the trim key leaves mute none.- assert_eq!(bind(&mut prefs, "cut-left", "m"), Some("mute"));- assert_eq!(resolve(&prefs, "m"), Some("cut-left"));+ // Mute ships on M; taking M for Delete Left leaves mute none.+ assert_eq!(bind(&mut prefs, "delete-left", "m"), Some("mute"));+ assert_eq!(resolve(&prefs, "m"), Some("delete-left"));assert_eq!(bound(&prefs, "mute"), None);assert_eq!(resolve(&prefs, "q"), None);// The override is what is stored, not the whole table.assert_eq!(prefs.keybinds,[- ("cut-left".to_owned(), "m".to_owned()),+ ("delete-left".to_owned(), "m".to_owned()),("mute".to_owned(), String::new())].into_iter()@@ -670,6 +674,25 @@ mod tests {);}+ /// A rebind and the action it left keyless are what the prefs file+ /// keeps, and the window resolves the same keys after a restart.+ #[test]+ fn a_rebind_survives_the_prefs_file() {+ let mut prefs = Preferences::default();+ assert_eq!(bind(&mut prefs, "delete-right", "e"), None);+ assert_eq!(bind(&mut prefs, "delete-left", "ctrl+shift+q"), None);+ assert_eq!(bind(&mut prefs, "split", "m"), Some("mute"));+ let text = serde_json::to_string(&prefs).unwrap();+ let back: Preferences = serde_json::from_str(&text).unwrap();+ assert_eq!(resolve(&back, "e"), Some("delete-right"));+ assert_eq!(resolve(&back, "w"), None);+ assert_eq!(resolve(&back, "ctrl+shift+q"), Some("delete-left"));+ assert_eq!(resolve(&back, "q"), None);+ assert_eq!(resolve(&back, "m"), Some("split"));+ assert_eq!(bound(&back, "mute"), None);+ assert_eq!(resolve(&back, "ctrl+b"), None);+ }+#[test]fn binding_an_action_back_to_its_default_clears_the_override() {let mut prefs = Preferences::default();@@ -685,20 +708,20 @@ mod tests {#[test]fn reset_takes_the_shipped_chord_back() {let mut prefs = Preferences::default();- // The trim key took M from mute, leaving mute none.- assert_eq!(bind(&mut prefs, "cut-left", "m"), Some("mute"));+ // Delete Left took M from mute, leaving mute none.+ assert_eq!(bind(&mut prefs, "delete-left", "m"), Some("mute"));assert_eq!(bound(&prefs, "mute"), None);- assert_eq!(bound(&prefs, "cut-left"), Some("m"));+ assert_eq!(bound(&prefs, "delete-left"), Some("m"));// Mute's own Reset puts M back where it ships, taking it off- // the trim key — a chord is one action's, and mute is the+ // Delete Left — a chord is one action's, and mute is the// action it belongs to.- assert_eq!(reset(&mut prefs, "mute"), Some("cut-left"));+ assert_eq!(reset(&mut prefs, "mute"), Some("delete-left"));assert_eq!(bound(&prefs, "mute"), Some("m"));- assert_eq!(bound(&prefs, "cut-left"), None);- // The trim key's Reset returns it to Q, which nobody holds, so+ assert_eq!(bound(&prefs, "delete-left"), None);+ // Delete Left's Reset returns it to Q, which nobody holds, so// there is no loser to name.- assert_eq!(reset(&mut prefs, "cut-left"), None);- assert_eq!(bound(&prefs, "cut-left"), Some("q"));+ assert_eq!(reset(&mut prefs, "delete-left"), None);+ assert_eq!(bound(&prefs, "delete-left"), Some("q"));assert_eq!(bound(&prefs, "mute"), Some("m"));reset_all(&mut prefs);assert!(prefs.keybinds.is_empty());@@ -708,6 +731,8 @@ mod tests {fn the_windows_own_chords_are_reserved() {assert!(reserved("ctrl+o"));assert!(reserved("ctrl+w"));+ // W alone is Delete Right's, not the window's.+ assert!(!reserved("w"));assert!(!reserved("ctrl+z"));assert!(!reserved("alt+m"));if cfg!(not(any(target_os = "macos", target_os = "ios"))) {@@ -727,7 +752,9 @@ mod tests {}let undo = display("ctrl+z");assert!(undo.to_lowercase().contains('z'), "{undo}");- assert!(undo.contains("Ctrl") || undo.contains('⌃'), "{undo}");+ // Ctrl+Z on Windows and Linux, ⌘Z on a Mac, where Slint's Control+ // is the command key.+ assert!(undo.contains("Ctrl") || undo.contains('⌘'), "{undo}");let ripple = display("shift+delete");assert!(!ripple.is_empty(), "the ripple delete displays as nothing");// A row for an action with no chord reads "" for its menu anddiff --git a/src/crates/concat/src/prefs.rs b/src/crates/concat/src/prefs.rsindex c5fe695a..c331beeb 100644--- a/src/crates/concat/src/prefs.rs+++ b/src/crates/concat/src/prefs.rs@@ -435,12 +435,15 @@ mod tests {dark: Some(true),..Preferences::default()};- prefs.keybinds.insert("cut-left".into(), "j".into());+ prefs.keybinds.insert("delete-left".into(), "j".into());prefs.keybinds.insert("mute".into(), String::new());let text = serde_json::to_string(&prefs).unwrap();assert!(text.contains("\"keybinds\""), "{text}");let back: Preferences = serde_json::from_str(&text).unwrap();- assert_eq!(back.keybinds.get("cut-left").map(String::as_str), Some("j"));+ assert_eq!(+ back.keybinds.get("delete-left").map(String::as_str),+ Some("j")+ );assert_eq!(back.keybinds.get("mute").map(String::as_str), Some(""));let older: Preferences = serde_json::from_str(r#"{"dark": false}"#).unwrap();assert!(older.keybinds.is_empty());diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex 5aec3860..b3a845b5 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -38,11 +38,11 @@ use concat_host::{templates,};use concat_media::{Pyramid, jpeg};-use concat_project::Command;use concat_project::commands::{ClipMove, ClipPatch, TrackFlag, TrimEdge};use concat_project::model::{self, AppliedFilter, Clip, Project, TextAlign, TextStyle, Timeline, Track, Transition,};+use concat_project::{Command, PlayheadSide};mod consolidate;use consolidate::MergeJob;@@ -6864,43 +6864,75 @@ impl Studio {}}- /// Q / E: the selected clip is cut at the playhead - Q drops its left- /// up to there, E its right from there on, as one undo step. Like any- /// trim, the lane closes behind the edge only on a magnetic timeline,- /// and trim follow carries the playhead to a head cut's new start.- pub fn cut_to_playhead(&mut self, left: bool) {- let Some(clip_id) = self.sole_selection() else {- self.notify(&t("studio.selectClipTimelineFirst"), true);- return;- };- let Some(clip) = self.clip(&clip_id).cloned() else {- return;+ /// Delete Left / Delete Right, CapCut's Q and W: the selected clips the+ /// playhead runs through lose everything before it, or everything+ /// after it, as one undo step. With nothing selected, the one clip+ /// under the playhead is cut; with several there and none chosen, a+ /// notice asks for one rather than guessing - a caption over the+ /// picture is as much "the clip" as the picture is. The lane closes+ /// behind the cut only on a magnetic timeline, as any trim's does.+ /// https://github.com/jub0t/Concat/issues/400+ pub fn delete_to_playhead(&mut self, side: PlayheadSide) {+ let at = f64::from(self.playhead);+ let edge = f64::from(MIN_DURATION);+ let under: Vec<String> = self+ .timeline()+ .clips+ .iter()+ .filter(|clip| {+ clip.start + edge < at+ && at < clip.start + clip.duration - edge+ && !self.locked(&clip.track_id)+ })+ .map(|clip| clip.id.clone())+ .collect();+ let targets: Vec<String> = if self.selection.is_empty() {+ if under.len() > 1 {+ self.notify(&t("studio.selectClipToCut"), true);+ return;+ }+ under+ } else {+ under+ .into_iter()+ .filter(|id| self.selection.contains(id))+ .collect()};- if self.locked(&clip.track_id) {- return;- }+ self.delete_clips_to_playhead(&targets, side);+ }++ /// The cut itself, on these clips; see [`Self::delete_to_playhead`].+ /// A Delete Left ends with the playhead on the frame it was showing,+ /// which a magnetic cut has moved back to the clip's start.+ fn delete_clips_to_playhead(&mut self, ids: &[String], side: PlayheadSide) {let at = f64::from(self.playhead);- // Nothing is cut unless the playhead sits inside the clip, as- // split_at requires of its cuts.- if !(clip.start + f64::from(MIN_DURATION) < at- && at < clip.start + clip.duration - f64::from(MIN_DURATION))- {+ let ids: Vec<String> = ids+ .iter()+ .filter(|id| {+ self.clip(id)+ .is_some_and(|clip| !self.locked(&clip.track_id))+ })+ .cloned()+ .collect();+ let Some(command) = concat_project::delete_to_playhead(+ self.timeline(),+ &ids,+ at,+ side,+ self.prefs.magnetic,+ ) else {+ self.notify(&t("studio.parkPlayheadInsideClip"), true);return;- }- let (edge, delta) = if left {- (TrimEdge::Start, at - clip.start)- } else {- (TrimEdge::End, at - (clip.start + clip.duration))- };- let follow = left && self.prefs.trim_follow;- self.apply(Command::TrimClip {- clip_id: clip_id.clone(),- edge,- delta,- ripple: self.prefs.magnetic,- });- if follow {- if let Some(start) = self.clip(&clip_id).map(|clip| clip.start) {+ };+ self.flush_commit();+ self.apply(command);+ if side == PlayheadSide::Left {+ let start = ids+ .iter()+ .filter_map(|id| self.clip(id))+ .map(|clip| clip.start)+ .fold(f64::INFINITY, f64::min);+ if start.is_finite() && start < at {self.seek(start as f32);}}@@ -10184,6 +10216,22 @@ impl Studio {&keymap::label(&self.prefs, "split"),straddled && !locked,),+ // CapCut's Delete Left and Right, here as on the keys; on a+ // phone, whose More is this menu, the only way to them.+ action(+ "delete-left",+ t("shortcuts.deleteLeft"),+ Glyph::None,+ &keymap::label(&self.prefs, "delete-left"),+ straddled && !locked,+ ),+ action(+ "delete-right",+ t("shortcuts.deleteRight"),+ Glyph::None,+ &keymap::label(&self.prefs, "delete-right"),+ straddled && !locked,+ ),action("merge",self.merge_label(),@@ -10265,7 +10313,7 @@ impl Studio {rows.push(check("mute",&t("studio.mute"),- "M",+ &keymap::label(&self.prefs, "mute"),clip.volume <= 0.0,!locked && audible,));@@ -10829,10 +10877,10 @@ impl Studio {TimelineTool::Split};}- // Q / E: the selected clip's edge jumps to the playhead, taking- // the clip's left or its right with it.- "cut-left" => self.cut_to_playhead(true),- "cut-right" => self.cut_to_playhead(false),+ // Q / W, as in CapCut: the clip loses what is left, or right,+ // of the playhead.+ "delete-left" => self.delete_to_playhead(PlayheadSide::Left),+ "delete-right" => self.delete_to_playhead(PlayheadSide::Right),"select-all" => self.select_all(),// The phone's way out of the clip tools: nothing selected, the// way a press on an empty lane leaves it.@@ -10959,6 +11007,22 @@ impl Studio {self.split_at(at, true);}"freeze" => self.freeze_at_playhead(),+ // The clip right-clicked, or the selection when it is one of+ // it, as Delete takes it.+ "delete-left" | "delete-right" => {+ let ids =+ if self.selection.len() > 1 && self.selection.iter().any(|held| held == id) {+ self.selection.clone()+ } else {+ vec![id.to_owned()]+ };+ let side = if action == "delete-left" {+ PlayheadSide::Left+ } else {+ PlayheadSide::Right+ };+ self.delete_clips_to_playhead(&ids, side);+ }"merge" => self.merge(),// The menu opens the clip's Enhance in the inspector, where its// switch starts it and later turns it off and on again.