Jump to content
  • Advertisement
Sign in to follow this  
Servant of the Lord

Looking for a few console commands...

This topic is 4500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the win32 console app, how do I make a single line italic or bold? And how do I make a certain line colored text? (Without changing the color of the entire console's text) If there is a simple line or two of code that explains how to do one of these, please post and explain it for me. If it is a huge thing, however, could you post a link? I'm using Dev C++, thanks. Oh, and I already know of the system("color 04"); thing, but I want to change just one line. Thanks again!

Share this post


Link to post
Share on other sites
Advertisement
Making text in a console window italic or bold is impossible.

There's some Win32 API calls that do it. I think it's something like "SetConsoleTextAttribute" or something like that, but I don't really know, since I haven't used the console in a while.

Share this post


Link to post
Share on other sites
I'm not sure about Italic or Bold, but IIRC the old conio.h C library is a lot more flexible than stdio or iostream. I know I've seen it used to set colors on specific text before.

EDIT: Scratch that, conio.h was more of a coincidence than anything else. I have seen specific text set to a color though.

Share this post


Link to post
Share on other sites
Quote:
Original post by dpadam450
about all you can do with consoles


Thanks. Any other sites anyone? Also, Drew_Benton gave me this awhile back and I've just remembered.


void SetColor(int textColor, int backGroundColor = 0)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, (WORD)((backGroundColor << 4) | textColor));
}

Thanks Drew!


Still, anyone have a way to add italic or bold text to a console?

Share this post


Link to post
Share on other sites
Quote:
Original post by Servant of the Lord
Still, anyone have a way to add italic or bold text to a console?


When I said that it's impossible, I wasn't joking or exaggerating. I meant it literally.

Sure, you can change the font, but it only changes the entire console, and AFAIK there's no way to do it from a running application (you CAN change the font by fiddling with the options on the console, but programs can't do it themselves).

If you want bolded/italic text and other fonts on Windows, you'll have to look into Windows GDI or some other graphics API, I'm afraid.

Share this post


Link to post
Share on other sites
Okay. I wasn't exactly needing bold text, I was just wondering whether it was possible. Would it be possible(for me) to make one? I figure, the current text is drawn to the screen somehow. If I could figure it out, I could create an option to allow for a second or third charactor set which I could switch in or out. Just wishful thinking I guess, but it would be good practice even if I fail.

Share this post


Link to post
Share on other sites
It's not going to happen in the Windows Console... it's just not designed for that sort of thing. You'd have to write your own console program, which might actually be good practice anyhow.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!