Handle maskblank in rust

This commit is contained in:
Greg Shuflin 2023-07-23 20:13:44 -07:00
parent 2841625b15
commit 1e87c76689
5 changed files with 13 additions and 16 deletions

View File

@ -13,6 +13,10 @@ pub(crate) struct Args {
///"green", "red", and "cyan". ///"green", "red", and "cyan".
pub(crate) foreground: Option<OsString>, pub(crate) foreground: Option<OsString>,
pub(crate) autodecrypt: bool, 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, pub(crate) mask_blanks: bool,
} }

View File

@ -11,6 +11,7 @@ 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; static mut foregroundColor: c_int;
static mut maskBlank: c_int;
} }
#[no_mangle] #[no_mangle]
@ -38,6 +39,13 @@ pub extern "C" fn rust_main() {
foregroundColor = n; foregroundColor = n;
} }
} }
unsafe {
if args.mask_blanks {
maskBlank = 1;
} else {
maskBlank = 0;
}
}
if args.clear_screen { if args.clear_screen {
unsafe { unsafe {

View File

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

View File

@ -33,7 +33,7 @@
// Behavior settings // Behavior settings
static int autoDecrypt = 0; // Auto-decrypt flag 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 static int colorOn = 1; // Terminal color flag
// Character attribute structure, linked list. Keeps track of every // Character attribute structure, linked list. Keeps track of every
@ -302,17 +302,6 @@ void nmseffect_set_autodecrypt(int setting) {
autoDecrypt = 0; 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 * Pass the 'setting' argument to the nmstermio module where it will set

View File

@ -12,7 +12,6 @@
char nmseffect_exec(unsigned char *, int string_len); char nmseffect_exec(unsigned char *, int string_len);
void nmseffect_set_returnopts(char *); void nmseffect_set_returnopts(char *);
void nmseffect_set_autodecrypt(int); void nmseffect_set_autodecrypt(int);
void nmseffect_set_maskblank(int);
void nmseffect_set_clearscr(int); void nmseffect_set_clearscr(int);
void nmseffect_use_color(int); void nmseffect_use_color(int);
void nmseffect_set_input_position(int, int); void nmseffect_set_input_position(int, int);