Skip to content

Commit 41fbf10

Browse files
committed
add --vt100 param
1 parent 0cec77c commit 41fbf10

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/main.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@
1111

1212
typedef struct parameter{
1313

14-
bool showAll; //--all shows all available ascii codes
15-
bool showAllDigits; //--digits shows all digits ascii codes
16-
bool showAllAlphas; //--alphas shows all alphabets ascii codes
17-
18-
bool onlyOct; //--octa shows only octa in output table
19-
bool onlyDec; //--dec shows only dec in output table
20-
bool onlyHex; //--hex shows only hex in output table
21-
bool onlyChar; //
22-
bool _onlyAll; // if all only* 4 are false this will be set to true
14+
bool showAll; //--all shows all available ascii codes
15+
bool showAllDigits; //--digits shows all digits ascii codes
16+
bool showAllAlphas; //--alphas shows all alphabets ascii codes
17+
18+
bool onlyOct; //--octa shows only octa in output table
19+
bool onlyDec; //--dec shows only dec in output table
20+
bool onlyHex; //--hex shows only hex in output table
21+
22+
bool onlyChar; // hardcoded and set to true(1) always shows `chr` column
23+
bool _onlyAll; // if all only* 3 are false this will be set to true
2324

24-
char* content; // " " content / data
25+
char* content; // " " content / data (user input)
2526

26-
uint8_t order; //0 - default , 1 - ascending, 3 - desending ordered output table
27+
uint8_t order; //0 - default , (--asc)1 - ascending, (--des)2 - desending ordered output table
28+
bool color; //--vt100 register ansi vt100 escape sequence color to the terminal
2729

2830
}asciiParams;
2931

@@ -92,6 +94,8 @@ asciiParams parseParameter(int argv, char** args){
9294
else if(strcmp(args[i],"--asc")==0) params.order = 1;
9395
else if(strcmp(args[i],"--des")==0) params.order = 2;
9496

97+
else if(strcmp(args[i],"--vt100")==0) params.color = true;
98+
9599
}
96100

97101
params.onlyChar = 1; //hardcoded;
@@ -129,7 +133,7 @@ void manipulateData(asciiParams *params){
129133
}
130134

131135
void printData(asciiParams params){
132-
136+
133137
size_t s = 0;char se_line[20] = "";
134138
if(params._onlyAll) printf("Oct Dec Hex "YEL"Chr"RESET"\n------------------\n");
135139
else{
@@ -166,6 +170,11 @@ int main(int argv, char** args){
166170

167171
asciiParams params = parseParameter(argv, args);
168172

173+
if(params.color){
174+
system("REG ADD HKCU\\CONSOLE /f /v VirtualTerminalLevel /t REG_DWORD /d 1");
175+
return 0;
176+
}
177+
169178
if(params.showAll){
170179
splashScreen();
171180
return 0;

0 commit comments

Comments
 (0)