Overview
Comment: | utils/ofhttp: Make sure bar width is >= 0 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e4b34278f50a6632787a8edc36ff77cf |
User & Date: | js on 2015-05-17 01:42:32 |
Other Links: | manifest | tags |
Context
2015-05-20
| ||
22:26 | OFHTTPClient: Correctly handle keep-alive for HEAD check-in: a8184e90ae user: js tags: trunk | |
2015-05-17
| ||
01:42 | utils/ofhttp: Make sure bar width is >= 0 check-in: e4b34278f5 user: js tags: trunk | |
2015-05-16
| ||
23:59 | utils/ofhttp: Show ETA check-in: 65681d0342 user: js tags: trunk | |
Changes
Modified utils/ofhttp/ProgressBar.m from [258ce39ec5] to [b3212f82f5].
︙ | ︙ | |||
81 82 83 84 85 86 87 | - (void)setReceived: (intmax_t)received { _received = received; } - (void)_drawProgress { | | | > | | > | | 81 82 83 84 85 86 87 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 | - (void)setReceived: (intmax_t)received { _received = received; } - (void)_drawProgress { size_t i; 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) / (_resumedFrom + _length) * barWidth; percent = (float)(_resumedFrom + _received) / (_resumedFrom + _length) * 100; [of_stdout writeString: @"\r ▕"]; for (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) |
︙ | ︙ | |||
122 123 124 125 126 127 128 | else if (remainder >= 0.25) [of_stdout writeString: @"▎"]; else if (remainder >= 0.125) [of_stdout writeString: @"▏"]; else [of_stdout writeString: @" "]; | | | < | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | else if (remainder >= 0.25) [of_stdout writeString: @"▎"]; else if (remainder >= 0.125) [of_stdout writeString: @"▏"]; else [of_stdout writeString: @" "]; for (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]; _BPS = (float)_received / timeInterval; _ETA = timeInterval; } if (isinf(_ETA)) [of_stdout writeString: @"--:--:-- "]; else if (_ETA >= 99 * 3600) [of_stdout writeFormat: @"%4.2f d ", _ETA / (24 * 3600)]; else [of_stdout writeFormat: @"%2u:%02u:%02u ", (uint8_t)(_ETA / 3600), (uint8_t)(_ETA / 60) % 60, (uint8_t)_ETA % 60]; if (_BPS >= GIBIBYTE) [of_stdout writeFormat: @"%7.2f GiB/s", _BPS / GIBIBYTE]; else if (_BPS >= MEBIBYTE) [of_stdout writeFormat: @"%7.2f MiB/s", _BPS / MEBIBYTE]; else if (_BPS >= KIBIBYTE) [of_stdout writeFormat: @"%7.2f KiB/s", _BPS / KIBIBYTE]; |
︙ | ︙ |