simple_editor/
main.rs

1//! Simple Editor — a tiny, fast video trimmer/editor for Windows.
2//! `simple-editor [file]`   open a video/project
3//! `simple-editor --selftest [dir]`   headless engine check
4//! `simple-editor [file] --screenshot out.ppm`   render the UI once and save it (for visual checks)
5
6#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
7
8mod contextmenu;
9mod engine;
10mod hotkeys;
11mod mcp;
12mod media;
13mod model;
14mod playback;
15mod scripting;
16mod selftest;
17mod settings;
18mod theme;
19mod ui;
20mod winpos;
21
22use std::path::PathBuf;
23
24fn main() {
25    let args: Vec<String> = std::env::args().skip(1).collect();
26    if args.first().map(|s| s.as_str()) == Some("--selftest") {
27        std::process::exit(selftest::run(&args[1..]));
28    }
29    let mut screenshot: Option<PathBuf> = None;
30    let mut open: Option<PathBuf> = None;
31    let mut i = 0;
32    while i < args.len() {
33        match args[i].as_str() {
34            "--screenshot" => {
35                screenshot = args.get(i + 1).map(PathBuf::from);
36                i += 1;
37            }
38            // absolute: the path is stored in the project/recents and must survive a different cwd
39            a if !a.starts_with("--") && open.is_none() => {
40                open = Some(std::path::absolute(a).unwrap_or_else(|_| PathBuf::from(a)))
41            }
42            _ => {}
43        }
44        i += 1;
45    }
46
47    let options = eframe::NativeOptions {
48        viewport: eframe::egui::ViewportBuilder::default()
49            .with_title("Simple Editor")
50            .with_app_id("SimpleEditor")
51            .with_inner_size([1400.0, 860.0])
52            // hidden until the first frame is painted (App::update shows it) — otherwise the OS
53            // flashes a blank white window at the restored position before we move/paint it
54            .with_visible(false)
55            .with_min_inner_size([900.0, 560.0]),
56        persist_window: true,
57        ..Default::default()
58    };
59    if let Err(e) = eframe::run_native(
60        "Simple Editor",
61        options,
62        Box::new(move |cc| Ok(Box::new(ui::app::App::new(cc, open, screenshot)))),
63    ) {
64        eprintln!("failed to start: {e}");
65        std::process::exit(1);
66    }
67}