0

I'm trying to get a program I'm running to display a bright colored background, but the program won't apply the brightness increase, it instead shows a 'normal' colored background.

Let me add some details:

  • I log into a server running Debian, through PuTTY, with the TERM variable set to putty (or manually do this using export TERM=putty).
  • I first try whether bright backgrounds show up correctly at all, using

    echo -e "\e[43mHello\e[0m \e[103mWorld\e[0m"
    

    You see that \e[43m is the code for setting the background to yellow and \e[103m is the code for setting the background color to bright yellow. The image below shows that it actually works:

    Both normal and bright yellow background work

  • Then I run the program I want to display such bright backgrounds. The program is the ACUCOBOL runtime. The manual says that it tries to read the TERM value and reads /etc/a_termcap by this value, selecting the (hopefully) proper terminal capabilities, if used on a *nix OS. The Windows client doesn't use any terminal capability info.

    The entry within the a_termcap file looks like this:

    putty|/PuTTY Colors:\
        :k1=\E[[A:k2=\E[[B:k3=\E[[C:k4=\E[[D:k5=\E[[E:k6=\E[17~:k7=\E[18~:\
        :k8=\E[19~:k9=\E[20~:k0=\E[21~:K1=\E[23~:K2=\E[24~:\
        :KE=\E[4~:KI=\E[2~:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:\
        :kh=\E[1~:al=\E[L:dl=\E[M:KX=\E[3~:li#25:DI=\E[m:kN=\E[G:kP=\E[I:\
        :cl=\E[;H\E[J:cm=\E[%i%d;%dH:ce=\E[K:cd=\E[J:DL:nd=\E[C:\
        :RV=\E[7m:HI=\E[0;1m:LO=\E[m:BL=\E[5m:UL=\E[4m:RB=\E[5;7m:RU=\E[4;7m:\
        :C1=\E[30m:C2=\E[34m:C3=\E[32m:C4=\E[36m:C5=\E[31m:C6=\E[35m:\
        :C7=\E[33m:C8=\E[37m:AC:\
        :B1=\E[40m:B2=\E[44m:B3=\E[42m:B4=\E[46m:B5=\E[41m:B6=\E[45m:\
        :B7=\E[43m:B8=\E[47m:UL@:RU@:\
        :GO=\016:GF=\017:\
        :GM=\161\170\154\153\155\152\166\164\167\165\156:
    

    The problem is that I can barely read these values, but the codes C1C8 and B1B8 refer to the foreground and background colors respectively, I think.

My guess is that the runtime is not aware of the codes \e[100m\e[107m. How can I fix this?


Edit

It seems that I can somehow can get black and white to be bright. Below a screenshot which allows both the bright and normal variants of black and white.

black and white bright


Edit

I have changed the terminal emulator name to putty and set the TERM variable accordingly. I don't think, however, that it matters.

  • The image is not from Linux's built-in terminal emulator, which does not produce the effect claimed in response to those control sequences. That is some other terminal emulator, not the Linux built-in one. – JdeBP Mar 15 '18 at 5:27
  • 1
    Linux's built-in terminal emulator does not have scroll bars, either. Are you going to tell us what terminal emulator you are actually using? – JdeBP Mar 15 '18 at 9:02
  • It doesn't matter - almost all of the available terminal emulators copied xterm's behavior. The actual question is whether ACUCOBOL can manage more than 8 colors (it cannot). – Thomas Dickey Mar 15 '18 at 9:23
  • @downvoter Care to explain the downvote? – MC Emperor Mar 15 '18 at 9:31
  • By the way, I'm using the PuTTY client. putty was not a valid entry within the a_termcap file, so I changed it to something the ACUCOBOL runtime would even understand. – MC Emperor Mar 15 '18 at 9:38
1

short: you can't

long: The ACUCOBOL support page explains what the termcap fields are. It knows about 8 colors, while your example expects to use the aixterm 16-color controls. Handling all 16 colors is beyond the ability of a termcap application (unless it cheats and formats its own strings rather than using tgoto).

You could make all of the backgrounds use bright colors, but you can't make some scenarios bright and some not. The places to modify would be B1 to B8 (colors 0-7 in the usual numbering convention):

:B1=\E[40m:B2=\E[44m:B3=\E[42m:B4=\E[46m:B5=\E[41m:B6=\E[45m:\
:B7=\E[43m:B8=\E[47m:

replacing 40 by 100, 41 by 101, etc.

By the way, TERM=linux is inconsistent with the example of an escape sequence which you gave (since Linux console's 16 colors are achieved by combining bold with colors 0-7, i.e., replacing 40 by 40;1, etc). You could copy that entry and change the name in the first line

linux|/Linux system console:\

to something more suitable, e.g.,

putty|bright-backgrounds:\

A termcap description cannot produce values in two ranges (40-47, 100-107 for example) since it doesn't support expressions. A terminfo description (not supported by ACUCOBOL, apparently) can do this. For example, ncurses has a 16-color Linux description. There are similar descriptions for other terminals, including whatever terminal you are actually using.

  • The GT Users' Guide has a more complete description than the Runtime Manual. – JdeBP Mar 15 '18 at 5:23
  • Its documentation of color is no better. – Thomas Dickey Mar 15 '18 at 8:02
  • Thanks for the explanation, it (now) makes sense to me. Leaves me with one last question (see question edit): why can the brightness still be applied to black and white? That should be impossible, isn't it? – MC Emperor Mar 15 '18 at 9:36
  • It looks like you ran a script which sent codes 100-107. You can modify a termcap to do that, but can't make it choose from both 40-47 and 100-107. – Thomas Dickey Mar 15 '18 at 21:07
  • Its documentation of colour gives the answer. It is not actually "you can't", and it's one of several reasons that correctly stating the output device in the question is important. – JdeBP Mar 16 '18 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.