Messing with clear screen

This commit is contained in:
Greg Shuflin 2023-11-12 11:20:13 -08:00
parent ea5efdcf69
commit 297c1aedb9
6 changed files with 11 additions and 25 deletions

View File

@ -11,12 +11,13 @@ use color::Color;
const VERSION: &str = "2.0.0";
extern "C" {
fn nmseffect_set_clearscr(_: c_int) -> c_void;
fn nmstermio_set_clearscr(_: c_int);
fn nmseffect_exec(
input: *const c_char,
len: c_int,
autodecrypt_c: c_int,
maskblank_c: c_int,
clear_scr: c_int,
) -> c_char;
static mut foregroundColor: c_int;
}
@ -68,7 +69,7 @@ pub extern "C" fn rust_main() {
if args.clear_screen {
unsafe {
nmseffect_set_clearscr(1);
nmstermio_set_clearscr(2);
}
}
@ -79,10 +80,10 @@ pub extern "C" fn rust_main() {
process::exit(1);
}
exec_effect(input, args.autodecrypt, args.mask_blanks);
exec_effect(input, args.autodecrypt, args.mask_blanks, args.clear_screen);
}
fn exec_effect(input: String, autodecrypt: bool, maskblank: bool) {
fn exec_effect(input: String, autodecrypt: bool, maskblank: bool, clear_screen: bool) {
let maskblank_c = if maskblank { 1 } else { 0 };
let autodecrypt_c = if autodecrypt { 1 } else { 0};
@ -90,7 +91,8 @@ fn exec_effect(input: String, autodecrypt: bool, maskblank: bool) {
let output_cstring = CString::new(input).unwrap();
let ptr = output_cstring.as_ptr();
let len = output_cstring.as_bytes().len();
let _r = unsafe { nmseffect_exec(ptr, len as i32, autodecrypt_c, maskblank_c) };
let clear = if clear_screen { 1 } else { 0 };
let _r = unsafe { nmseffect_exec(ptr, len as i32, autodecrypt_c, maskblank_c, clear) };
}

View File

@ -53,7 +53,7 @@ extern void nmseffect_sleep(int);
* string that is provided as an argument. It returns the last character
* pressed by the user.
*/
char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt, int maskBlank) {
char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt, int maskBlank, int clear_screen) {
struct charAttr *list_pointer = NULL;
struct charAttr *list_head = NULL;
struct charAttr *list_temp = NULL;
@ -70,7 +70,7 @@ char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt, int
// Initialize terminal
nmstermio_init_terminal();
if (!nmstermio_get_clearscr()) {
if (!clear_screen) {
// Get current row position
origRow = nmstermio_get_cursor_row();
@ -269,7 +269,7 @@ char nmseffect_exec(unsigned char *string, int string_len, int autoDecrypt, int
nmstermio_clear_input();
if (nmstermio_get_clearscr()) {
if (clear_screen) {
nmstermio_get_char();
}

View File

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

View File

@ -206,14 +206,6 @@ void nmstermio_beep(void) {
BEEP();
}
/*
* Return the status of the clearScr flag. This is used by the nmseffect
* module to make certain decisions based on its value.
*/
int nmstermio_get_clearscr(void) {
return clearScr;
}
/*
* Sets the clearScr flag according to the true/false value of the 's' argument.
*/

View File

@ -22,7 +22,6 @@ char nmstermio_get_char(void);
void nmstermio_print_reveal_string(char *, int);
void nmstermio_show_cursor(void);
void nmstermio_beep(void);
int nmstermio_get_clearscr(void);
void nmstermio_set_clearscr(int);
int nmstermio_get_cursor_row(void);

View File

@ -140,13 +140,6 @@ void nmstermio_beep(void) {
beep();
}
/*
* Return the status of the clearScr flag. This is used by the nmseffect
* module to make certain decisions based on its value.
*/
int nmstermio_get_clearscr(void) {
return clearScr;
}
/*
* Sets the clearScr flag according to the true/false value of the 's' argument.