View Single Post
Old 05-03-2006, 08:50 PM
ErnieLongmire ErnieLongmire is offline
Registered User
Join Date: Nov 2004
Posts: 18

I think I've solved this, or at least figured out what's causing it. It looks like under certain circumstances, SCRT will lose a character while processing the escape sequence that loads a color into Xterm's 256-color index table:

ESC ] 4 ; index ; rgb:rval/gval/bval ESC \

When that happens, the default color value for that table position remains unchanged, which can show up as an unexpected color value as shown in the screencap I posted earlier. This happens for me in SCRT versions up through 5.1.0 build 263.

Here's another script that shows the bug for me pretty consistently:

#!/usr/bin/perl -w

printf "before\n\n"; &show_colors;
printf "press enter to load replacement color table: ";
readline(*STDIN); &load_colors;
printf "after\n\n"; &show_colors;
printf "\x1b[39m\x1b[49m\n\n";

sub load_colors {
  for (my $i = 16; $i <= 255; $i++) {
    printf "\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", $i, $i, $i, $i;
    printf "\x1b[38;5;%dm%d: %2.2x/%2.2x/%2.2x\n", $i, $i, $i, $i, $i;

sub show_colors {
  for (my $bgix = 0, $fgix = 255; $bgix <= 255; $bgix++, $fgix--) {
    printf "\x1b[48;5;%dm\x1b[38;5;%dm**", $bgix, $fgix;
    if (! (($bgix+1) % 16)) { print "\x1b[48;5;0m\x1b[38;5;255m\n"; }
  printf "\x1b[0m\n";
What'll usually happen is that while it's loading the color table (and printing each value as it's loaded) I'll get a couple of output glitches like these:

203: cb/cb/cb
204: cc/cc/cc
;205;rgb:cd/cd/cd205: cd/cd/cd
206: ce/ce/ce
207: cf/cf/cf

with the result that color position 80 keeps its default value, which shows up when the new color table is used.

After running the script you can reset the color table with Edit > Reset from SCRT's menu bar.

Please let me know if this helps you reproduce the behavior.