mirror of
https://github.com/PoetryInCode/ViewBin.git
synced 2026-08-13 11:24:38 -04:00
colorizing output
This commit is contained in:
parent
f3f3d564de
commit
37265430dc
10
viewbin.c
10
viewbin.c
@ -104,13 +104,17 @@ int main(int argc, char **argv) {
|
||||
fread(text,sizeof(char),length,file);
|
||||
int i=0,byte_index=0,bytes_shown=0;
|
||||
while(i < lines) {
|
||||
printf("[%08x]> ",byte_index);
|
||||
printf("\033[33m[%08x]>\033[39m ",byte_index);
|
||||
int a=0;
|
||||
bytes_shown=0;
|
||||
while(a<max_per_row) {
|
||||
if(text <= end) {
|
||||
if(print_mode == HEX) {
|
||||
if(*text == (char)0x00) {
|
||||
printf("\033[90m00 \033[39m");
|
||||
} else {
|
||||
printf("%x%x ",(char)(*text & 0x0F),(char)(*text >> 4 & 0x0F));
|
||||
}
|
||||
} else if(print_mode == INT) {
|
||||
printf("%08i ",(int)*text);
|
||||
} else if(print_mode == CHAR) {
|
||||
@ -143,9 +147,9 @@ int main(int argc, char **argv) {
|
||||
i++;
|
||||
}
|
||||
if((12+(bytes_shown*chunk_size)+11) < width) {
|
||||
printf("<[%08x]",byte_index);
|
||||
printf("\033[33m<[%08x]\033[39m",byte_index);
|
||||
} else {
|
||||
printf("\n<[%08x]",byte_index);
|
||||
printf("\n\033[33m<[%08x]\033[39m",byte_index);
|
||||
}
|
||||
free((void *)original);
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user