From 1e87c76689e7d3f27ece79c795a64cec810d9cba Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 23 Jul 2023 20:13:44 -0700 Subject: [PATCH] Handle maskblank in rust --- src/args.rs | 4 ++++ src/lib.rs | 8 ++++++++ src/nms.c | 3 --- src/nmseffect.c | 13 +------------ src/nmseffect.h | 1 - 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/args.rs b/src/args.rs index b3f7b43..c2d57e5 100644 --- a/src/args.rs +++ b/src/args.rs @@ -13,6 +13,10 @@ pub(crate) struct Args { ///"green", "red", and "cyan". pub(crate) foreground: Option, pub(crate) autodecrypt: bool, + + /// Set the maskBlank flag according to the true/false value of the + /// 'setting' argument. When set to true, blank spaces characters + /// will be masked as well. pub(crate) mask_blanks: bool, } diff --git a/src/lib.rs b/src/lib.rs index 1e962a5..970d0c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ extern "C" { fn nmseffect_set_autodecrypt(_: c_int) -> c_void; fn nmseffect_set_clearscr(_: c_int) -> c_void; static mut foregroundColor: c_int; + static mut maskBlank: c_int; } #[no_mangle] @@ -38,6 +39,13 @@ pub extern "C" fn rust_main() { foregroundColor = n; } } + unsafe { + if args.mask_blanks { + maskBlank = 1; + } else { + maskBlank = 0; + } + } if args.clear_screen { unsafe { diff --git a/src/nms.c b/src/nms.c index fb88fc9..9273140 100644 --- a/src/nms.c +++ b/src/nms.c @@ -29,9 +29,6 @@ int main(int argc, char *argv[]) { switch (o) { - case 's': - nmseffect_set_maskblank(1); - break; case '?': if (isprint(optopt)) { diff --git a/src/nmseffect.c b/src/nmseffect.c index dddc36f..068a614 100644 --- a/src/nmseffect.c +++ b/src/nmseffect.c @@ -33,7 +33,7 @@ // Behavior settings static int autoDecrypt = 0; // Auto-decrypt flag -static int maskBlank = 0; // Mask blank spaces +int maskBlank = 0; // Mask blank spaces static int colorOn = 1; // Terminal color flag // Character attribute structure, linked list. Keeps track of every @@ -302,17 +302,6 @@ void nmseffect_set_autodecrypt(int setting) { autoDecrypt = 0; } -/* - * Set the maskBlank flag according to the true/false value of the - * 'setting' argument. When set to true, blank spaces characters - * will be masked as well. - */ -void nmseffect_set_maskblank(int setting) { - if (setting) - maskBlank = 1; - else - maskBlank = 0; -} /* * Pass the 'setting' argument to the nmstermio module where it will set diff --git a/src/nmseffect.h b/src/nmseffect.h index 514b583..ba93031 100644 --- a/src/nmseffect.h +++ b/src/nmseffect.h @@ -12,7 +12,6 @@ char nmseffect_exec(unsigned char *, int string_len); void nmseffect_set_returnopts(char *); void nmseffect_set_autodecrypt(int); -void nmseffect_set_maskblank(int); void nmseffect_set_clearscr(int); void nmseffect_use_color(int); void nmseffect_set_input_position(int, int);