ftp.nice.ch/pub/next/unix/editor/vile-filters.tar.gz#/vile-filters/vile-cfilt.pl

This is vile-cfilt.pl in view mode; [Download] [Up]

(Message inbox:1198)
Return-Path: ecn.purdue.edu!cavanaug
Return-Path: <ecn.purdue.edu!cavanaug>
Received: by gutso: id m0rwUal-0000WmC; 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 IAA05147 for <pgf@foxharp.boston.ma.us>; Wed, 5 Apr 1995 08:30:17 -0400
Received: from elwom4.ecn.purdue.edu by fcr.fcr.com (8.6.9/8.6.9) with ESMTP
	id IAA05147 for <pgf@foxharp.boston.ma.us>; Wed, 5 Apr 1995 08:30:17 -0400
Received: from elwom4.ecn.purdue.edu (cavanaug@localhost)
	by elwom4.ecn.purdue.edu (8.6.10/3.5davy)
	id IAA12776; Wed, 5 Apr 1995 08:30:37 -0400
Message-Id: <199504051230.IAA12776@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:30:37 -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: 3576      

> 
>  > 
>  > Well two things here.  I was wondering when color support for x11 would
>  > be available.
> it's there now.  see the last of the X-resource descriptions in the help
> file.  (search for "fcolor1")

Ive got it working for xvile now.  Its cool thanks. 
Now however I cant get it to work for DISPANSI on a terminal
emulator that accepts ansi color sequences (Im using ncurses x.x.7 on
HPUX)

>  > The other is this.  Its a relatively easily extendable colorizing filter
>  > written in perl 5.  The one I mailed you is for perl (Its becoming my
>  > pet language)
> thanks -- i'll take a look.  i'm afraid i don't have perl5 yet...

Here is one for C/C++
Ill also mail you the new one for perl.

-----------------------------------------------------------------------
  John Cavanaugh                                   Purdue University
             Email: cavanaug@ecn.purdue.edu  
               WWW: http://albrecht.ecn.purdue.edu/~cavanaug
-----------------------------------------------------------------------
                  Don't find fault, find a remedy.
                                                -- Henry Ford
-----------------------------------------------------------------------

#!/GNU/bin/perl
###########################################################################
#
#
#             Script: vile-cfilt.p
#           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:";

$CKeywords="void break register short enum extern int for if while struct "
	. "static long continue switch case char unsigned double float "
	. "return else default goto do pascal Boolean typedef volatile union "
	. "auto sizeof size_t new delete class friend protected private "
	. "public template try catch throw operator const mutable virtual "
	. "asm inline this and and_eq bitand bitor compl not or or_eq xor "
	. "xor_eq not_eq wchar_t bool true false static_cast dynamic_cast "
	. "reinterpret_cast typeid using namespace inherited";
$CKeywords=~ s/ /\|/g;

$/="";

while (<>) 
{
   # Do comments in italic 
   s|(/\*[^\000]*?\*/)|comment($1)|oeg;

   # Do preprocessor directives in color3;
   s/(\#[ \t]*.*\n)/bold($1)/oeg;

   # Do Keywords in uline
   s/\b($CKeywords)\b/uline($1)/oegs;

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

   print $_;
} 

sub comment
{
	local($bigcomment)=@_[0];
	local(@linecomment)=split('\n',$bigcomment);
	local($retval)="";

    foreach $line (@linecomment)
	  { $line=~ s/^(.*)$/italic($1)/oeg;
	    $retval.=$line . "\n"; }

	return $retval;
}

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]; }

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.