feat: preview opens the configured editor
This commit is contained in:
1 parent
ea986b06ab
commit
a00e39f55c
2 files changed
+86
-14
No files matched your search
+26
-2
@@ -12,6 +12,7 @@ pub struct Config {
|
||||
pub capture: Capture,
|
||||
pub preview: Preview,
|
||||
pub zoom: Zoom,
|
||||
pub editor: Editor,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
@@ -51,6 +52,21 @@ impl Default for Zoom {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize, Default)]
|
||||
#[serde(default)]
|
||||
pub struct Editor {
|
||||
pub backend: Backend,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Default)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Backend {
|
||||
/// `valw edit`.
|
||||
#[default]
|
||||
Builtin,
|
||||
Satty,
|
||||
}
|
||||
|
||||
impl Default for Preview {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -157,12 +173,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn unknown_keys_are_reported_not_rejected() {
|
||||
let text = "[editor]\nbackend = \"satty\"\n\n[save]\nfolder = \"x\"\n";
|
||||
let text = "[toolbar]\nposition = \"top\"\n\n[save]\nfolder = \"x\"\n";
|
||||
let (config, unknown) = parse(text).unwrap();
|
||||
assert_eq!(config, Config::default());
|
||||
assert_eq!(
|
||||
unknown,
|
||||
vec!["editor".to_string(), "save.folder".to_string()]
|
||||
vec!["save.folder".to_string(), "toolbar".to_string()]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -220,6 +236,14 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn editor_backend_default_and_values() {
|
||||
assert_eq!(Config::default().editor.backend, Backend::Builtin);
|
||||
let (config, _) = parse("[editor]\nbackend = \"satty\"\n").unwrap();
|
||||
assert_eq!(config.editor.backend, Backend::Satty);
|
||||
assert!(parse("[editor]\nbackend = \"gimp\"\n").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_file_gives_defaults() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in new issue
Block a user