From c5bdc659230f40373b252dc163a9ebbebd7729ef Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 23 Jul 2023 19:35:15 -0700 Subject: [PATCH] Start doing color handling in rust --- src/lib.rs | 7 +++++++ src/nms.c | 3 --- src/nmstermio.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index be1dac2..3bc8beb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,7 @@ const VERSION: &str = "2.0.0"; extern "C" { fn nmseffect_set_autodecrypt(_: c_int) -> c_void; fn nmseffect_set_clearscr(_: c_int) -> c_void; + static mut foregroundColor: c_int; } #[no_mangle] @@ -20,6 +21,12 @@ pub extern "C" fn rust_main() { std::process::exit(0); } + if let Some(ref _color) = args.foreground { + unsafe { + foregroundColor = 5; + } + } + if args.clear_screen { unsafe { nmseffect_set_clearscr(1); diff --git a/src/nms.c b/src/nms.c index 2103200..fb88fc9 100644 --- a/src/nms.c +++ b/src/nms.c @@ -29,9 +29,6 @@ int main(int argc, char *argv[]) { switch (o) { - case 'f': - nmseffect_set_foregroundcolor(optarg); - break; case 's': nmseffect_set_maskblank(1); break; diff --git a/src/nmstermio.c b/src/nmstermio.c index f4f082c..c8d0ccd 100644 --- a/src/nmstermio.c +++ b/src/nmstermio.c @@ -50,7 +50,7 @@ // Terminal IO settings static int clearScr = 0; // clearScr flag -static int foregroundColor = COLOR_BLUE; // Foreground color setting +int foregroundColor = COLOR_BLUE; // Foreground color setting // Function prototypes static void nmstermio_set_terminal(int);