www.digitalmars.com         C & C++   DMDScript  

D - textcolor, textbackground

reply "Carlos" <carlos8294 msn.com> writes:
Is there anything like textcolor() and textbackground() in D?
May 16 2002
next sibling parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:ac1jl2$68r$1 digitaldaemon.com...

 Is there anything like textcolor() and textbackground() in D?

No, because they aren't multi-platform (I think for the same reason they aren't present in C). Just use SetConsoleTextAttribute()...
May 16 2002
parent reply "Carlos" <carlos8294 msn.com> writes:
Ok, but if I have Turbo C/C++ 3.0 and DJGPP 2.02 (which have support for
textcolor, textbackground and others), how could I use them? I mean, in both
of them there're lib directories with the respective .lib files, but they
have cryptic names. What could I do?

"Pavel Minayev" <evilone omen.ru> escribió en el mensaje
news:ac20nv$gr7$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:ac1jl2$68r$1 digitaldaemon.com...

 Is there anything like textcolor() and textbackground() in D?

No, because they aren't multi-platform (I think for the same reason they aren't present in C). Just use SetConsoleTextAttribute()...

May 19 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:ac95de$1mkt$1 digitaldaemon.com...

 Ok, but if I have Turbo C/C++ 3.0 and DJGPP 2.02 (which have support for
 textcolor, textbackground and others), how could I use them? I mean, in

 of them there're lib directories with the respective .lib files, but they
 have cryptic names. What could I do?

I'm not sure what you want to do... are you trying to link those libs to your D programs?
May 19 2002
parent reply "Carlos" <carlos8294 msn.com> writes:
yes, I am

"Pavel Minayev" <evilone omen.ru> escribió en el mensaje
news:ac9rn4$2aai$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:ac95de$1mkt$1 digitaldaemon.com...

 Ok, but if I have Turbo C/C++ 3.0 and DJGPP 2.02 (which have support for
 textcolor, textbackground and others), how could I use them? I mean, in

 of them there're lib directories with the respective .lib files, but


 have cryptic names. What could I do?

I'm not sure what you want to do... are you trying to link those libs to your D programs?

May 19 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:ac9s39$2aka$1 digitaldaemon.com...

 yes, I am

It won't work. Turbo C is 16-bit, and DJGPP is 32-bit, but for DOS. And DMD produces Win32 executables. If you want it, you'll have to write it yourself. Wrappers around SetConsoleTextAttribute and SetConsoleCursorPosition shouldn't be hard to do...
May 20 2002
parent reply "Carlos" <carlos8294 msn.com> writes:
Ok. In the Dev-C++ 4.0 conio.h I found it. This is the code to implement
them:

void textattr(int a)
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}

void textbackground(int a)
{
    /*
    if (a==BLINK)
        a=WHITE;
    */
    __BACKGROUND=a;
    textattr(__FOREGROUND | (a+29));
}

void textcolor(int a)
{
    /*
    if (a==BLINK)
        a=WHITE;
    */
    __FOREGROUND=a;
}

But I have no idea how to make them work. I know that
SetConsoleTextAttribute is in wincon.h (in dm\include\win32) but what do I
do now?

"Pavel Minayev" <evilone omen.ru> escribió en el mensaje
news:acamoo$7kn$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:ac9s39$2aka$1 digitaldaemon.com...

 yes, I am

It won't work. Turbo C is 16-bit, and DJGPP is 32-bit, but for DOS. And DMD produces Win32 executables. If you want it, you'll have to write it yourself. Wrappers around SetConsoleTextAttribute and SetConsoleCursorPosition shouldn't be hard to do...

May 22 2002
parent "Carlos" <carlos8294 msn.com> writes:
My mistake. This is the correct code:

void textattr(int a)
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}

void textbackground(int a)
{
    /*
    if (a==BLINK)
        a=WHITE;
    */
    __BACKGROUND=a;
    textattr(__FOREGROUND | (a+29));
}

void textcolor(int a)
{
    /*
    if (a==BLINK)
        a=WHITE;
        */
    __FOREGROUND=a;
    textattr(a|__BACKGROUND);
}

 But I have no idea how to make them work. I know that
 SetConsoleTextAttribute is in wincon.h (in dm\include\win32) but what do I
 do now?

 "Pavel Minayev" <evilone omen.ru> escribió en el mensaje
 news:acamoo$7kn$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:ac9s39$2aka$1 digitaldaemon.com...

 yes, I am

It won't work. Turbo C is 16-bit, and DJGPP is 32-bit, but for DOS. And DMD produces Win32 executables. If you want it, you'll have to write it yourself. Wrappers around SetConsoleTextAttribute and SetConsoleCursorPosition shouldn't be hard to do...


May 22 2002
prev sibling parent "Walter" <walter digitalmars.com> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:ac1jl2$68r$1 digitaldaemon.com...
 Is there anything like textcolor() and textbackground() in D?

Check out the disp package: www.digitalmars.com/rtl/disp.html
May 17 2002