summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2022-08-07 08:48:38 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2022-08-08 23:10:36 +0200
commita3a177159085b7a26d79fb39e2ddda653aac766a (patch)
tree6dbf1fab365b21fc3c9cf96260de0505d36610ef
parent3f394af544db5075a8042cf6a45ba4ead85b1601 (diff)
downloadvtcol-a3a177159085b7a26d79fb39e2ddda653aac766a.tar.gz
bin: prepare for scheme editor
Optionally build against slint (sixtyfps) to provide an “edit” subcommand.
-rw-r--r--Cargo.toml2
-rw-r--r--src/vtcol.rs25
2 files changed, 27 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index ac7f62c..6aca9fc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,9 +18,11 @@ libc = "0.2"
clap = { version = "2.33", optional = true }
anyhow = { version = "1.0", optional = true }
base64 = "0.13"
+slint = { version = "0.2", optional = true }
[features]
vtcol-bin = [ "anyhow", "clap" ]
+gui = [ "vtcol-bin", "slint" ]
[[bin]]
name = "vtcol"
diff --git a/src/vtcol.rs b/src/vtcol.rs
index 8b86e07..122b471 100644
--- a/src/vtcol.rs
+++ b/src/vtcol.rs
@@ -463,6 +463,17 @@ impl<'a> Job
),
)
.subcommand(
+ SubCommand::with_name("edit")
+ .about("launch a graphical color scheme editor")
+ .arg(
+ Arg::with_name("scheme")
+ .help("name of the scheme to edit")
+ .required(false)
+ .value_name("NAME")
+ .takes_value(true),
+ ),
+ )
+ .subcommand(
SubCommand::with_name("list")
.about("list builtin schemes"),
)
@@ -786,6 +797,20 @@ impl<'a> Job
}
Err(anyhow!("dump requires an argument"))
},
+ ("edit", Some(subm)) => {
+ #[cfg(feature = "gui")]
+ if let Some(name) = subm.value_of("scheme") {
+ let scm = Scheme::from(name);
+ Ok(Self(con, Subcmd::Colors(ColorJob::Dump(scm))))
+ } else {
+ todo!() /* generate generic name */
+ }
+ #[cfg(not(feature = "gui"))]
+ Err(anyhow!(
+ "the ``edit'' subcommand requires vtcol to be \
+ built with the the ``gui'' feature"
+ ))
+ },
("list", _) =>
Ok(Self(con, Subcmd::Colors(ColorJob::List))),
("set", Some(subm)) => {