editor: noctalia backend (noctalia msg annotate)

This commit is contained in:
elwrcl committed 2026-10-04 17:49:33 +03:00
1 parent 210c9f4260
commit 4bf53289ea
4 files changed
+21 -3

No files matched your search

+1 -1
View File
@@ -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
+1
View File
@@ -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 `<name> — 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.
+5
View File
@@ -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());
}
+14 -2
View File
@@ -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::<Vec<_>>(),
["msg", "annotate", "/p/Shot 1.png"]
);
}
#[test]