Colors, ^@ support
Colors, ^@ support
Posted Jun 5, 2004 6:01 UTC (Sat) by utoddl (guest, #1232)Parent article: The Grumpy Editor's guide to terminal emulators
I used to hope gnome-terminal would start passing ^@ to the application (as one of my apps needs it, and I use it regularly). Maybe it does now, but I just use xterm. Anyway, if anyone's compiling a list of things to check for in terminal emulators, please add that to the list.
As for colors, I finally gave up trying to find a combo I wanted to stick with. Instead, I found a whole class of background colors I like. So I wrote an xterm starter in Perl that picks a suitable background color for me at random from those that meet my criteria. It gets called when I click on one of those new-fangled icon thingies at the bottom of my screen. It's a work in progress that sort of stopped progressing when it got good enough. Yeah, it's a resource hog, but they're my resources. (Oh, and the indentation/brace placement style you've never seen before is as God intended. :) Here goes. Enjoy:
#!/usr/bin/perl
my @colors = ( 'wheat' );
if ( open COLORS, "/usr/X11R6/bin/showrgb|" )
{
my ($minc, $mind, $maxd ) = ( 127, 7, 97 );
while (<COLORS>)
{
chomp;
my ($r,$g,$b,$cname) = split /\s+/,$_,4;
next unless $r > $minc && $g > $minc && $b > $minc &&
abs( $r - $g) > $mind && abs( $r - $g) < $maxd &&
abs( $r - $b) > $mind && abs( $r - $b) < $maxd &&
abs( $g - $b) > $mind && abs( $g - $b) < $maxd;
push @colors, $cname;
}
close COLORS;
}
my $bg = $colors[ int( rand @colors ) ];
exec '/usr/X11R6/bin/xterm', '-bg', $bg, '-fg', 'black', '-fn', '9x15';
