Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Timeline: Option-drag duplicates captions (#3040)

Tex Jernigan964424ea8dfb
diff --git a/crates/edit/src/captions.rs b/crates/edit/src/captions.rs
index a08d0ad7d..252c7e46e 100644
--- a/crates/edit/src/captions.rs
+++ b/crates/edit/src/captions.rs
@@ -215,6 +215,67 @@ pub fn move_captions(seq: &mut Sequence, ids: &[ClipId], delta: Tick) -> Result<
Ok(d)
}
+/// Place copies of `captions` on `track`, overwriting what lies under them (captions there are cut
+/// back, split or removed), as Paste and Option-drag do. The copies keep their text, speaker and
+/// settings at their own `start`/`duration`, and get new ids (returned in time order).
+pub fn overwrite_captions(seq: &mut Sequence, track: TrackId, captions: &[Caption], ctx: &mut EditCtx) -> Result<Vec<ClipId>> {
+ let min = ctx.min_duration;
+ let mut placed: Vec<Caption> = captions.iter().filter(|c| c.duration >= min).cloned().collect();
+ if placed.is_empty() {
+ return Err(EditError::Nothing);
+ }
+ placed.sort_by_key(|c| c.start);
+ if placed.first().is_some_and(|c| c.start < Tick::ZERO) {
+ return Err(EditError::Other("captions cannot start before the sequence".into()));
+ }
+ if placed.windows(2).any(|w| w[0].end() > w[1].start) {
+ return Err(EditError::Other("captions overlap".into()));
+ }
+ let tr = track_mut(seq, track)?;
+ for c in &mut placed {
+ c.id = ClipId(ctx.alloc());
+ c.cue_id = None;
+ }
+ for c in &placed {
+ clear_range(tr, c.start, c.end(), min, ctx);
+ }
+ let ids = placed.iter().map(|c| c.id).collect();
+ tr.captions.extend(placed);
+ tr.sort();
+ Ok(ids)
+}
+
+/// Clear `a..b` on a caption track without closing the gap: captions inside go, captions across an
+/// edge are cut back, a caption across the whole range is split. Pieces shorter than `min` go.
+fn clear_range(tr: &mut CaptionTrack, a: Tick, b: Tick, min: Tick, ctx: &mut EditCtx) {
+ let mut out = Vec::with_capacity(tr.captions.len() + 1);
+ for c in tr.captions.drain(..) {
+ let (s, e) = (c.start, c.end());
+ if e <= a || s >= b {
+ out.push(c);
+ continue;
+ }
+ let mut kept_left = false;
+ if s < a && a - s >= min {
+ let mut l = c.clone();
+ l.duration = a - s;
+ out.push(l);
+ kept_left = true;
+ }
+ if e > b && e - b >= min {
+ let mut r = c;
+ if kept_left {
+ r.id = ClipId(ctx.alloc());
+ r.cue_id = None;
+ }
+ r.start = b;
+ r.duration = e - b;
+ out.push(r);
+ }
+ }
+ tr.captions = out;
+}
+
/// Delete captions. With `ripple`, later captions on the same track move left to close each gap.
pub fn delete_captions(seq: &mut Sequence, ids: &[ClipId], ripple: bool) -> Result<usize> {
let mut n = 0;
@@ -385,6 +446,40 @@ mod tests {
assert_eq!(spans(&seq, tid), vec![(0, 40, "a".into()), (40, 80, "c".into())]);
}
+ #[test]
+ fn overwrite_cuts_splits_and_removes_what_is_under() {
+ let (mut seq, tid) = seq_with(&[(0, 100, "a"), (100, 50, "b"), (200, 100, "c")]);
+ let mut n = 1;
+ let copy = |s: i64, d: i64, t: &str| Caption {
+ id: ClipId(1),
+ start: Tick(s),
+ duration: Tick(d),
+ text: t.into(),
+ speaker: None,
+ cue_id: Some("x".into()),
+ settings: String::new(),
+ };
+ // across a's tail and all of b; then inside c (c is split around it)
+ let ids = overwrite_captions(&mut seq, tid, &[copy(60, 95, "x"), copy(230, 40, "y")], &mut ctx(&mut n)).unwrap();
+ assert_eq!(ids.len(), 2);
+ assert_eq!(spans(&seq, tid), vec![(0, 60, "a".into()), (60, 155, "x".into()), (200, 230, "c".into()), (230, 270, "y".into()), (270, 300, "c".into())]);
+ let tr = seq.caption_track(tid).unwrap();
+ assert!(tr.captions.iter().all(|c| c.cue_id.is_none()));
+ let seen: std::collections::HashSet<u64> = tr.captions.iter().map(|c| c.id.0).collect();
+ assert_eq!(seen.len(), 5, "every piece has its own id");
+ assert!(seq.check().is_ok());
+ // a sliver under one frame is dropped, not kept
+ let (mut seq, tid) = seq_with(&[(0, 100, "a")]);
+ overwrite_captions(&mut seq, tid, &[copy(5, 90, "x")], &mut ctx(&mut n)).unwrap();
+ assert_eq!(spans(&seq, tid), vec![(5, 95, "x".into())]);
+ // hostile input: before zero, overlapping copies, nothing
+ assert!(overwrite_captions(&mut seq, tid, &[copy(-5, 50, "x")], &mut ctx(&mut n)).is_err());
+ assert!(overwrite_captions(&mut seq, tid, &[copy(0, 50, "x"), copy(40, 50, "y")], &mut ctx(&mut n)).is_err());
+ assert_eq!(overwrite_captions(&mut seq, tid, &[], &mut ctx(&mut n)), Err(EditError::Nothing));
+ seq.caption_track_mut(tid).unwrap().locked = true;
+ assert_eq!(overwrite_captions(&mut seq, tid, &[copy(0, 50, "x")], &mut ctx(&mut n)), Err(EditError::Locked));
+ }
+
#[test]
fn locked_refuses() {
let (mut seq, tid) = seq_with(&[(0, 100, "a")]);
diff --git a/crates/engine/src/captions.rs b/crates/engine/src/captions.rs
index 02bddd456..d620a9f8d 100644
--- a/crates/engine/src/captions.rs
+++ b/crates/engine/src/captions.rs
@@ -467,6 +467,44 @@ pub fn commands() -> Vec<CommandSpec> {
let applied = s.edit_sequence("Move Captions", |q, _, _| Ok(edit::captions::move_captions(q, &ids, d)?))?;
Ok(json!({"applied": applied.0}))
}),
+ spec("captions.duplicate", "Duplicate Captions", &[], None, r#"{"captions":[id]?,"delta":ticks|"deltaFrames":i64}"#, has_captions, |s, p| {
+ // Option-drag in the Timeline: copies `delta` later (or earlier) on their own
+ // tracks, overwriting what is there; the originals stay
+ let mut ids = caption_ids(s, p);
+ // each caption is copied once, however often it is named
+ let mut seen = std::collections::HashSet::new();
+ ids.retain(|id| seen.insert(*id));
+ if ids.is_empty() {
+ return Err(EngineError::Edit(edit::EditError::Nothing));
+ }
+ let d = delta_p(s, p).ok_or_else(|| bad("captions.duplicate", "need `delta` or `deltaFrames`"))?;
+ let q = s.active_sequence().ok_or(EngineError::NoSequence)?;
+ let mut by_track: Vec<(TrackId, Vec<filmcraft_project::Caption>)> = Vec::new();
+ for id in &ids {
+ let (tid, c) = q.find_caption(*id).ok_or(EngineError::Edit(edit::EditError::NoItem(*id)))?;
+ match by_track.iter_mut().find(|(t, _)| *t == tid) {
+ Some((_, v)) => v.push(c.clone()),
+ None => by_track.push((tid, vec![c.clone()])),
+ }
+ }
+ // never before the start of the sequence
+ let earliest = by_track.iter().flat_map(|(_, v)| v.iter().map(|c| c.start)).min().unwrap_or_default();
+ let d = d.max(-earliest);
+ if d == Tick::ZERO {
+ return Err(EngineError::Edit(edit::EditError::Nothing));
+ }
+ let new = s.edit_sequence("Duplicate Captions", |q, ctx, st| {
+ let mut new = Vec::new();
+ for (tid, caps) in &by_track {
+ let moved: Vec<_> = caps.iter().map(|c| filmcraft_project::Caption { start: c.start + d, ..c.clone() }).collect();
+ new.extend(edit::captions::overwrite_captions(q, *tid, &moved, ctx)?);
+ }
+ st.caption_selection = new.clone();
+ st.selection.clear();
+ Ok(new)
+ })?;
+ Ok(json!({"captions": new.iter().map(|c| c.0).collect::<Vec<_>>(), "delta": d.0}))
+ }),
spec("captions.delete", "Delete Captions", &[], None, r#"{"captions":[id]?,"ripple":bool=false}"#, has_captions, |s, p| {
let ids = caption_ids(s, p);
delete(s, &ids, bool_p(p, "ripple").unwrap_or(false))
diff --git a/crates/engine/src/captions_tests.rs b/crates/engine/src/captions_tests.rs
index feb65c175..2f33951e6 100644
--- a/crates/engine/src/captions_tests.rs
+++ b/crates/engine/src/captions_tests.rs
@@ -158,3 +158,36 @@ fn caption_list_track_filter_never_falls_back_to_every_track() {
assert!(s.execute("captions.list", json!({"track": sel})).is_err(), "{sel} names no caption track");
}
}
+
+fn caption_spans(s: &Session) -> Vec<(f64, f64, String)> {
+ let secs = |t: Tick| (t.seconds() * 10.0).round() / 10.0; // the demo sequence snaps to 23.976 fps frames
+ s.active_sequence().unwrap().caption_tracks[0].captions.iter().map(|c| (secs(c.start), secs(c.end()), c.text.clone())).collect()
+}
+
+#[test]
+fn captions_duplicate_copies_and_overwrites() {
+ let mut s = demo();
+ for (sec, text) in [(1.0, "one"), (3.0, "two")] {
+ s.execute("playhead.set", json!({"seconds": sec})).unwrap();
+ s.execute("captions.add", json!({"text": text, "durationSeconds": 1.0})).unwrap();
+ }
+ let one = s.active_sequence().unwrap().caption_tracks[0].captions[0].id;
+ // Option-drag: a copy 5 s later, the original stays; the copy is selected
+ let r = s.execute("captions.duplicate", json!({"captions": [one.0], "delta": 5 * TICKS_PER_SECOND})).unwrap();
+ assert_eq!(caption_spans(&s), vec![(1.0, 2.0, "one".into()), (3.0, 4.0, "two".into()), (6.0, 7.0, "one".into())]);
+ assert_eq!(s.state.caption_selection.len(), 1);
+ assert_eq!(r["captions"][0].as_u64(), Some(s.state.caption_selection[0].0));
+ // a copy dropped half over `two` overwrites that half
+ s.execute("captions.duplicate", json!({"captions": [one.0], "delta": TICKS_PER_SECOND * 3 / 2})).unwrap();
+ assert_eq!(caption_spans(&s)[1..3], [(2.5, 3.5, "one".into()), (3.5, 4.0, "two".into())]);
+ // never before zero; zero delta is nothing
+ s.execute("captions.duplicate", json!({"captions": [one.0], "delta": -100 * TICKS_PER_SECOND})).unwrap();
+ assert_eq!(caption_spans(&s)[0], (0.0, 1.0, "one".into()));
+ assert!(s.execute("captions.duplicate", json!({"captions": [one.0], "delta": 0})).is_err());
+ assert!(s.execute("captions.duplicate", json!({"captions": [one.0]})).is_err(), "needs a delta");
+ assert!(s.execute("captions.duplicate", json!({"captions": [], "delta": TICKS_PER_SECOND})).is_err(), "needs a caption");
+ let before = s.active_sequence().unwrap().caption_tracks[0].captions.len();
+ s.execute("captions.duplicate", json!({"captions": [one.0, one.0], "delta": 20 * TICKS_PER_SECOND})).unwrap();
+ assert_eq!(s.active_sequence().unwrap().caption_tracks[0].captions.len(), before + 1, "a caption named twice is copied once");
+ s.active_sequence().unwrap().check().unwrap();
+}
diff --git a/crates/ui-egui/src/panels/timeline_captions.rs b/crates/ui-egui/src/panels/timeline_captions.rs
index 75cf0e71a..eb5869356 100644
--- a/crates/ui-egui/src/panels/timeline_captions.rs
+++ b/crates/ui-egui/src/panels/timeline_captions.rs
@@ -1,8 +1,8 @@
//! Caption track rows of the Timeline: drawn in their own area above the video tracks (Premiere's
//! layout). Each row has a header (C1…, name, format, output eye, lock) and caption blocks in a
-//! distinct colour showing their text. Click selects (Cmd/Shift adds), dragging the body moves,
-//! dragging an edge trims, the Razor tool splits (Shift: every caption track), double-click opens
-//! the Text panel's Captions tab. Every gesture ends in
+//! distinct colour showing their text. Click selects (Cmd/Shift adds), dragging the body moves
+//! the selection (Option-drag copies it), dragging an edge trims, the Razor tool splits (Shift:
+//! every caption track), double-click opens the Text panel's Captions tab. Every gesture ends in
//! one `captions.*` command; every element registers an automation id (`timeline.caption.*`,
//! `timeline.captionTrack.C1.*`).
@@ -45,10 +45,11 @@ fn drag_state(ctx: &egui::Context) -> Option<(u64, u8, i64)> {
ctx.data(|d| d.get_temp::<(u64, u8, i64)>(drag_id()))
}
-fn block_rect(c: &filmcraft_project::Caption, row: Rect, layout: &Layout, drag: Option<(u64, u8, i64)>) -> Rect {
+/// Where a caption is drawn while a drag is live: a move carries the whole selection along with
+/// the grabbed caption, a trim only the grabbed one.
+fn block_rect(c: &filmcraft_project::Caption, row: Rect, layout: &Layout, drag: Option<(u64, u8, i64)>, sel: &[ClipId]) -> Rect {
let (mut s, mut e) = (c.start, c.end());
- if let Some((id, g, d)) = drag.filter(|d| d.0 == c.id.0) {
- let _ = id;
+ if let Some((_, g, d)) = drag.filter(|d| moves_with(c.id, *d, sel)) {
match g {
0 => {
s += Tick(d);
@@ -61,6 +62,11 @@ fn block_rect(c: &filmcraft_project::Caption, row: Rect, layout: &Layout, drag:
Rect::from_min_max(pos2(layout.x_of(s), row.min.y + 2.0), pos2(layout.x_of(e).max(layout.x_of(s) + 1.0), row.max.y - 2.0))
}
+/// Whether caption `id` follows the live drag `(grabbed, gesture, delta)`.
+fn moves_with(id: ClipId, (grabbed, g, d): (u64, u8, i64), sel: &[ClipId]) -> bool {
+ d != 0 && (id.0 == grabbed || (g == 0 && sel.contains(&ClipId(grabbed)) && sel.contains(&id)))
+}
+
/// Paint headers and caption blocks.
pub fn paint(app: &mut FilmcraftApp, ui: &mut egui::Ui, seq: &Sequence, area: Rect, layout: &Layout, t: &Tokens) {
if seq.caption_tracks.is_empty() {
@@ -141,8 +147,13 @@ pub fn paint(app: &mut FilmcraftApp, ui: &mut egui::Ui, seq: &Sequence, area: Re
// caption blocks
let p = painter.with_clip_rect(lane);
let (v0, v1) = (layout.tick_at(content.min.x - 2.0), layout.tick_at(content.max.x + 2.0));
+ let copying = drag.is_some_and(|d| d.1 == 0) && ui.input(|i| i.modifiers.alt);
for c in tr.captions.iter().filter(|c| c.end() >= v0 && c.start <= v1) {
- let r = block_rect(c, row, layout, drag);
+ let r = block_rect(c, row, layout, drag, &sel);
+ // Option-drag copies: the original stays where it is under the copy being placed
+ if copying && drag.is_some_and(|d| moves_with(c.id, d, &sel)) {
+ p.rect_filled(block_rect(c, row, layout, None, &sel), 3.0, FILL);
+ }
let selected = sel.contains(&c.id);
p.rect_filled(r, 3.0, if selected { FILL_SEL } else { FILL });
if selected {
@@ -176,11 +187,12 @@ pub fn interact(app: &mut FilmcraftApp, ui: &mut egui::Ui, seq: &Sequence, area:
let ctx = ui.ctx().clone();
let rate = seq.settings.frame_rate;
let drag = drag_state(&ctx);
+ let sel = app.session.state.caption_selection.clone();
let mut actions: Vec<(String, Value)> = Vec::new();
for (tr, row) in seq.caption_tracks.iter().zip(rows(area, seq.caption_tracks.len())) {
let lane = Rect::from_min_max(pos2(layout.content.min.x, row.min.y), pos2(layout.content.max.x, row.max.y));
for c in &tr.captions {
- let r = block_rect(c, row, layout, drag).intersect(lane);
+ let r = block_rect(c, row, layout, drag, &sel).intersect(lane);
if r.width() <= 0.0 {
continue;
}
@@ -295,6 +307,9 @@ fn interact_block(
&& let (Some((id, g, _)), Some(p)) = (drag_state(&ctx), resp.interact_pointer_pos())
&& id == c.id.0
{
+ if g == 0 && ctx.input(|i| i.modifiers.alt) {
+ ctx.set_cursor_icon(CursorIcon::Copy);
+ }
let x0 = ctx.data(|d| d.get_temp::<f32>(egui::Id::new("caption-drag-origin"))).unwrap_or(p.x);
let pps = app.ui.timeline.pps;
let d = rate.snap_nearest(Tick::from_seconds_f64((p.x - x0) as f64 / pps));
@@ -314,7 +329,9 @@ fn interact_block(
} else {
vec![id]
};
- actions.push(("captions.move".into(), json!({"captions": sel, "delta": d})));
+ // Option held on the drop copies (Premiere: Option-drag duplicates)
+ let cmd = if ctx.input(|i| i.modifiers.alt) { "captions.duplicate" } else { "captions.move" };
+ actions.push((cmd.into(), json!({"captions": sel, "delta": d})));
}
1 => actions.push(("captions.trim".into(), json!({"caption": id, "edge": "in", "delta": d}))),
_ => actions.push(("captions.trim".into(), json!({"caption": id, "edge": "out", "delta": d}))),
diff --git a/crates/ui-egui/tests/it/caption_option_drag_ui.rs b/crates/ui-egui/tests/it/caption_option_drag_ui.rs
new file mode 100644
index 000000000..771ef0151
--- /dev/null
+++ b/crates/ui-egui/tests/it/caption_option_drag_ui.rs
@@ -0,0 +1,117 @@
+//! Option-drag of a caption in the Timeline leaves it where it was and drops a copy where it is
+//! released, as with clips. The real `FilmcraftApp` under `egui_kittest` with the demo project.
+
+use std::sync::mpsc::{Sender, channel};
+
+use egui::{Modifiers, Pos2, Rect, pos2};
+use egui_kittest::Harness;
+use filmcraft_engine::Session;
+use filmcraft_ui_egui::FilmcraftApp;
+use filmcraft_ui_egui::control::ControlRequest;
+use serde_json::{Value, json};
+
+struct Driver {
+ harness: Harness<'static, FilmcraftApp>,
+ tx: Sender<ControlRequest>,
+}
+
+impl Driver {
+ /// The demo project with snapping off, so drags land where the pointer goes; frames 1/60 s
+ /// apart, as on a display.
+ fn demo() -> Self {
+ let mut session = Session::default();
+ session.execute("file.openDemoProject", json!({})).expect("demo project");
+ session.execute("sequence.snap", json!({"on": false})).expect("snapping off");
+ let (tx, rx) = channel();
+ let app = FilmcraftApp::new(session).with_control(rx);
+ let harness = Harness::builder().with_size(egui::vec2(1600.0, 980.0)).with_step_dt(1.0 / 60.0).with_max_steps(10_000).build_eframe(move |_cc| app);
+ let mut d = Driver { harness, tx };
+ d.frames(4);
+ d.ok("ui.elements", json!({"prefix": "timeline.clip."}));
+ d
+ }
+
+ fn frames(&mut self, n: usize) {
+ for _ in 0..n {
+ let ctx = self.harness.ctx.clone();
+ let mut raw = std::mem::take(self.harness.input_mut());
+ eframe::App::raw_input_hook(self.harness.state_mut(), &ctx, &mut raw);
+ *self.harness.input_mut() = raw;
+ self.harness.step();
+ }
+ }
+
+ fn ok(&mut self, method: &str, params: Value) -> Value {
+ let (req, reply) = ControlRequest::new(method, params.clone());
+ self.tx.send(req).expect("control channel");
+ for _ in 0..600 {
+ self.frames(1);
+ if let Ok(v) = reply.try_recv() {
+ assert_eq!(v["ok"], json!(true), "{method} {params} failed: {v}");
+ return v["result"].clone();
+ }
+ }
+ panic!("no reply to {method} {params}");
+ }
+
+ fn exec(&mut self, command: &str, params: Value) -> Value {
+ self.ok("engine.execute", json!({"command": command, "params": params}))
+ }
+
+ fn rect(&mut self, id: &str) -> Option<Rect> {
+ self.frames(2);
+ let els = self.ok("ui.elements", json!({"prefix": id}));
+ let el = els.as_array()?.iter().find(|e| e["id"] == id)?.clone();
+ let r: Vec<f32> = el["rect"].as_array()?.iter().filter_map(|v| v.as_f64().map(|v| v as f32)).collect();
+ Some(Rect::from_min_size(pos2(*r.first()?, *r.get(1)?), egui::vec2(*r.get(2)?, *r.get(3)?)))
+ }
+
+ /// (start, end, text) of every caption on C1.
+ fn captions(&mut self) -> Vec<(i64, i64, String)> {
+ let r = self.exec("captions.list", json!({}));
+ r["tracks"][0]["captions"]
+ .as_array()
+ .expect("captions")
+ .iter()
+ .map(|c| (c["start"].as_i64().expect("start"), c["end"].as_i64().expect("end"), c["text"].as_str().expect("text").to_string()))
+ .collect()
+ }
+
+ /// Press at `from`, move to `to` over `steps` frames with `mods` held, release.
+ fn drag_with(&mut self, from: Pos2, to: Pos2, steps: usize, mods: Modifiers) {
+ let push = |d: &mut Self, e: egui::Event| d.harness.input_mut().events.push(e);
+ push(self, egui::Event::ModifiersChanged(mods));
+ push(self, egui::Event::PointerMoved(from));
+ self.frames(1);
+ push(self, egui::Event::PointerButton { pos: from, button: egui::PointerButton::Primary, pressed: true, modifiers: mods });
+ self.frames(1);
+ for i in 1..=steps {
+ push(self, egui::Event::PointerMoved(from + (to - from) * (i as f32 / steps as f32)));
+ self.frames(1);
+ }
+ push(self, egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: mods });
+ self.frames(2);
+ push(self, egui::Event::ModifiersChanged(Modifiers::NONE));
+ self.frames(1);
+ }
+}
+
+/// Option-drag of a caption leaves it where it was and drops a copy where it is released; a
+/// plain drag still moves it.
+#[test]
+fn option_drag_copies_a_caption() {
+ let mut d = Driver::demo();
+ let id = d.exec("captions.add", json!({"seconds": 1.0, "durationSeconds": 1.0, "text": "twin"}))["caption"].as_u64().expect("id");
+ let before = d.captions();
+ let r = d.rect(&format!("timeline.caption.{id}")).expect("caption block");
+ d.drag_with(r.center(), r.center() + egui::vec2(r.width() * 2.0, 0.0), 20, Modifiers::ALT);
+ let caps = d.captions();
+ assert_eq!(caps.len(), 2, "a copy was made: {caps:?}");
+ assert_eq!(caps[0], before[0], "the original stayed");
+ assert_eq!(caps[1].2, "twin");
+ assert!(caps[1].0 > before[0].1, "the copy is to the right: {caps:?}");
+ // without Option it moves
+ let r = d.rect(&format!("timeline.caption.{id}")).expect("caption block");
+ d.drag_with(r.center(), r.center() - egui::vec2(r.width() * 0.5, 0.0), 20, Modifiers::NONE);
+ assert_eq!(d.captions().len(), 2, "a plain drag does not copy");
+}
diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs
index d585570c7..3408b21da 100644
--- a/crates/ui-egui/tests/it/main.rs
+++ b/crates/ui-egui/tests/it/main.rs
@@ -1,5 +1,6 @@
mod audio51_ui;
mod audio_fx_editor_ui;
+mod caption_option_drag_ui;
mod caption_properties_ui;
mod caption_razor_ui;
mod captions_font_ui;
diff --git a/docs/captions.md b/docs/captions.md
index d54cc4dac..6e79d56b0 100644
--- a/docs/captions.md
+++ b/docs/captions.md
@@ -46,6 +46,7 @@ Details of each format and the SCC encoder are in [`crates/captions/README.md`](
| `captions.setTimes` | Text panel in/out fields | `caption`, `start…`/`end…` (`Time` ticks, `Frame`, `Seconds`, `Timecode`) |
| `captions.trim` | drag a caption edge in the timeline | `caption`, `edge` (`in`/`out`), `delta` or `deltaFrames` |
| `captions.move` | drag a caption in the timeline | `captions`, `delta` or `deltaFrames` |
+| `captions.duplicate` | ⌥-drag a caption in the timeline | `captions`, `delta` or `deltaFrames` — copies on the same tracks, overwriting what is there |
| `captions.delete` | Edit ▸ Clear / Ripple Delete with captions selected | `captions`, `ripple` |
| `captions.select`, `captions.goTo` | click / number button | `captions`, `add` / `caption` |
| `captions.setTrack` | caption track header (eye, lock) | `track`, `name`, `format`, `language`, `enabled`, `locked`, `syncLock` |
@@ -62,8 +63,9 @@ also splits captions.
## Timeline and Text panel
- Caption rows: header with `C1…` badge, lock, output eye, name and format; caption blocks in
- violet showing their text (Arabic and Hebrew in reading order from the block's right edge). Click selects (⌘/⇧ adds), drag moves, edge drag trims, the Razor tool cuts,
- double-click opens the Text panel. Automation ids: `timeline.caption.<id>`,
+ violet showing their text (Arabic and Hebrew in reading order from the block's right edge). Click selects (⌘/⇧ adds), drag moves (the whole selection; ⌥-drag
+ copies), edge drag trims, the Razor tool cuts, double-click
+ opens the Text panel. Automation ids: `timeline.caption.<id>`,
`timeline.captionTrack.C1[.locked|.enabled]`.
- **Text panel ▸ Captions**: search, track picker (also creates tracks of each format), add /
split / merge / delete / export buttons, the list of segments with editable in/out timecodes