Page 1 of 1
colours in console
Posted: Sat Jan 03, 2004 12:00 am
by St8ic
How would I go about getting different coloured text in the console? I know it is a pretty basic procedure, but I can't get it to work correctly.
Thanks!
RE:colours in console
Posted: Mon Jan 05, 2004 12:00 am
by gaf
Hello St8ic
The characters consist of 2 bytes, the first byte is the ANSI-Character itself and the second is the attribute-byte. So if you want to change the color of a character, you simply have to overwrite it's attribute-byte.
The attribute-byte:
-------------------
b 0 Foreground - BLUE
b 1 Foreground - GREEN
b 2 Foreground - RED
b 3 Foreground - INTENSITY
b 4 Background - BLUE
b 5 Background - GREEN
b 6 Background - RED
b 7 BLINKING
The foreground-colortable:
--------------------------
0000 Black1000 Grey
0001 Blue 1001 Light Blue
0010 Green 1010 Light Green
0011 Cyan 1011 Light Cyan
0100 Red 1100 Light Red
0101 Magenta 1101 Light Magenta
0110 Brown 1110 Yellow
0111 White 1111 "Bright" White
RE:colours in console
Posted: Mon Jan 05, 2004 12:00 am
by gaf
Hello St8ic
The characters consist of 2 bytes, the first byte is the ANSI-Character itself and the second is the attribute-byte. So if you want to change the color of a character, you simply have to overwrite it's attribute-byte.
The attribute-byte:
-------------------
b 0 Foreground - BLUE
b 1 Foreground - GREEN
b 2 Foreground - RED
b 3 Foreground - INTENSITY
b 4 Background - BLUE
b 5 Background - GREEN
b 6 Background - RED
b 7 BLINKING
The foreground-colortable:
--------------------------
0000 Black 1000 Grey
0001 Blue 1001 Light Blue
0010 Green 1010 Light Green
0011 Cyan 1011 Light Cyan
0100 Red 1100 Light Red
0101 Magenta 1101 Light Magenta
0110 Brown 1110 Yellow
0111 White 1111 "Bright" White
The background-colortable is basically the same, but there's no intensity-bit, so you can only use the 3bit colors (on the left site)
regards,
gaf