mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Enhance highlighting of semi-large and large numbers
This commit is contained in:
parent
c7568bc054
commit
40441dca8e
6
CRT.c
6
CRT.c
@ -98,6 +98,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[PROCESS_SHADOW] = A_BOLD | ColorPairGrayBlack,
|
||||
[PROCESS_TAG] = A_BOLD | ColorPair(Yellow,Black),
|
||||
[PROCESS_MEGABYTES] = ColorPair(Cyan,Black),
|
||||
[PROCESS_GIGABYTES] = ColorPair(Green,Black),
|
||||
[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan,Black),
|
||||
[PROCESS_TREE] = ColorPair(Cyan,Black),
|
||||
[PROCESS_R_STATE] = ColorPair(Green,Black),
|
||||
@ -167,6 +168,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[PROCESS_SHADOW] = A_DIM,
|
||||
[PROCESS_TAG] = A_BOLD,
|
||||
[PROCESS_MEGABYTES] = A_BOLD,
|
||||
[PROCESS_GIGABYTES] = A_BOLD,
|
||||
[PROCESS_BASENAME] = A_BOLD,
|
||||
[PROCESS_TREE] = A_BOLD,
|
||||
[PROCESS_R_STATE] = A_BOLD,
|
||||
@ -236,6 +238,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[PROCESS_SHADOW] = A_BOLD | ColorPair(Black,White),
|
||||
[PROCESS_TAG] = ColorPair(White,Blue),
|
||||
[PROCESS_MEGABYTES] = ColorPair(Blue,White),
|
||||
[PROCESS_GIGABYTES] = ColorPair(Green,White),
|
||||
[PROCESS_BASENAME] = ColorPair(Blue,White),
|
||||
[PROCESS_TREE] = ColorPair(Green,White),
|
||||
[PROCESS_R_STATE] = ColorPair(Green,White),
|
||||
@ -305,6 +308,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[PROCESS_SHADOW] = A_BOLD | ColorPairGrayBlack,
|
||||
[PROCESS_TAG] = ColorPair(White,Blue),
|
||||
[PROCESS_MEGABYTES] = ColorPair(Blue,Black),
|
||||
[PROCESS_GIGABYTES] = ColorPair(Green,Black),
|
||||
[PROCESS_BASENAME] = ColorPair(Green,Black),
|
||||
[PROCESS_TREE] = ColorPair(Blue,Black),
|
||||
[PROCESS_R_STATE] = ColorPair(Green,Black),
|
||||
@ -374,6 +378,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[PROCESS_SHADOW] = A_BOLD | ColorPair(Black,Blue),
|
||||
[PROCESS_TAG] = A_BOLD | ColorPair(Yellow,Blue),
|
||||
[PROCESS_MEGABYTES] = ColorPair(Cyan,Blue),
|
||||
[PROCESS_GIGABYTES] = ColorPair(Green,Blue),
|
||||
[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan,Blue),
|
||||
[PROCESS_TREE] = ColorPair(Cyan,Blue),
|
||||
[PROCESS_R_STATE] = ColorPair(Green,Blue),
|
||||
@ -443,6 +448,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[PROCESS_SHADOW] = A_BOLD | ColorPairGrayBlack,
|
||||
[PROCESS_TAG] = A_BOLD | ColorPair(Yellow,Black),
|
||||
[PROCESS_MEGABYTES] = A_BOLD | ColorPair(Green,Black),
|
||||
[PROCESS_GIGABYTES] = A_BOLD | ColorPair(Yellow,Black),
|
||||
[PROCESS_BASENAME] = A_BOLD | ColorPair(Green,Black),
|
||||
[PROCESS_TREE] = ColorPair(Cyan,Black),
|
||||
[PROCESS_THREAD] = ColorPair(Green,Black),
|
||||
|
1
CRT.h
1
CRT.h
@ -58,6 +58,7 @@ typedef enum ColorElements_ {
|
||||
PROCESS_SHADOW,
|
||||
PROCESS_TAG,
|
||||
PROCESS_MEGABYTES,
|
||||
PROCESS_GIGABYTES,
|
||||
PROCESS_TREE,
|
||||
PROCESS_R_STATE,
|
||||
PROCESS_D_STATE,
|
||||
|
74
Process.c
74
Process.c
@ -61,46 +61,64 @@ void Process_humanNumber(RichString* str, unsigned long number, bool coloring) {
|
||||
|
||||
int largeNumberColor = CRT_colors[LARGE_NUMBER];
|
||||
int processMegabytesColor = CRT_colors[PROCESS_MEGABYTES];
|
||||
int processGigabytesColor = CRT_colors[PROCESS_GIGABYTES];
|
||||
int processColor = CRT_colors[PROCESS];
|
||||
if (!coloring) {
|
||||
largeNumberColor = CRT_colors[PROCESS];
|
||||
processMegabytesColor = CRT_colors[PROCESS];
|
||||
processGigabytesColor = CRT_colors[PROCESS];
|
||||
}
|
||||
|
||||
if(number >= (10 * ONE_DECIMAL_M)) {
|
||||
#ifdef __LP64__
|
||||
if(number >= (100 * ONE_DECIMAL_G)) {
|
||||
len = snprintf(buffer, 10, "%4luT ", number / ONE_G);
|
||||
RichString_appendn(str, largeNumberColor, buffer, len);
|
||||
return;
|
||||
} else if (number >= (1000 * ONE_DECIMAL_M)) {
|
||||
len = snprintf(buffer, 10, "%4.1lfT ", (double)number / ONE_G);
|
||||
RichString_appendn(str, largeNumberColor, buffer, len);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if(number >= (100 * ONE_DECIMAL_M)) {
|
||||
len = snprintf(buffer, 10, "%4luG ", number / ONE_M);
|
||||
RichString_appendn(str, largeNumberColor, buffer, len);
|
||||
return;
|
||||
}
|
||||
len = snprintf(buffer, 10, "%4.1lfG ", (double)number / ONE_M);
|
||||
RichString_appendn(str, largeNumberColor, buffer, len);
|
||||
return;
|
||||
} else if (number >= 100000) {
|
||||
len = snprintf(buffer, 10, "%4luM ", number / ONE_K);
|
||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||
return;
|
||||
} else if (number >= 1000) {
|
||||
if (number < 1000) {
|
||||
//Plain number, no markings
|
||||
len = snprintf(buffer, 10, "%5lu ", number);
|
||||
RichString_appendn(str, processColor, buffer, len);
|
||||
} else if (number < 100000) {
|
||||
//2 digit MB, 3 digit KB
|
||||
len = snprintf(buffer, 10, "%2lu", number/1000);
|
||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||
number %= 1000;
|
||||
len = snprintf(buffer, 10, "%03lu ", number);
|
||||
RichString_appendn(str, processColor, buffer, len);
|
||||
return;
|
||||
} else if (number < 1000 * ONE_K) {
|
||||
//3 digit MB
|
||||
number /= ONE_K;
|
||||
len = snprintf(buffer, 10, "%4luM ", number);
|
||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||
} else if (number < 10000 * ONE_K) {
|
||||
//1 digit GB, 3 digit MB
|
||||
number /= ONE_K;
|
||||
len = snprintf(buffer, 10, "%1lu", number/1000);
|
||||
RichString_appendn(str, processGigabytesColor, buffer, len);
|
||||
number %= 1000;
|
||||
len = snprintf(buffer, 10, "%03luM ", number);
|
||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||
} else if (number < 100 * ONE_M) {
|
||||
//2 digit GB, 1 digit MB
|
||||
number /= 100 * ONE_K;
|
||||
len = snprintf(buffer, 10, "%2lu", number/10);
|
||||
RichString_appendn(str, processGigabytesColor, buffer, len);
|
||||
number %= 10;
|
||||
len = snprintf(buffer, 10, ".%1luG ", number);
|
||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||
} else if (number < 1000 * ONE_M) {
|
||||
//3 digit GB
|
||||
number /= ONE_M;
|
||||
len = snprintf(buffer, 10, "%4luG ", number);
|
||||
RichString_appendn(str, processGigabytesColor, buffer, len);
|
||||
} else if (number < 10000 * ONE_M) {
|
||||
//1 digit TB, 3 digit GB
|
||||
number /= ONE_M;
|
||||
len = snprintf(buffer, 10, "%1lu", number/1000);
|
||||
RichString_appendn(str, largeNumberColor, buffer, len);
|
||||
number %= 1000;
|
||||
len = snprintf(buffer, 10, "%03luG ", number);
|
||||
RichString_appendn(str, processGigabytesColor, buffer, len);
|
||||
} else {
|
||||
//2 digit TB and above
|
||||
len = snprintf(buffer, 10, "%4.1lfT ", (double)number/ONE_G);
|
||||
RichString_appendn(str, largeNumberColor, buffer, len);
|
||||
}
|
||||
len = snprintf(buffer, 10, "%5lu ", number);
|
||||
RichString_appendn(str, processColor, buffer, len);
|
||||
}
|
||||
|
||||
void Process_colorNumber(RichString* str, unsigned long long number, bool coloring) {
|
||||
|
Loading…
Reference in New Issue
Block a user