I tried to run the escape sequences using the writeln () function, I also tried to use them with the printf () function imported from the std.c.stdlib module, but it only prints an empty line.
printf("\0x1B[5;32;40m Blink Text"); printf("\e[5;32;40m Blink Text\e[m"); writeln("\0x1b\x5b1;31;40m\tColor");
None of these works.
I tried everything I could think of, is there any way?
Finding a link to the D site library did not help me.
EDIT: SOLUTION
Ok, so I tried to import the SetConsoleTextAttribute function, as Mars kindly suggested:
extern (Windows) bool SetConsoleTextAttribute(void*, ushort);
I also imported another function (which I just guessed, I need to import, since I have no previous Win programming experience)
extern (Windows) void* GetStdHandle(uint);
And just call two functions
auto handle = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(handle, FOREGROUND_BLUE); writeln("In Color");
This works great, thank you all for your time and help.
Pavel matuska
source share