mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-23 17:38:44 +00:00
Changed: #1051 Progress tweak
This commit is contained in:
parent
6c63513943
commit
267a39ee02
1 changed files with 28 additions and 7 deletions
|
@ -83,11 +83,30 @@ void printDownload(const std::string &str)
|
|||
static const uint maxLength = 160;
|
||||
static char spaces[maxLength];
|
||||
|
||||
memset(spaces, ' ', previousLength);
|
||||
spaces[previousLength] = '\0';
|
||||
uint length = 0;
|
||||
|
||||
if (useUtf8)
|
||||
{
|
||||
ucstring utf8Str;
|
||||
utf8Str.fromUtf8(str);
|
||||
length = (uint)utf8Str.length();
|
||||
}
|
||||
else
|
||||
{
|
||||
length = (uint)str.length();
|
||||
}
|
||||
|
||||
sint diff = length - previousLength;
|
||||
|
||||
if (diff > 0 && length < maxLength)
|
||||
{
|
||||
memset(spaces, ' ', length);
|
||||
spaces[length] = '\0';
|
||||
|
||||
// "erase" previous line
|
||||
printf("%s\r", spaces);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
// display download in purple
|
||||
if (useEsc)
|
||||
|
@ -109,7 +128,9 @@ void printDownload(const std::string &str)
|
|||
#endif
|
||||
}
|
||||
|
||||
previousLength = (uint)str.length();
|
||||
fflush(stdout);
|
||||
|
||||
previousLength = length;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
Loading…
Reference in a new issue