Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

SCRPUT command uses defined ConPTY BG color when Black BG is specified

Jun
149
13
Here's an old script I had to display a grid of all 16 named colors on both the foreground and background.

Code:
@echo off

do BG in /L Black, Blue, Green, Cyan, Red, Magenta, Yellow, White
   echo.
   echo `---` %BG `/` Bright %BG background `-----------------------`
   do FG in /L Black, Blue, Green, Cyan, Red, Magenta, Yellow, White
      scrput /U +0 +0 %FG on %BG `|`%FG`|` & scrput /U +0 +0 bright %FG on %BG `|`bri %FG`|`
   enddo
   echo.
   do FG in /L Black, Blue, Green, Cyan, Red, Magenta, Yellow, White
      scrput /U +0 +0 %FG on bri %BG `|`%FG`|` & scrput /U +0 +0 bright %FG on bri %BG `|`bri %FG`|`
   enddo
   echo.
enddo

quit

And here's the output it produced.

1775697890720.webp


Note that the first display line, which should be displaying text on a black background is instead displaying on the BG color set for the ConPTY console. All the other colors are displaying correctly.

And no, I don't usually use a neon pink background. This was just to clearly identify the issue.

I set this color by opening the TCMD options, selecting the "Tabs" tab, and clicking the ConPTY BGColor button.

1775697850721.webp
 
Here's a similar test. It's not using the default BG color (a yucky green) but, like yours, it won't do black on black (30 on 40). But there's no problem doing the other colors on themselves.

1775702129824.webp
 
Here's what Rex said about this in the beta testing forum.

This is WAD, and it's not doing what you think it's doing.

TCMD has had a kludge-around for a Windows bug since Win10 came out. Windows was setting the colors on an ANSI reset to 0 FG and 0 BG. TCMD checks for both FG and BG being 0, and if so sets the FG to RGB(128,128,128). It's possible Microsoft has fixed this in newer versions of Windows 10/11; I haven't checked it lately.

You'll only see this behavior if you (1) run white on black, and (2) deliberately set your foreground to black.
 
Interesting Vince. You are specifying colors differently and getting different results.

I specified colors using the color names and couldn't get the black background to display with any foreground colors. (This issue only appears to be in ConPTY sessions and is not limited to the SCRPUT command. I also tried it with the DRAWBOX command, and it also used the ConPTY background color when I specified a black BG.)

Your test had no problem rendering a black background...but had issues with black text on the black background. Maybe two different issues?
 
Rex's statement doesn't quite match our observations. But there's a kludge in there.
 
I'm specifying colors with ANSI/VT control sequences (that goes back to MSDOS). You can do that without ConPty but you can only get the 16-color palette. With ConPty you can get 16 million colors using other control sequences. See my "Fun with colors" post in the Suggestions forum for a few more details. And see this document for much more about control sequences. Nearly all of them work with TCMD/ConPty.
 
This doesn't have anything to do with TCMD; it's a Windows issue with the FillConsoleOutputAttribute API in TCC/SCRPUT, which doesn't like black backgrounds in ConPTY. I'll have to dig around to see if I can force it another way.
I'm not so sure that this is the issue I'm experiencing.

In the script I included above, it appears that I can't get SCRPUT to write text of any color on a black background. When I specify a black BG, the actual background is rendered using the default ConPTY BG color.

However, if I change the default ConPTY BG color to black, then I get this result.

1775705196828.webp


Note that in the first line that all the FG colors appear fine on the black background, except for the Black FG, which is changed as you described above to BRIght BLAack.

It sure behaves as if the named color Black (when used as a background) is somehow picking up the ConPTY BG color instead.

Is this what you would expect from the issue you mentioned above or could this be a different issue with Windows ConPTY?
 
Last edited by a moderator:
This is definitely a bug in the Windows FillConsoleOutputAttribute API, which refuses to write a black background in a ConPTY window. This breaks both SCRPUT and COLOR in TCC, with no TCMD involved.

Writing an ANSI color sequence with a black background does work; I've made a change in TCC for the (many) places I use FillConsoleOutputAttribute to set the screen attributes.

Curiously, it works in Windows Terminal -- but that's because they're using Detours to intercept the FillConsoleOutputAttribute calls.
 
Back
Top