On Saturday, 10 June 2017 at 16:10:18 UTC, Russel Winder wrote:
It appears that std.stdio.stderr does not wor exactly as stdio
stderr
does. In particular std.stdio.stderr.writef(…) does not work as
fprintf(stderr…) does.
Some code I am porting from C++ to D makes use of ANSI escape
codes to go up a line and overwrite what was there, as well as
change colours. This work fine in the C++ code but fails in the
D code. The codes are definitely all the same, the only
difference is in the writing functions.
Is this problem to be expected or should it work?
Hi Russel,
It seems to work for me with a dumb example:
```
import std.stdio;
void main()
{
writefln("stdout: %s", "[7m[1mEdit source/app.d to start your
project.[0m");
stderr.writefln("stderr: %s", "[7m[1mEdit source/app.d to
start your project.[0m");
stderr.writefln("stderr: %s", "[0;31m[1mEdit source/app.d to
start your project.[0m");
stderr.writefln("%s", "[1A[12C[K");
}
```
Before copy/paste take into account that in sequences like "[7m",
etc... there's a hidden ESC char at the beginning, something
like: "\033[7m", and I can't see it in the preview of my posting.
Antonio