@@ -97,40 +97,38 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentageModuleConf
97
97
98
98
bool autoColorElapsed = ffStrbufIgnCaseEqualS (& options -> barColorElapsed , "auto" );
99
99
100
+ bool monochrome = (percentType & FF_PERCENTAGE_TYPE_BAR_MONOCHROME_BIT ) || !autoColorElapsed ;
101
+ if (!options -> pipe && options -> barColorElapsed .length > 0 && monochrome )
102
+ {
103
+ const char * color = NULL ;
104
+ if (!autoColorElapsed )
105
+ color = options -> barColorElapsed .chars ;
106
+ else if (green <= yellow )
107
+ {
108
+ if (percent < green ) color = colorGreen ;
109
+ else if (percent < yellow ) color = colorYellow ;
110
+ else color = colorRed ;
111
+ }
112
+ else
113
+ {
114
+ if (percent < yellow ) color = colorRed ;
115
+ else if (percent < green ) color = colorYellow ;
116
+ else color = colorGreen ;
117
+ }
118
+ ffStrbufAppendF (buffer , "\e[%sm" , color );
119
+ }
100
120
for (uint8_t i = 0 ; i < blocksPercent ; ++ i )
101
121
{
102
- if (!options -> pipe && options -> barColorElapsed .length > 0 )
122
+ if (!options -> pipe && options -> barColorElapsed .length > 0 && ! monochrome )
103
123
{
104
- if ((percentType & FF_PERCENTAGE_TYPE_BAR_MONOCHROME_BIT ) || !autoColorElapsed )
105
- {
106
- const char * color = NULL ;
107
- if (!autoColorElapsed )
108
- color = options -> barColorElapsed .chars ;
109
- else if (green <= yellow )
110
- {
111
- if (percent < green ) color = colorGreen ;
112
- else if (percent < yellow ) color = colorYellow ;
113
- else color = colorRed ;
114
- }
115
- else
116
- {
117
- if (percent < yellow ) color = colorRed ;
118
- else if (percent < green ) color = colorYellow ;
119
- else color = colorGreen ;
120
- }
121
- ffStrbufAppendF (buffer , "\e[%sm" , color );
122
- }
123
- else
124
- {
125
- uint32_t section1Begin = (uint32_t ) ((green <= yellow ? green : yellow ) / 100.0 * options -> barWidth + 0.5 );
126
- uint32_t section2Begin = (uint32_t ) ((green > yellow ? green : yellow ) / 100.0 * options -> barWidth + 0.5 );
127
- if (i == section2Begin )
128
- ffStrbufAppendF (buffer , "\e[%sm" , (green > yellow ? colorGreen : colorRed ));
129
- else if (i == section1Begin )
130
- ffStrbufAppendF (buffer , "\e[%sm" , colorYellow );
131
- else if (i == 0 )
132
- ffStrbufAppendF (buffer , "\e[%sm" , (green <= yellow ? colorGreen : colorRed ));
133
- }
124
+ uint32_t section1Begin = (uint32_t ) ((green <= yellow ? green : yellow ) / 100.0 * options -> barWidth + 0.5 );
125
+ uint32_t section2Begin = (uint32_t ) ((green > yellow ? green : yellow ) / 100.0 * options -> barWidth + 0.5 );
126
+ if (i == section2Begin )
127
+ ffStrbufAppendF (buffer , "\e[%sm" , (green > yellow ? colorGreen : colorRed ));
128
+ else if (i == section1Begin )
129
+ ffStrbufAppendF (buffer , "\e[%sm" , colorYellow );
130
+ else if (i == 0 )
131
+ ffStrbufAppendF (buffer , "\e[%sm" , (green <= yellow ? colorGreen : colorRed ));
134
132
}
135
133
ffStrbufAppend (buffer , borderAsValue && i == 0
136
134
? & options -> barBorderLeftElapsed
@@ -146,9 +144,9 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentageModuleConf
146
144
for (uint8_t i = blocksPercent ; i < options -> barWidth ; ++ i )
147
145
{
148
146
ffStrbufAppend (buffer , borderAsValue && i == 0
149
- ? & options -> barBorderLeftElapsed
147
+ ? & options -> barBorderLeft
150
148
: borderAsValue && i == options -> barWidth - 1
151
- ? & options -> barBorderRightElapsed
149
+ ? & options -> barBorderRight
152
150
: & options -> barCharTotal );
153
151
}
154
152
}
0 commit comments