(Message inbox:1199)
Return-Path: ecn.purdue.edu!cavanaug
Return-Path: <ecn.purdue.edu!cavanaug>
Received: by gutso: id m0rwUam-0000WqC; Wed, 5 Apr 95 08:53 EDT
Received: from elwom4.ecn.purdue.edu by fcr.fcr.com (8.6.9/8.6.9) with ESMTP
	id IAA05154 for <pgf@foxharp.boston.ma.us>; Wed, 5 Apr 1995 08:31:17 -0400
Received: from elwom4.ecn.purdue.edu by fcr.fcr.com (8.6.9/8.6.9) with ESMTP
	id IAA05154 for <pgf@foxharp.boston.ma.us>; Wed, 5 Apr 1995 08:31:17 -0400
Received: from elwom4.ecn.purdue.edu (cavanaug@localhost)
	by elwom4.ecn.purdue.edu (8.6.10/3.5davy)
	id IAA12789; Wed, 5 Apr 1995 08:31:44 -0400
Message-Id: <199504051231.IAA12789@elwom4.ecn.purdue.edu>
From: John P Cavanaugh <cavanaug@ecn.purdue.edu>
Subject: Re: Colorizing in vile.......
To: pgf@foxharp.boston.ma.us
Date: Wed, 5 Apr 1995 08:31:44 -0400 (EDT)
In-Reply-To: <m0rvP7O-0000WmC@gutso> from "Paul Fox" at Apr 2, 95 08:51:01 am
X-Mailer: ELM [version 2.4 PL23]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 3496      


Here is one for perl.....


#!/GNU/bin/perl
###########################################################################
#
#
#             Script: vile-pfilt.pl
#           Revision: $Revision
#
#            Creator: cavanaug@elwom4.ecn.purdue.edu (John P Cavanaugh)
#               Date: Fri Mar 31 22:34:19 1995
#
#     Basic Overview: <overview of this scripts purpose in life>
#                     <aligned like this>
#
#             Returns: <type> - <description>
#
#           Arguments: <type> <varname>
#                          <parameter description>
#
#  Comments/Concerns: <general comments and/or concerns about code>
#
###########################################################################

$CTRL_A="\001";

$BOLD="B:";
$ULINE="U:";
$ITALIC="I:";
$COLOR1="C1:";
$COLOR2="C2:";
$COLOR3="C3:";
$COLOR4="C4:";

$perlkeywords="accept alarm atan2 bind binmode caller chdir chmod chop chown chroot "
    . "close closedir connect continue cos crypt dbmclose dbmopen defined "
    . "delete die do dump each else elsif eof eval exec exit exp fcntl fileno "
    . "flock for foreach fork getc getlogin getpeername getpgrp getppid "
    . "getpriority getgrnam gethostbyname getnetbyname getprotobyname getpwuid "
    . "getgrgid getservbyname gethostbyaddr getnetbyaddr getprotobynumber "
    . "getservbyport getpwent getgrent gethostent getnetent getprotoent "
    . "getservent setpwent setgrent sethostent setnetent setprotoent setservent "
    . "endpwent endgrent endhostent endnetent endprotoent endservent "
    . "getsockname getsockopt gmtime goto grep hex if index int ioctl join keys "
    . "kill last length link listen local localtime log lstat lstat mkdir "
    . "msgctl msgget msgsnd msgrcv next oct open opendir ord pack pipe pop "
    . "print print printf printf push q qq qx rand read readdir readlink recv "
    . "redo rename require reset return reverse rewinddir rindex rindex rmdir "
    . "scalar seek seekdir select semctl semget semop send setpgrp setpriority "
    . "setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep "
    . "socket socketpair sort splice split sprintf sqrt srand stat study sub "
    . "substr symlink syscall sysread system syswrite tell telldir time times "
    . "tr truncate umask undef unless unlink unpack unshift until utime values "
    . "vec wait waitpid wantarray warn while write eq ne cmp lt gt le ge";
$perlkeywords=~ s/ /\|/g;

$perlvariables='@_ $_ $. $/ $, $" $\\ $\# $% $= $- $~ $^ $| $$ $? $& $` $\' $+ $* ' 
             . '$0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $[ $] $; $! $@ $< $> $( $) $: '
             . '$^D $^F $^I $^P $^T $^W $^X $ARGV @ARGV @INC %INC $ENV $SIG';
$perlvariables=~ s/([^ \w])/\\$1/g;
$perlvariables=~ s/ /\|/g;

$\="";

while (<>) 
{
   chop($_);

   # Do comments in italic 
   s/(\#.*)$/italic($1)/oe;

   # Do keywords in uline
   s/\b($perlkeywords)\b/bold($1)/oeg;

   # Do perl variables in color3
   s/($perlvariables)/color3($1)/oeg;

   # Do brackets in bold
   s/([{}])/bold($1)/oeg;

   print $_ . "\n";
} 

sub bold    { return $CTRL_A . length(@_[0]) . $BOLD . @_[0]; }
sub uline   { return $CTRL_A . length(@_[0]) . $ULINE . @_[0]; }
sub italic  { return $CTRL_A . length(@_[0]) . $ITALIC . @_[0]; }
sub color1  { return $CTRL_A . length(@_[0]) . $COLOR1 . @_[0]; }
sub color2  { return $CTRL_A . length(@_[0]) . $COLOR2 . @_[0]; }
sub color3  { return $CTRL_A . length(@_[0]) . $COLOR3 . @_[0]; }
sub color4  { return $CTRL_A . length(@_[0]) . $COLOR4 . @_[0]; }

