1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem with %_FG and %_BG

Discussion in 'Support' started by dcantor, Jul 29, 2011.

  1. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    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.
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,311
    Likes Received:
    39
    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.
     
  3. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    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?
     

Share This Page