summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2022-08-07 09:25:07 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2022-08-08 23:10:36 +0200
commit48342e5bc46380d977edf178e31ad518eac7bd20 (patch)
tree01e9757585877d03465c926dbe5f64997b70a35b
parenta3a177159085b7a26d79fb39e2ddda653aac766a (diff)
downloadvtcol-48342e5bc46380d977edf178e31ad518eac7bd20.tar.gz
edit: set up a rudimentary 60fps window
Not much to see yet.
-rw-r--r--src/vtcol.rs40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/vtcol.rs b/src/vtcol.rs
index 122b471..f12af09 100644
--- a/src/vtcol.rs
+++ b/src/vtcol.rs
@@ -2,6 +2,8 @@
pub mod lib;
+#[cfg(feature = "gui")] pub mod edit;
+
use vtcol::{Console, Fade, KbLedFlags, KbLedState, Palette, Scheme};
use anyhow::{anyhow, Result};
@@ -251,6 +253,8 @@ enum ColorJob
List,
/** Dump a scheme. */
Dump(Scheme),
+ /** Launch scheme editor. */
+ Edit(Option<String>, Scheme),
/** Switch to color scheme. */
Set(Scheme),
/** Get currently active scheme. */
@@ -267,6 +271,7 @@ impl Run for ColorJob
{
match self {
Self::Dump(scm) => Self::dump(scm),
+ Self::Edit(name, scm) => Self::edit(name, scm),
Self::List => Self::list(),
Self::Set(scm) => Self::set(console, scm),
Self::Get(b64) => Self::get(console, b64),
@@ -321,6 +326,25 @@ impl ColorJob
}
}
+ #[cfg(feature = "gui")]
+ fn edit(name: Option<String>, scm: Scheme) -> Result<()>
+ {
+ vrb!("Launching color scheme editor for scheme {}", scm);
+ let editor = crate::edit::Edit::new();
+
+ editor.run(name, scm)
+ }
+
+ #[cfg(not(feature = "gui"))]
+ fn edit(scm: Scheme) -> Result<()>
+ {
+ eprintln!(
+ "scheme editor not available; try recompiling vtcol with \
+ --features=gui!"
+ );
+ Err(anyhow!("editor not available"))
+ }
+
fn set(con: Option<String>, scheme: Scheme) -> Result<()>
{
let fd = open_console(con.as_deref())?;
@@ -801,9 +825,21 @@ impl<'a> Job
#[cfg(feature = "gui")]
if let Some(name) = subm.value_of("scheme") {
let scm = Scheme::from(name);
- Ok(Self(con, Subcmd::Colors(ColorJob::Dump(scm))))
+ Ok(Self(
+ con,
+ Subcmd::Colors(ColorJob::Edit(
+ Some(name.to_string()),
+ scm,
+ )),
+ ))
} else {
- todo!() /* generate generic name */
+ Ok(Self(
+ con,
+ Subcmd::Colors(ColorJob::Edit(
+ None,
+ Scheme::from("default"),
+ )),
+ ))
}
#[cfg(not(feature = "gui"))]
Err(anyhow!(