From a3a177159085b7a26d79fb39e2ddda653aac766a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Aug 2022 08:48:38 +0200 Subject: bin: prepare for scheme editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Optionally build against slint (sixtyfps) to provide an “edit” subcommand. --- Cargo.toml | 2 ++ src/vtcol.rs | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) 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 @@ -462,6 +462,17 @@ impl<'a> Job .takes_value(true), ), ) + .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)) => { -- cgit v1.2.3