-
Notifications
You must be signed in to change notification settings - Fork 0
textcolor
Function Selects new character color in text mode.
Syntax void textcolor(int newcolor);
Prototype in conio.h
Return value None.
See also gettextinfo, highvideo, lowvideo, normvideo, textattr, textbackground
textcolor selects the foreground character color. The foreground color of all characters subsequently written by console output functions will be the color given by newcolor. You can give the color using a symbolic constant defined in conio.h. If you use the constants, you must include conio.h
This function does not affect any characters currently on the screen, but only those displayed using direct console output (such as cprintf) after textcolor has been called.
The following table lists the allowable colors (as symbolic constants) and their numeric values:
| Symbolic Constant | Numeric Value | Foreground or background? |
|---|---|---|
| BLACK | 0 | both |
| BLUE | 1 | both |
| GREEN | 2 | both |
| CYAN | 3 | both |
| RED | 4 | both |
| MAGENTA | 5 | both |
| BROWN | 6 | both |
| LIGHTGRAY | 7 | both |
| DARKGRAY | 8 | foreground only |
| LIGHTBLUE | 9 | foreground only |
| LIGHTGREEN | 10 | foreground only |
| LIGHTCYAN | 11 | foreground only |
| LIGHTRED | 12 | foreground only |
| LIGHTMAGENTA | 13 | foreground only |
| YELLOW | 14 | foreground only |
| WHITE | 15 | foreground only |
| BLINK | 128 | foreground only |
You can make the characters blink by adding 128 to the foreground color. The predefined constant BLINK exists for this purpose. For example,
textcolor(CYAN + BLINK);