Merge pull request #52 from livz/master
Add option to mask blank spaces
This commit is contained in:
commit
d87094bde1
@ -89,6 +89,7 @@ enjoy the magic. In the below examples, I use a simple directory listing.
|
|||||||
```
|
```
|
||||||
ls -l | nms
|
ls -l | nms
|
||||||
ls -l | nms -a // Set auto-decrypt flag
|
ls -l | nms -a // Set auto-decrypt flag
|
||||||
|
ls -l | nms -s // Set mask blanks flag
|
||||||
ls -l | nms -f green // Set foreground color to green
|
ls -l | nms -f green // Set foreground color to green
|
||||||
ls -l | nms -c // Clear screen
|
ls -l | nms -c // Clear screen
|
||||||
nms -v // Display version
|
nms -v // Display version
|
||||||
|
3
nms.6
3
nms.6
@ -11,6 +11,9 @@ nms [options]
|
|||||||
.B -a
|
.B -a
|
||||||
sets the auto-decrypt flag, decryption sequence starts without requiring a key press.
|
sets the auto-decrypt flag, decryption sequence starts without requiring a key press.
|
||||||
.TP
|
.TP
|
||||||
|
.B -s
|
||||||
|
sets the mask blanks flag. Blank spaces will be encrypted and decrypted.
|
||||||
|
.TP
|
||||||
.B -c
|
.B -c
|
||||||
clear the screen prior to printing any output
|
clear the screen prior to printing any output
|
||||||
.TP
|
.TP
|
||||||
|
@ -19,7 +19,7 @@ int main(int argc, char *argv[]) {
|
|||||||
char *input = NULL;
|
char *input = NULL;
|
||||||
|
|
||||||
// Processing command arguments
|
// Processing command arguments
|
||||||
while ((o = getopt(argc, argv, "f:acv")) != -1) {
|
while ((o = getopt(argc, argv, "f:ascv")) != -1) {
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case 'f':
|
case 'f':
|
||||||
nmseffect_set_foregroundcolor(optarg);
|
nmseffect_set_foregroundcolor(optarg);
|
||||||
@ -27,6 +27,9 @@ int main(int argc, char *argv[]) {
|
|||||||
case 'a':
|
case 'a':
|
||||||
nmseffect_set_autodecrypt(1);
|
nmseffect_set_autodecrypt(1);
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
nmseffect_set_maskblank(1);
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
nmseffect_set_clearscr(1);
|
nmseffect_set_clearscr(1);
|
||||||
break;
|
break;
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
// Behavior settings
|
// Behavior settings
|
||||||
static char *returnOpts = NULL; // Return option setting
|
static char *returnOpts = NULL; // Return option setting
|
||||||
static int autoDecrypt = 0; // Auto-decrypt flag
|
static int autoDecrypt = 0; // Auto-decrypt flag
|
||||||
|
static int maskBlank = 0; // Mask blank spaces
|
||||||
static int colorOn = 1; // Terminal color flag
|
static int colorOn = 1; // Terminal color flag
|
||||||
static int inputPositionX = -1; // X coordinate for input position
|
static int inputPositionX = -1; // X coordinate for input position
|
||||||
static int inputPositionY = -1; // Y coordinate for input position
|
static int inputPositionY = -1; // Y coordinate for input position
|
||||||
@ -136,10 +137,15 @@ char nmseffect_exec(char *string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set flag if we have a whitespace character
|
// Set flag if we have a whitespace character
|
||||||
if (strlen(list_pointer->source) == 1 && isspace(list_pointer->source[0]))
|
if (strlen(list_pointer->source) == 1 && isspace(list_pointer->source[0])) {
|
||||||
list_pointer->is_space = 1;
|
// If flag is enabled, mask blank spaces as well
|
||||||
else
|
if (maskBlank && (list_pointer->source[0] == ' '))
|
||||||
list_pointer->is_space = 0;
|
list_pointer->is_space = 0;
|
||||||
|
else
|
||||||
|
list_pointer->is_space = 1;
|
||||||
|
} else {
|
||||||
|
list_pointer->is_space = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Set initial mask chharacter
|
// Set initial mask chharacter
|
||||||
list_pointer->mask = nmscharset_get_random();
|
list_pointer->mask = nmscharset_get_random();
|
||||||
@ -349,6 +355,18 @@ 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
|
||||||
* the clearScr flag according to the true/false value. When set to true,
|
* the clearScr flag according to the true/false value. When set to true,
|
||||||
|
@ -13,6 +13,7 @@ char nmseffect_exec(char *);
|
|||||||
void nmseffect_set_foregroundcolor(char *);
|
void nmseffect_set_foregroundcolor(char *);
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user