mask blank as arg

This commit is contained in:
Greg Shuflin 2023-07-25 23:46:31 -07:00
parent fa3bbfff58
commit 7ee23cd20d
3 changed files with 10 additions and 13 deletions

View File

@ -12,9 +12,13 @@ const VERSION: &str = "2.0.0";
extern "C" { extern "C" {
fn nmseffect_set_clearscr(_: c_int) -> c_void; fn nmseffect_set_clearscr(_: c_int) -> c_void;
fn nmseffect_exec(input: *const c_char, len: c_int, autodecrypt_c: c_int) -> c_char; fn nmseffect_exec(
input: *const c_char,
len: c_int,
autodecrypt_c: c_int,
maskblank_c: c_int,
) -> c_char;
static mut foregroundColor: c_int; static mut foregroundColor: c_int;
static mut maskBlank: c_int;
} }
///Sleep for the number of milliseconds indicated by argument ///Sleep for the number of milliseconds indicated by argument
@ -61,13 +65,7 @@ pub extern "C" fn rust_main() {
foregroundColor = n; foregroundColor = n;
} }
} }
unsafe { let maskblank_c = if args.mask_blanks { 1 } else { 0 };
if args.mask_blanks {
maskBlank = 1;
} else {
maskBlank = 0;
}
}
if args.clear_screen { if args.clear_screen {
unsafe { unsafe {
@ -85,7 +83,7 @@ pub extern "C" fn rust_main() {
let output_cstring = CString::new(output).unwrap(); let output_cstring = CString::new(output).unwrap();
let ptr = output_cstring.as_ptr(); let ptr = output_cstring.as_ptr();
let len = output_cstring.as_bytes().len(); let len = output_cstring.as_bytes().len();
let _r = unsafe { nmseffect_exec(ptr, len as i32, autodecrypt_c) }; let _r = unsafe { nmseffect_exec(ptr, len as i32, autodecrypt_c, maskblank_c) };
} }
fn get_input(prompt: &str) -> String { fn get_input(prompt: &str) -> String {

View File

@ -32,7 +32,6 @@
#define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop #define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop
// Behavior settings // Behavior settings
int maskBlank = 0; // Mask blank spaces
const int colorOn = 1; // Terminal color flag - nothing actually sets this to be false ever const int colorOn = 1; // Terminal color flag - nothing actually sets this to be false ever
// Character attribute structure, linked list. Keeps track of every // Character attribute structure, linked list. Keeps track of every
@ -54,7 +53,7 @@ extern void nmseffect_sleep(int);
* string that is provided as an argument. It returns the last character * string that is provided as an argument. It returns the last character
* pressed by the user. * pressed by the user.
*/ */
char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt) { char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt, int maskBlank) {
struct charAttr *list_pointer = NULL; struct charAttr *list_pointer = NULL;
struct charAttr *list_head = NULL; struct charAttr *list_head = NULL;
struct charAttr *list_temp = NULL; struct charAttr *list_temp = NULL;

View File

@ -9,7 +9,7 @@
#define NMSEFFECT_H 1 #define NMSEFFECT_H 1
// Function prototypes // Function prototypes
char nmseffect_exec(unsigned char *, int string_len, int autoDecrypt); char nmseffect_exec(unsigned char *, int string_len, int autoDecrypt, int maskblank);
void nmseffect_set_returnopts(char *); void nmseffect_set_returnopts(char *);
void nmseffect_set_clearscr(int); void nmseffect_set_clearscr(int);
void nmseffect_use_color(int); void nmseffect_use_color(int);