diff --git a/README.md b/README.md index 7b5bc6f..19e66b3 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ scroll_step = 1.15 flashlight_radius = 180 [editor] -backend = "builtin" # or "satty" +backend = "builtin" # or "satty", or "noctalia" (its annotator) [sound] enabled = true diff --git a/docs/test-checklist.md b/docs/test-checklist.md index 87ab451..2be5fbe 100644 --- a/docs/test-checklist.md +++ b/docs/test-checklist.md @@ -80,6 +80,7 @@ image, a cancel brought the thumbnail back, and a swipe still dismissed it. ## Editor (Phase 5a) - [ ] Clicking a preview opens `valw edit` (title ` — valw`); `[editor] backend = "satty"` still opens Satty. +- [ ] `[editor] backend = "noctalia"`: clicking a preview opens the shot in Noctalia's annotator, in the Noctalia theme; Save writes a new "annotated" file in the screenshots folder (the shot stays as it was), Copy puts the result on the clipboard. - [ ] Each tool draws (arrow head at the release point, outline rectangle/ellipse, line, pen dot on a click, translucent highlighter); Shift snaps lines to 45° and makes squares/circles. - [ ] Colours and S/M/L change new shapes only; A/R/O/L/P/H switch tools. - [ ] Ctrl+Z / Ctrl+Shift+Z / Ctrl+Y and the toolbar buttons undo and redo. diff --git a/src/config.rs b/src/config.rs index 89f2226..37e618d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -68,6 +68,9 @@ pub enum Backend { #[default] Builtin, Satty, + /// Noctalia's annotator: it saves a new "annotated" file instead of + /// overwriting the shot. + Noctalia, } #[derive(Debug, Clone, PartialEq, Deserialize)] @@ -285,6 +288,8 @@ mod tests { assert_eq!(Config::default().editor.backend, Backend::Builtin); let (config, _) = parse("[editor]\nbackend = \"satty\"\n").unwrap(); assert_eq!(config.editor.backend, Backend::Satty); + let (config, _) = parse("[editor]\nbackend = \"noctalia\"\n").unwrap(); + assert_eq!(config.editor.backend, Backend::Noctalia); assert!(parse("[editor]\nbackend = \"gimp\"\n").is_err()); } diff --git a/src/host.rs b/src/host.rs index dd27a80..16e2b74 100644 --- a/src/host.rs +++ b/src/host.rs @@ -501,8 +501,9 @@ fn add(state: &mut State, path: &Path, output_name: &str) -> Result<()> { Ok(()) } -/// The command that opens `path` in the configured editor; both save over -/// the file. +/// The command that opens `path` in the configured editor. The built-in +/// editor and Satty save over the file; Noctalia's annotator saves a new +/// one next to it (or copies), leaving the shot as it was. fn editor_command(backend: Backend, path: &Path, exe: &Path) -> std::process::Command { let mut command = match backend { Backend::Builtin => { @@ -518,6 +519,11 @@ fn editor_command(backend: Backend, path: &Path, exe: &Path) -> std::process::Co .arg(path); c } + Backend::Noctalia => { + let mut c = std::process::Command::new("noctalia"); + c.args(["msg", "annotate"]).arg(path); + c + } }; command .stdin(std::process::Stdio::null()) @@ -573,6 +579,12 @@ mod tests { "/p/Shot 1.png" ] ); + let noctalia = editor_command(Backend::Noctalia, path, exe); + assert_eq!(noctalia.get_program(), "noctalia"); + assert_eq!( + noctalia.get_args().collect::>(), + ["msg", "annotate", "/p/Shot 1.png"] + ); } #[test]