Problem with %_FG and %_BG

May 29, 2008
533
3
Groton, CT
#1
I'm trying to save the current colors, change them temporarily, and change them back, using something like this:

Code:
set savecolors=%_fg on %_bg
color  (something else)
(do some stuff)
color %savecolors
This always produces white on black.

Here's a test:
Code:
C:\Tv\TV_DATA\Groton> ver

TCC  12.11.69   Windows XP [Version 5.1.2600]

C:\Tv\TV_DATA\Groton> color bri white on green

C:\Tv\TV_DATA\Groton> echo %_fg on %_bg
Whi on Bla
My workaround for now is that I can restore to standard colors, rather than what was current at the time I save them, with
Code:
set savecolors=%@format[02,%@eval[%@option[StdColors]=h]]
but what I really want is a way to save and restore the current colors.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,619
46
Albuquerque, NM
prospero.unm.edu
#2
As I understand it, those two variables report the colors at the cursor position. In most cases, they will be white on black -- unless you have filled the screen buffer with something else via e.g. CLS BRI WHI ON GRE.

A variable or variables reporting the color TCC will use for stdout might be useful; but I don't think that's what _FG and _BG do.
 
May 29, 2008
533
3
Groton, CT
#3
As I understand it, those two variables report the colors at the cursor position. In most cases, they will be white on black -- unless you have filled the screen buffer with something else via e.g. CLS BRI WHI ON GRE.

A variable or variables reporting the color TCC will use for stdout might be useful; but I don't think that's what _FG and _BG do.
Ah, I see.

Rex, would you consider a way to read out the current values of the foreground and background colors as set by COLOR?