Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
April 27, 2015 How to change text while running in console? | ||||
---|---|---|---|---|
| ||||
I remember doing this in C++ and it worked but is this possible in D? Its basically updating information in the console window without constantly printing new lines. http://stackoverflow.com/questions/14043148/how-to-change-text-while-running-the-console |
April 27, 2015 Re: How to change text while running in console? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Israel | On Monday, 27 April 2015 at 02:26:01 UTC, Israel wrote:
> I remember doing this in C++ and it worked but is this possible in D?
>
> Its basically updating information in the console window without constantly printing new lines.
>
> http://stackoverflow.com/questions/14043148/how-to-change-text-while-running-the-console
write(info, "\r"); stdout.flush();
E.g. with percent:
writef("%d%%\r", current * 100 / total); stdout.flush();
|
April 27, 2015 Re: How to change text while running in console? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Israel | On Monday, 27 April 2015 at 02:26:01 UTC, Israel wrote:
> I remember doing this in C++ and it worked but is this possible in D?
Have you tried it yet? The solution is basically the same, you just write out the carriage return character to the device.
|
April 27, 2015 Re: How to change text while running in console? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | On Monday, 27 April 2015 at 02:30:36 UTC, Vladimir Panteleev
wrote:
> writef("%d%%\r", current * 100 / total); stdout.flush();
I'd prolly put a width specifier on it like %3d because otherwise
if it was 100 percent then went to 99, the third digit wouldn't
be erased.
|
April 27, 2015 Re: How to change text while running in console? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Monday, 27 April 2015 at 02:32:17 UTC, Adam D. Ruppe wrote:
> On Monday, 27 April 2015 at 02:26:01 UTC, Israel wrote:
>> I remember doing this in C++ and it worked but is this possible in D?
>
> Have you tried it yet? The solution is basically the same, you just write out the carriage return character to the device.
You also need to flush the FILE buffer, as C stdio will do that for you only if the string contains a \n character.
|
April 27, 2015 Re: How to change text while running in console? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | On Monday, 27 April 2015 at 02:30:36 UTC, Vladimir Panteleev wrote:
> On Monday, 27 April 2015 at 02:26:01 UTC, Israel wrote:
>> I remember doing this in C++ and it worked but is this possible in D?
>>
>> Its basically updating information in the console window without constantly printing new lines.
>>
>> http://stackoverflow.com/questions/14043148/how-to-change-text-while-running-the-console
>
> write(info, "\r"); stdout.flush();
>
> E.g. with percent:
>
> writef("%d%%\r", current * 100 / total); stdout.flush();
Thank you guys it works. Even with the percent sign.
write(sumincrease, "%", "\r"); stdout.flush();
|
Copyright © 1999-2021 by the D Language Foundation