editor: noctalia backend (noctalia msg annotate)
This commit is contained in:
1 parent
210c9f4260
commit
4bf53289ea
4 files changed
+21
-3
No files matched your search
@@ -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
@@ -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]
|
||||
|
||||
Reference in new issue
Block a user