What is "dmd" Internal API, can I use it just like std Library Reference?
a11e99z
black80 at bk.ru
Tue Aug 20 13:22:10 UTC 2019
On Tuesday, 20 August 2019 at 12:52:31 UTC, BoQsc wrote:
> Hello everyone, again,
>
> I had an idea that I want some colors in the output of Command
> Line (For Windows) and the Terminal (For Linux)
>
yesterday was talks about terminal colors in IRC-channel:
u can use VT-codes for changing colors:
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#text-formatting
probably for Win10 only. idk for which Linux/Terminals it working
too
> // Windows code
> import std,
> core.sys.windows.windows;
>
> void main() {
> auto hc = GetStdHandle( STD_OUTPUT_HANDLE );
> assert( hc != INVALID_HANDLE_VALUE);
>
> uint mod;
> auto ok = GetConsoleMode( hc, &mod);
> assert( ok);
> ok = SetConsoleMode( hc, mod |
> ENABLE_VIRTUAL_TERMINAL_PROCESSING );
> assert( ok);
>
> writeln( "\x1b[38;2;255;100;0mTRUECOLOR");
> writeln( "\x1b[30;47mHello from Inversed" );
> writeln( "\x1b[38;2;255;0;255mTRUECOLOR\x1b[0m" );
> // last "\x1b[0m" - make colors default
> readln;
> }
More information about the Digitalmars-d-learn
mailing list