Start doing color handling in rust

This commit is contained in:
Greg Shuflin 2023-07-23 19:35:15 -07:00
parent c77fb9818f
commit c5bdc65923
3 changed files with 8 additions and 4 deletions

View File

@ -7,6 +7,7 @@ const VERSION: &str = "2.0.0";
extern "C" { extern "C" {
fn nmseffect_set_autodecrypt(_: c_int) -> c_void; fn nmseffect_set_autodecrypt(_: c_int) -> c_void;
fn nmseffect_set_clearscr(_: c_int) -> c_void; fn nmseffect_set_clearscr(_: c_int) -> c_void;
static mut foregroundColor: c_int;
} }
#[no_mangle] #[no_mangle]
@ -20,6 +21,12 @@ pub extern "C" fn rust_main() {
std::process::exit(0); std::process::exit(0);
} }
if let Some(ref _color) = args.foreground {
unsafe {
foregroundColor = 5;
}
}
if args.clear_screen { if args.clear_screen {
unsafe { unsafe {
nmseffect_set_clearscr(1); nmseffect_set_clearscr(1);

View File

@ -29,9 +29,6 @@ int main(int argc, char *argv[])
{ {
switch (o) switch (o)
{ {
case 'f':
nmseffect_set_foregroundcolor(optarg);
break;
case 's': case 's':
nmseffect_set_maskblank(1); nmseffect_set_maskblank(1);
break; break;

View File

@ -50,7 +50,7 @@
// Terminal IO settings // Terminal IO settings
static int clearScr = 0; // clearScr flag static int clearScr = 0; // clearScr flag
static int foregroundColor = COLOR_BLUE; // Foreground color setting int foregroundColor = COLOR_BLUE; // Foreground color setting
// Function prototypes // Function prototypes
static void nmstermio_set_terminal(int); static void nmstermio_set_terminal(int);