Since ROOT 5.30.00 the strange behavior of console color on Windows is observed. If one set the suitable colors of background and text of the Windows console than ROOT changed these colors. The background becomes the black. It was not with older versions of the ROOT. The attempts of change the system.rootrc file in the /root/etc directory did not get the success.
Is it possible to save the Windows console colors after the ROOT start?
You mean ROOT changes the color background of the terminal you are running it ?
I do see this using cygwin on XP.
The Cygwin is not used. The binary ROOT version created for the Windows with Visual Studio 9 is downloaded. The colors of cmd screen are set. After the start of ROOT the background color is changed on black. It was not so until version 5.30.00.
For that, Windows would need to tell me which console (background) color is the current default. I cannot find it as part of Windows’ WIN32 API - can you?
The next example gives the current console background. It was got from the dreamincode.net/code/snippet4313.htm site and checked on the local computer with Windows 7 and Visual Studio 9.
int color, cback, cforg, key = 0;
color = GetColor();
cback = GetBackground();
cforg = GetForground();
printf("COLOR = %d\n",color);
printf("CBACK = %d\n",cback);
printf("CFORG = %d\n",cforg);
WORD wColor = 0;
//We will need this handle to get the current background attribute
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
//We use csbi for the wAttributes word.
//return the wAttributes data
wColor = (csbi.wAttributes & 0xFF);
//Mask out all but the lower nibble
return GetColor() & 0x0F;
// Shift down one nibble (4bits) and then mask off everything else
return (GetColor() >> 4) & 0x0F;
Awesome, thanks! In the trunk, ROOT now reverts the terminal to the colors that were set before ROOT started. Could you confirm by checking tomorrow’s ROOT build from ecsft.cern.ch/dist/ROOT/trunk/ (assuming we didn’t break ROOT in the meantime ?
Thanks for your good find!
I got root_trunk-snapshot-2012-07-24_r45170.Win32-i686-MSVC2010. It was checked on the Windows 7.
The background color of the screen is changed on the black. The screenshot is attached.