Welcome!

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

SignUp Now!

Can't get TCC to render text on a black background

Jun
174
15
I have my default colors set to bright white on blue. I was trying to display some text on a black background and it doesn't seem to be working.

I've tried using a COLOR/ECHO combination (see example below) and using the SCRPUT command and neither approach appears to be able to display text on a black background.

I also have a ColorDir specification which is set to display BTM and BAT files on a black background, and that doesn't work either. (see below).

These issues exist in both Version 36 and 37. Version 35 doesn't have any trouble displaying text on a black background.


1794699462609.webp
 
There are two issues here:

1. As the COLOR docs say, setting default input and output colors will override COLOR specs.
2. An RGB value of 0 can mean either "black" or "use the default background color". When you've changed the default background color, TCMD defaults to using that value. (Curiously, in the same situation Windows Terminal defaults to using gray.)

You can avoid the confusion with issue #1 by using the RGB color option in COLOR instead of the 16-color strings. If you using something like 1 (or 010101) it will look black but not be confused with the default color.
 
There are two issues here:

1. As the COLOR docs say, setting default input and output colors will override COLOR specs.
2. An RGB value of 0 can mean either "black" or "use the default background color". When you've changed the default background color, TCMD defaults to using that value. (Curiously, in the same situation Windows Terminal defaults to using gray.)

You can avoid the confusion with issue #1 by using the RGB color option in COLOR instead of the 16-color strings. If you using something like 1 (or 010101) it will look black but not be confused with the default color.

Thanks for the response and explanation, Rex.

I was trying to make your suggestion of using an RGB "near black" color work with the COLOR command, but so far I have been unsuccessful.

If I'm interpreting the help correctly it appears that in order to use the /FG and /BG parameters with COLOR I need to be running a stand-alone TCC session. This makes this solution a lot less valuable to me. It's probably easier for me to just pick another color or use ANSI sequences as needed.

Nonetheless, I started a stand alone session and tried to set RGB colors using /FG and /BG, but I'm seeing usage errors. Maybe I have the syntax wrong, but the help didn't have an example of how to specify RGB values.

1794887861886.webp
 
Good catch on RGB 0 colliding with the default background sentinel value—using 010101 is a neat workaround since it is visually indistinguishable from pure black while still being treated as an explicit RGB override. That also explains why ColorDir entries for BAT and BTM files behaved differently once a non-black default background was configured.
 
Does this work?

Code:
echo ^e[48;2;0;0;0m^e[38;2;255;255;255mbright white on black^e[0m
 
Does this work?

Code:
echo ^e[48;2;0;0;0m^e[38;2;255;255;255mbright white on black^e[0m

Yes. But I find it a little awkward to read.

Building on an idea I saw somewhere in this forum, I've started to collect some common ANSI strings in a callable .BTM

Code:
@echo off

set +WhiteOnBlack=`^e[48;2;0;0;0m^e[38;2;255;255;255m`

set +Reset=`^e[0m`

set +Bold=`^e[1m`
set -Bold=`^e[22m`

set +Blink=`^e[5m`
set -Blink=`^e[25m`

So if I want to use these codes in a script, I can call SetANSIvars.btm first. Then I can write lines like these:

Code:
echo %[+WhiteOnBlack] Hello There %[+Reset]
echo %[+WhiteOnBlack]%[+Bold] A bold hello to you! %[-Bold]
echo %[+Reset] Back to Blue
echo %[+Blink] May I have your attention...%[-Blink]
 
As you probably know there are simpler SGR control sequences that can do the job but they're likely to depend on the current 16-color palette. In any event, I think SGR control sequences are a safer way to go than the COLOR command
 
COLOR in v37 didn't allow changing both the RGB background color and foreground color in a single COLOR command. I have changed COLOR in 37.0.19 (already uploaded) to support this.

I'm not sure if this is fixable or not, but there is a distinct difference in how the COLOR command works with the 16 named colors vs. the FG/BG usage of RGB colors.

Referencing the screen below. Immediately after opening TC, if I execute the line beginning with "color bright yellow on green...." only the text "Hello Green background" is displayed with a green background.

But when I execute the line beginning with "color /BG:...", then the text "Hello Black background" is displayed with a black background, but the remainder of the visible screen is also colored with a black background. It appears that the default colors for the tab window are also changed as indicated by the black border areas on the left and right of the display area. You can also see the default colors are changing by noting the color of the prompt displayed after issuing an ANSI reset.

What's a little unexpected (to me at least) is that this behavior (FG/BG changing the default tab colors) only happens if COLOR FG/BG is executed before output in the tab window reaches the bottom and starts to scroll. For example, If I open a brand-new TC instance and execute a DIR command or a CLS command, then execute "COLOR /BG:...", the color command behaves as expected - only changing the color of the displayed text and not the rest of the tab window area.

Is this a bug, WAD, or an unavoidable limitation to adding RGB support to COLOR?


1795206796809.webp
 
Back
Top