Public Group

Archived

This topic is now archived and is closed to further replies.

underlined text

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

Recommended Posts

In a Win32 console program, is it possible to print out underlined text like this: this text is underlined. If so, how do you do it? Thanks in advance for your help. ------------------------------ BASIC programmers don''t die, they just GOSUB and don''t return.

Share on other sites
I did the search and after spending a while figuring out ASNI escape codes i tried this:
const char ESC = 27;
std::cout << ESC << "[04mThis text should be underlined." << std::endl;
ESC[04m should make the text underlined. Instead, it turnes blue . What could I possibly be doing wrong?

------------------------------
BASIC programmers don''t die, they just GOSUB and don''t return.

Share on other sites
\e is a (non-standard) code for ESC. gcc supports it, maybe VS too.

According to http://enterprise.aacc.cc.md.us/~rhs/ansi.html

Underscore (on monochrome display adapter only)
Parameters 30 through 47 meet the ISO 6429 standard.

"\e[=0h"
Set Mode 40 x 148 x 25 monochrome (text)

Hope you can get it to work... usually it works in terminals, not that well in windows consoles (at least on W2k).

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share on other sites
On standard PC display adapters, the only way to get underlined text in text mode is if your video adapter supports it. The last adapater I had that supported it was a Hercules/MDA monochrome display adapter (720x348, if I''m not mistaken), and it could be done by using forground color 01h (which I think is blue on color adapters).

Graphical consoles and terminal emulators can support it using ANSI codes, but i''ve never been able to do it in a NT/DOS console.

You could use two lines to do it. One line with the text and one line with character C4h.

Other than that, you should use graphics mode. Actually, I prefer to do my text-based apps using web servers and HTML, and underlining in HTML is EEEEEASY! :-)

--TheMuuj

Share on other sites
Fruny: doesn't work. Thanks for reminding me about '\e' though.

What i am trying to do is have an equation(to be solved) on two lines, with the first one underlined, since it is a fraction (in case anyone cares, it is the quadratic formula). This is opposed to three lines(to save screen space). here's what i am talking about:
3 lines: -b±sqrt(b²-4ac)         ---------------               2a2 lines: -b±sqrt(b²-4ac)               2a

EDIT: Stupid spacing...
------------------------------
BASIC programmers don't die, they just GOSUB and don't return.

[edited by - GarlandIX on June 3, 2002 12:59:21 AM]

Share on other sites
quote:

Apparently, ANSI escapes aren''t supported anymore in windows...

They work alright on win98se(i have) but not the underlining .
I guess ill just have to do what theMuuj said (three lines with char C4h as the underline.

------------------------------
BASIC programmers don''t die, they just GOSUB and don''t return.

Share on other sites
quote:
Original post by GarlandIX

They work alright on win98se(i have) but not the underlining .
...

Actually the underlining is only available in Hercules/MDA or Monochrome (those IBM XT,8086,8088)... on CGA/EGA/VGA/SVGA it is blue text (color 1 in BASIC).... TheMuuj already mentioned it. So it is not 98SE not supporting it... it is your grpahics/display card....

...maybe u could change the display mode to black&white.....

Share on other sites
If you have an expression like "a = b / c" (but with a horizontal division line) wouldn''t you want to have it on 3 lines so the "a =" is centred vertically?

How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 14
• Forum Statistics

• Total Topics
632961
• Total Posts
3009485
• Who's Online (See full list)

There are no registered users currently online

×