Differences From Artifact [84262304c6]:
- File
utils/ofhttp/ProgressBar.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 5409) [annotate] [blame] [check-ins using] [more...]
To Artifact [e437710ddc]:
- File utils/ofhttp/ProgressBar.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 5412) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
88 89 90 91 92 93 94 | - (void)setReceived: (intmax_t)received { _received = received; } - (void)_drawProgress { | < | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | - (void)setReceived: (intmax_t)received { _received = received; } - (void)_drawProgress { float bars, percent; unsigned short barWidth; #ifdef HAVE_SYS_IOCTL_H struct winsize ws; if (ioctl(0, TIOCGWINSZ, &ws) == 0 && ws.ws_col > 37) barWidth = ws.ws_col - 37; else barWidth = 0; #else barWidth = 43; #endif bars = (float)(_resumedFrom + _received) / (float)(_resumedFrom + _length) * barWidth; percent = (float)(_resumedFrom + _received) / (float)(_resumedFrom + _length) * 100; [of_stdout writeString: @"\r ▕"]; for (size_t i = 0; i < (size_t)bars; i++) [of_stdout writeString: @"█"]; if (bars < barWidth) { float remainder = bars - floorf(bars); if (remainder >= 0.875) [of_stdout writeString: @"▉"]; else if (remainder >= 0.75) |
︙ | ︙ | |||
131 132 133 134 135 136 137 | else if (remainder >= 0.25) [of_stdout writeString: @"▎"]; else if (remainder >= 0.125) [of_stdout writeString: @"▏"]; else [of_stdout writeString: @" "]; | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | else if (remainder >= 0.25) [of_stdout writeString: @"▎"]; else if (remainder >= 0.125) [of_stdout writeString: @"▏"]; else [of_stdout writeString: @" "]; for (size_t i = 0; i < barWidth - (size_t)bars - 1; i++) [of_stdout writeString: @" "]; } [of_stdout writeFormat: @"▏ %6.2f%% ", percent]; if (percent == 100) { double timeInterval = -[_startDate timeIntervalSinceNow]; |
︙ | ︙ |