Printing coloured text to the console window
Grub4dos does not allow you to specify the text (foreground) colour and the background colour separately.
[Edit] For colours 1-F you can use echo $[Bn0T] where n=1 for bright colour and T is colour 0-F. B=1 for blink if in text mode (e.g. graphicsmode 3)[/Edit]
This causes problems if you don't already know what the current colour settings are:
Say we want to write coloured text to the console window but then want to restore the original colours - e.g.
message1
message2
WARNING: some warning
message3
we will need to know the current foreground/background colours so we can restore them after writing the red text.
Also we may not want to change the background colour but we don't know what it is at the moment.
Chenall has shown me a way to get the current colours from internal variables.
It also means that we can find the current background colour and therefore write our text message in any colour we like and keep the current background colour the same and then restore the current colours again to whatever they were before.
# 64-bit background color , e.g. 0xCCCC00
calc 44<<2 + *0x8304 > nul ;; read %@retval% ;; set /A stdhb=%@retval%
#64-bit foreground TEXT color , e.g. 0x123456
calc 43<<2 + *0x8304 > nul ;; read %@retval% > nul ;; set /A stdhf=%@retval% > nul
#32-bit color current colour, e.g. 0x15
calc 42<<2 + *0x8304 > nul ;; read %@retval% > nul ;; set /A color_32=%@retval% > nul
#get foreground and background 4-bit color values
set stdb=%color_32:~2,1% ;; set stdf=%color_32:~3,1% ;; if "%stdf%"=="" set stdf=%stdb% && set stdb=0