Wednesday 16 November 2011

How do you write text in color with the ANSI driver? in C programming

How do you write text in color with the ANSI driver?

The color of text is one of the text’s attributes you can change. You can change the attributes of text with
<esc>[<attr>m. In the case of ANSI sequences, these attributes are represented by numerical values. You can set multiple attributes with one command by separating them with semicolons, like this: <esc>[<attr>;<attr>m.
The following program demonstrates this action:
#include <stdio.h>
main()
{
printf( “%c[32;44mPsychedelic, man.\n” , 27 );
return( 0 );
}

Here is a list of attributes supported by the ANSI driver. Your particular monitor might not support some
of the options.
1. High Intensity.
2. Low Intensity.
3. Italic.
4. Underline.
5. Blinking.
6. Fast Blinking.
7. Reverse.
8. Invisible.

Foreground colors:

30. Black.
31. Red.
32. Green.
33. Yellow.
34. Blue.
35. Magenta.
36. Cyan.
37. White.

Background colors:

40. Black.
41. Red.
42. Green.
43. Yellow.
44. Blue.
45. Magenta.
46. Cyan.
47. White.

Cross Reference:


None.

No comments:

Post a Comment