Update of /cvsroot/squirrel-sql/mavenize/thirdparty-non-maven/ostermiller-syntax/src/main/resources/com/Ostermiller/Syntax
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv32334/thirdparty-non-maven/ostermiller-syntax/src/main/resources/com/Ostermiller/Syntax
Added Files:
tohtml.bte texted.bte release.sh page.bte editor.bte
simple.bte license.bte ToHTML.properties features.bte
install.bte COPYING.TXT ant.bte package.html index.bte
syntax.bte spell.sh download.bte
Log Message:
Source for thirdparty dependency. Maven central requires a valid source code repository for artifacts that it hosts. This project has none, so we host it here for the time being.
--- NEW FILE: ToHTML.properties ---
license=This program is free software; you can redistribute it and/or modify\n\
it under the terms of the GNU General Public License as published by\n\
the Free Software Foundation; either version 2 of the License, or\n\
(at your option) any later version.\n\
\n\
This program is distributed in the hope that it will be useful,\n\
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
GNU General Public License for more details.
version=Version {0}
copyright=Copyright (c) {0} by {1}
stdin.message=If no files are specified standard input will be used.
default=default
purpose.message=Converts source files to syntax colored HTML.
tohtml=ToHTML
files=files
help.option=help
help.message=Print this help message.
version.option=version
version.message=Print out the version number.
about.option=about
about.message=Print out license and contact info.
m.option=mime
m.message=Input is the given mime type. text/html, text/x-java...
l.option=lexer
l.message=Java class name of the lexer to use.
type=type
T.option=title
T.message=Use the given title in the html page.
title=title
i.option=ignore
i.message=CSS class name of token to ignore, eg. "whitespace"
class=class
t.option=template
t.message=BTE template to use. see: ostermiller.org/bte
url=URL
s.option=css
s.message=Cascading Style Sheet to which html should be linked.
o.option=output
o.message=Output file, output directory, or -- for standard output.
file=file
f.option=force
f.message=Overwrite files without prompting.
unexpectedArgument=Unexpected argument, use --help for help.
fileExists={0} already exists, use -f to overwrite without prompting.
r.option=trans
r.message=translate a CSS style into another style.
translate=old=new
unexpectedTranslation=Malformed translation. Format: canonicalStyleName=newStyleName
--- NEW FILE: texted.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>Programmer's Editor Demonstration<%/bte.tpl%>
<%bte.tpl name=keywords%>text editor,text,programmer,editor<%/bte.tpl%>
<%bte.tpl name=description%>A simple text editor with syntax highlighting written in Java.<%/bte.tpl%>
<%bte.tpl name=bareditor%><span class=currentpage>Programmer's Editor</span><%/bte.tpl%>
<%bte.tpl name=pageContent%>
<p>A very simple text editor that correctly and efficiently colors the source code.
See the <a href="editor.html">tutorial</a> on incorporating syntax highlighting into a text editor.</p>
<p>To run, double click syntax.jar or try one of these command lines:<br>
<b>java -jar syntax.jar</b><br>
<b>java -classpath syntax.jar com.Ostermiller.Syntax.ProgrammerEditorDemo</b></p>
<p>Due to a <a href="http://developer.java.sun.com/developer/bugParade/bugs/4406598.html">bug in Java 1.2</a>
that does not set the background and foreground colors of a JTextPane correctly, Java 1.3 or later
is recommended unless you remove calls to <code>.setBackground(Color.white)</code> and recompile.
(Thanks to Collin Lee for pointing this out.)</p>
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: index.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>Syntax Highlighting<%/bte.tpl%>
<%bte.tpl name=keywords%>syntax,highlighting,color,java,library,libraries,free,freeware,gpl,open source,free-ware,source,code,source code,source-code,software,program<%/bte.tpl%>
<%bte.tpl name=description%>Java libraries for coloring programming source code to HTML or in a text editor.<%/bte.tpl%>
<%bte.tpl name=baroverview%><span class=currentpage>Overview</span><%/bte.tpl%>
<%bte.tpl name=pageContent%>
<p>The com.Ostermiller.Syntax package is designed to add syntax coloring to
web pages that display source code or to add color syntax highlighting ability to any
text editor written in Java.</p>
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: syntax.bte ---
<%bte.doc output="false"%>
<%bte.tpl name=page %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title><%bte.inc name=pageTitle %></title><%bte.grp onNoResolve=warning %>
<meta name="description" content="<%bte.inc name=description %>"><%/bte.grp %><%bte.grp onNoResolve=warning %>
<meta name="keywords" content="<%bte.inc name=keywords %>,syntax highlighting,syntax coloring,syntax,color,highlight,highlighting,colored,coloring,highlighted"><%/bte.grp %>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" media="screen" title="Web View" href="style.css" type="text/css">
<link rel="stylesheet" media="print" href="printable.css" type="text/css">
<link rel="alternate stylesheet" media="screen" title="Print Preview" href="printable.css" type="text/css">
<base href="http://ostermiller.org/syntax/">
</head>
<body>
<p class=nostyle><%bte.inc name=pageTitle %> - <a href="#content">Skip Header</a><%bte.grp onNoResolve=ok%><%bte.inc name=noStyleLinks%><%/bte.grp%></p>
<div class="sidebar">
<a href="./"><img border="0" src="syntax.gif" alt="Syntax Highlighting" height="62" width="175" align="left"></a><br>
<p><%bte.grp ondefault=ok%><%bte.inc name=baroverview%><%/bte.grp%><br>
<%bte.grp ondefault=ok%><%bte.inc name=bardownload%><%/bte.grp%><br>
<%bte.grp ondefault=ok%><%bte.inc name=barinstall%><%/bte.grp%><br>
<%bte.grp ondefault=ok%><%bte.inc name=barfeatures%><%/bte.grp%><br>
<%bte.grp ondefault=ok%><%bte.inc name=bartohtml%><%/bte.grp%><br>
<%bte.grp ondefault=ok%><%bte.inc name=bareditor%><%/bte.grp%><br>
<%bte.grp ondefault=ok%><%bte.inc name=barlicense%><%/bte.grp%></p>
</div>
<h1><%bte.inc name=pageTitle %></h1>
<div><%bte.inc name=pageContent %></div>
<br clear=all>
<div class=copyright><p>Copyright 1999-2005 <a href="http://ostermiller.org/contact.pl?regarding=Syntax+Highlighting" class=mail>Stephen Ostermiller</a></p></div>
</body>
</html><%/bte.tpl%>
<%bte.tpl name=baroverview%><a href="./">Overview</a><%/bte.tpl%>
<%bte.tpl name=bardownload%><a href="download.html">Download</a><%/bte.tpl%>
<%bte.tpl name=barinstall%><a href="install.html">Install</a><%/bte.tpl%>
<%bte.tpl name=barfeatures%><a href="features.html">Supported Formats</a><%/bte.tpl%>
<%bte.tpl name=bartohtml%><a href="tohtml.html">Color Web Pages</a><%/bte.tpl%>
<%bte.tpl name=bareditor%><a href="texted.html">Programmer's Editor</a><%/bte.tpl%>
<%bte.tpl name=barlicense%><a href="license.html">License</a><%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: tohtml.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>Syntax Highlighting HTML<%/bte.tpl%>
<%bte.tpl name=keywords%>web,HTML,tohtml,page,pages,document,documents<%/bte.tpl%>
<%bte.tpl name=description%>A program to turn source code into colored web pages.<%/bte.tpl%>
<%bte.tpl name=bartohtml%><span class=currentpage>Color Web Pages</span><%/bte.tpl%>
<%bte.tpl name=pageContent%>
<p>The com.Ostermiller.Syntax package comes with a program to turn
source code into colored web pages. The program is a command line Java program.</p>
<p>To run, use the command line:<br>
<b>java -classpath syntax.jar com.Ostermiller.Syntax.ToHTML --help</b><br>
<br clear=all>
<div style='border: black inset;padding:.2cm;'>
<pre>ToHTML [-mlTitsofr] <files>
Converts source files to syntax colored HTML.
If no files are specified standard input will be used.
--help Print this help message.
--version Print out the version number.
--about Print out license and contact info.
-m --mime <type> Input is the given mime type. text/html, text/x-java...
-l --lexer <class> Java class name of the lexer to use.
-T --title <title> Use the given title in the html page.
-i --ignore <class> CSS class name of token to ignore, eg. "whitespace"
-t --template <URL> BTE template to use. see: <a href="http://ostermiller.org/bte/">ostermiller.org/bte</a>
-s --css <URL> Cascading Style Sheet to which html should be linked.
-o --output <file> Output file, output directory, or -- for standard output.
-f --force Overwrite files without prompting.
-r --trans <old=new> translate a CSS style into another style.</pre>
</div>
<p>The resulting html documents will generally be much smaller if the <b>-i whitespace</b> option
is used. This is acceptable as long as styles used do not effect whitespace. An example of a style
that would effect whitespace would be background color.
Also consider translating styles into styles with shorter names and editing
the style sheet. For example you might want to use <b>-r keyword=k</b>.</p>
<p> BTE template files are used to customize the output. The BTE system is a separate
download. It must just be placed in the classpath or placed in the Java extensions directory.
The -t option can then be used to specify
a desired template such as the <a href="page.bte">default template</a>. Using templates you can easily customize the look
and feel of the generated html and add your own content.</p>
<p>If you are coloring your source files in a project which you build with Ant,
you can use an <a href="ant.html">Ant task</a>.
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: COPYING.TXT ---
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
--- NEW FILE: download.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>Download<%/bte.tpl%>
<%bte.tpl name=keywords%>download,get,get<%/bte.tpl%>
<%bte.tpl name=description%>Download Java libraries for coloring programming source code to HTML or in a text editor.<%/bte.tpl%>
<%bte.tpl name=bardownload%><span class=currentpage>Download</span><%/bte.tpl%>
<%bte.tpl name=pageContent%>
<p><a href="http://java.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=www.java.com:80" target="_new">Download</a> and install the Java2 Runtime Environment (J2SE JRE) version 1.5 or later from java.sun.com if you do not already have it installed.</p>
<p><a href="syntax.jar">Download</a> the com.Ostermiller.Syntax package in jar format. (Includes source code - 346k)</p>
<p>view the <a href="docs/">documentation.</a></p>
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: editor.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>Text Editor Tutorial<%/bte.tpl%>
<%bte.tpl name=keywords%>text editor, text editor, text editor, tutorial, tutorial, howto, write, writing, program, programming, programmer<%/bte.tpl%>
<%bte.tpl name=description%>A tutorial on writing a text editor in Java that incorporates syntax highlighting.<%/bte.tpl%>
<%bte.tpl name=pageContent%>
<p>Despite initial appearances, writing a text editor is not a trivial task. Creating text editors takes programming experience and a firm basis in theory. The Internet is littered with hundreds of unfinished or poorly working text editors. While this this tutorial does not tell you everything you need to know to write your own text editor, you will learn how to add syntax highlighting and and gain a sense of the overall complexity of undertaking such a project.</p>
<p>This tutorial assumes that you have a text area to work with and that you can change the color of the text in that text area. Luckily, the libraries that come with Java include a JTextPane (<a href="http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTextPane.html">API</a>). The Programmer's Editor Demo included with this tutorial uses JTextPane but the techniques discussed here will work with other base editor classes as well. Before going any further, it would be a good idea to familiarize yourself the <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html">JTextPane Tutorial</a> in Sun's Java Tutorial.</p>
<h2>What You Will Need</h2>
<p>If you haven't done so already, <a href="download.html">download</a> the syntax highlighting package and the ProgrammerEditorDemo.java that comes with it. If you would like you may <a href="http://www.gjt.org/servlets/JCVSlet/show/gjt/com/Ostermiller/Syntax/ProgrammerEditorDemo.java/HEAD">browse</a> the source code for the demo.</p>
<h3><a href="texted.html">Running the Demo</a></h3>
The demo is a very simple text editor:<br>
<img src="ProgrammerEditorDemo.png" vspace="10" width="627" height="509" alt="Screen-shot of demo with a Java Hello World program displayed."><br>
The demo supports cut, copy, paste, and syntax highlighting, but little else. It doesn't even open and save files.
<h2>The Basics</h2>
<p>Syntax Highlighting works like this: you give the text to the lexer, it goes through it and gives it back to you piece by piece and tells you what color to make each piece.</p>
<h3>Streams and Readers</h3>
<p>The syntax lexers accept your document through Streams and Readers. Fortunately it is very easy to turn just about anything into a Stream or a Reader. Java comes with many pre-built classes for this purpose. A FileReader or a StringReader could be used. The demo uses a custom DocumentReader.</p>
<h3>Tokens</h3>
<p>The lexer returns <a href="docs/com/Ostermiller/Syntax/Lexer/Token.html">Tokens</a>. Tokens don't tell you the actual color that the text should be, but they do give you enough information to figure it out. The token contains such useful information as the type of text, a description of the text, and the position of the text in the file.</p>
<h3>Basic Example</h3>
<pre>JavaLexer syntaxLexer = new JavaLexer(new StringReader(myDocumentText));
Token t;
while ((t = syntaxLexer.getNextToken()) != null){
// color the part of the document
// to which the token refers here.
}</pre>
<p>The Demo uses a look-up hashtable to get the color of the text based on the description from the token.</p>
<pre>SimpleAttributeSet style;
style = new SimpleAttributeSet();
StyleConstants.setFontFamily(style, "Monospaced");
StyleConstants.setFontSize(style, 12);
StyleConstants.setBackground(style, Color.white);
StyleConstants.setForeground(style, Color.black);
StyleConstants.setBold(style, false);
StyleConstants.setItalic(style, false);
styles.put("body", style);
style = new SimpleAttributeSet();
StyleConstants.setFontFamily(style, "Monospaced");
StyleConstants.setFontSize(style, 12);
StyleConstants.setBackground(style, Color.white);
StyleConstants.setForeground(style, Color.blue);
StyleConstants.setBold(style, true);
StyleConstants.setItalic(style, false);
styles.put("tag", style);
...</pre>
<p>The section of text in the document is then colored according to the style retrieved from the
look-up table.</p>
<pre>document.setCharacterAttributes(
t.getCharBegin(),
t.getCharEnd()-t.getCharBegin(),
getStyle(t.getDescription()),
true
);</pre>
<h2>Coloring Parts of the Document</h2>
<p>The entire document is colored and it looks good in the editor. You might think that this is the end of the story. Sadly, its not. Editors are meant to edit documents. The documents change. The obvious approach is to re-color the document when the text changes. This may work for small documents, but as the document size gets larger it will quickly become unwieldy. For a 1000 line document, it could take as much as a few seconds to color the entire document. Waiting a few seconds each time a character is typed does not make for a good text editor.<p>
<p>The trick is that not all of the document needs to be re-colored when something changes. But how much really needs to be re-colored? Not many editors do this part right. I have seen editors that re-color the previous three lines and the next three lines. That approach works most of the time, but it is pretty easy to fool.</p>
<h3>Initial State</h3>
<p>Every so often the syntax lexer returns to what are known as the initial state. At these times, the lexer returns a token and continues lexing as if it were at the beginning of the document again. Since the lexer acts as if it were at the beginning of the document from an initial state, the lexer could be restarted from this point without effecting the coloring of what comes afterwords. It can be determined from the last token returned if the lexer is in the initial state after returning that token.</p>
<p>So that solves half the problem. Just re-color the document from the last initial state. If the user is only going to append to the end of the document, this solves the problem. We can just keep track of the last initial state and re-color from there to the end of the document. But what if something in the middle of the document changes? We really need to keep track of <em>all</em> initial states so that we can restart the lexer from near anywhere in the document. Then we won't need to color the entire rest of the document either. If the lexer returns to an initial state at the same point that it returned to an initial state the last time, the rest of the document is already colored correctly.</p>
<h4>Example</h4>
<p>The demo keeps the list of initial states in a balanced tree. If desired the list could be included with the meta data of the document or stored in some other fashion. Care must be taken when looking at initial positions after start position. If text has been added or removed from the document, the positions after the addition/removal will have changed.<P>
<h3>Only what is Visible</h3>
<p>The initial coloring time for a document may become an issue. One way around this would be to only color what is visible on the screen. If the user scrolls, then more of the document will have to be colored as the user scrolls.
<p>Another approach that is used by the demo is to start a separate thread to do the coloring. In this case, the document coloring happens in the background and the user may modify the document while that happens.</p>
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: install.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>Install<%/bte.tpl%>
<%bte.tpl name=keywords%>install,installation<%/bte.tpl%>
<%bte.tpl name=description%>Install Java libraries for coloring programming source code to HTML or in a text editor.<%/bte.tpl%>
<%bte.tpl name=barinstall%><span class=currentpage>Install</span><%/bte.tpl%>
<%bte.tpl name=pageContent%>
The syntax coloring libraries are pre-compiled and ready to use.
Simply use one of the following to add syntax.jar to your classpath:
<ul>
<li>Put syntax.jar in the <a href="http://java.sun.com/products/jdk/1.2/docs/guide/extensions/extensions.html#installed">Java extensions directory</a>.</li>
<li>Set your <a href="http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html">CLASSPATH environment variable</a> to include syntax.jar.</li>
<li>Specify syntax.jar in the command line classpath when you compile and run your programs.</li>
<li>Extract syntax.jar to a folder already in your classpath.</li>
<li>Include the contents of syntax.jar in your program's jar file.</li>
<li>Reference syntax.jar from the manifest file in your program's jar file.</li>
</ul>
You can extract the contents of syntax.jar either with the jar tool that comes with java or by
renaming syntax.jar to syntax.zip and using any zip file extractor.
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: package.html ---
<html>
<body>
This package contains classes for <A HREF="http://ostermiller.org/syntax/">Syntax Highlighting</A> source files.
@author <a href="http://ostermiller.org/contact.pl?regarding=Syntax+Highlighting">Stephen Ostermiller</a>
@gjtlicense GPL
@gjtcompile yes
@gjtcat library
@gjtjvm 1.4
@gjthome <http://ostermiller.org/syntax/> Syntax Highlighting
@gjtdate $Date: 2010/01/26 20:54:47 $
@gjtmain com.Ostermiller.Syntax.ToHTML
</body>
</html>
--- NEW FILE: page.bte ---
<%bte.doc output=false%>
<%bte.tpl name=page%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%bte.grp onNoResolve=ok %><title><%bte.inc name="title"%></title><%/bte.grp%>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<%bte.grp onNoResolve=ok %><link rel="stylesheet" media="screen" title="Syntax Highlighting" href="<%bte.inc name="styleSheet"%>" type="text/css"><%/bte.grp%>
</head>
<body>
<%bte.inc name="highlightedDocument"%>
<div style="border: thin black ridge;padding:1cm;">
<!--
To customize the appearance of the html that is emitted you must create a BTE
template file and specify that template file on the command line when creating syntax
highlighted html documents. BTE template files are explained at:
http://ostermiller.org/bte/
The default template file can be found at
http://ostermiller.org/syntax/page.bte
-->
Syntax Highlighting created using the
<a href="http://ostermiller.org/syntax/">com.Ostermiller.Syntax</a> package.<br>
<%bte.inc name="date"%>
</div>
</body>
</html>
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: simple.bte ---
<%bte.doc output=false%>
<%bte.tpl name=page%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%bte.grp onNoResolve=ok %><title><%bte.inc name="title"%></title><%/bte.grp%>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<%bte.grp onNoResolve=ok %><link rel="stylesheet" media="screen" title="Syntax Highlighting" href="<%bte.inc name="styleSheet"%>" type="text/css"><%/bte.grp%>
</head>
<body>
<%bte.inc name="highlightedDocument"%>
</body>
</html>
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: features.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>Features<%/bte.tpl%>
<%bte.tpl name=keywords%>features,formats,languages,source code<%/bte.tpl%>
<%bte.tpl name=description%>List of the features supported by the com.Ostermiller.syntax package..<%/bte.tpl%>
<%bte.tpl name=barfeatures%><span class=currentpage>Supported Formats</span><%/bte.tpl%>
<%bte.tpl name=pageContent%>
<p>The com.Ostermiller.syntax package supports several programming languages.</p>
<ul>
<li>Supports <a href="features.html#java">Java</a>, <a href="features.html#c">C/C++</a>, <a href="features.html#html">HTML</a>, <a href="features.html#latex">LaTeX</a>, <a href="features.html#sql">SQL</a>, and <a href="features.html#properties">Java properties</a>. (More can be added with relative ease)</li>
<li>True lexer support - language syntax specified using <a href="http://jflex.de/">JFlex</a>.</li>
<li>Language specification compliant:
<ul>
<li>C/C++ (<a name=c href="TestCases.c.html">Test Case</a>)
<ul>
<li>Keywords</li>
<li>Precompiler statements (even those with comments)</li>
<li>Comments</li>
<li>Literals
<ul>
<li>Integers, Floats, and Doubles</li>
<li>Characters and Strings (with escape sequences)</li>
</ul>
</li>
<li>Identifiers</li>
<li>Operands</li>
<li>Trigraph escape sequence support</li>
<li>Error reporting</li>
</ul>
</li>
<li>Java (<a name=java href="TestCases.java.html">Test Case</a>)
<ul>
<li>Keywords</li>
<li>Comments (including documentation comments)</li>
<li>Literals
<ul>
<li>Integers, Floats and Doubles (with bounds checking)</li>
<li>Characters and Strings (with escape sequences including unicode)</li>
<li>true, false, and null</li>
</ul>
</li>
<li>Identifiers</li>
<li>Operands</li>
<li>Error reporting</li>
</ul>
</li>
<li>HTML (<a href="TestCases.html.simple.html">Simple Test Case</a>)
<ul>
<li>Text</li>
<li>Character entity references</li>
<li>Comments</li>
<li>Scripts</li>
<li>Tags</li>
<li>Error reporting</li>
</ul>
</li>
<li>HTML (<a name=html href="TestCases.html.complex.html">Complex Test Case</a>)
<ul>
<li>Text</li>
<li>Character entity references</li>
<li>Comments</li>
<li>Scripts</li>
<li>Tag parts</li>
<li>Name/value pairs</li>
<li>Error reporting</li>
</ul>
</li>
<li>Java Properties (<a name=properties href="TestCases.properties.html">Test Case</a>)
<ul>
<li>Name/value pairs</li>
<li>Values split across multiple lines.</li>
<li>Comments</li>
</ul>
</li>
<li>LaTeX (<a name=latex href="TestCases.latex.html">Test Case</a>)
<ul>
<li>Commands</li>
<li>Text</li>
<li>Operators</li>
<li>Comments</li>
<li>Escape Sequences</li>
</ul>
</li>
<li>SQL (<a name=sql href="TestCases.sql.html">Test Case</a>)
<ul>
<li>About 500 keywords.</li>
<li>Comments including nested comments.</li>
<li>literals including strings and numbers</li>
</ul>
</li>
</ul>
</li>
</ul>
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: ant.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>Ant<%/bte.tpl%>
<%bte.tpl name=keywords%>ant,task,anttask<%/bte.tpl%>
<%bte.tpl name=description%>Ant task to create colored html from source files.<%/bte.tpl%>
<%bte.tpl name=pageContent%>
<h2><a name="syntax">Syntax</a></h2>
<h3>Description</h3>
<p>The com.Ostermiller.Syntax package comes with an
<a href="http://ant.apache.org/">Ant</a> task to automate
the creation of colored html documents during your Java software
build process. To use the ant task, simply place syntax.jar in Ant's lib
directory.</p>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">srcdir</td>
<td valign="top">Location of the files to color. Defaults to the project's basedir.</td>
<td align="center">No</td>
</tr>
<tr>
<td valign="top">destdir</td>
<td valign="top">Location to store the colored files. Defaults to
the srcdir.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">css</td>
<td valign="top">URL of the cascading style sheet to which generated
files should be linked. If this option is not specified, the pages
are linked to a default "syntax.css". If this file is not present, the pages
will not appear to have any color.
<a href="http://ostermiller.org/syntax/syntax.css">Example
style sheet</a></td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">includes</td>
<td valign="top">Comma separated list of file globs to accept. If not
specified, all files in all subdirectories are colored.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">excludes</td>
<td valign="top">Comma separated list of file globs to reject that would
otherwise be accepted. If not
specified, no files are excluded.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">mime</td>
<td valign="top">Mime-type of the files to color. If not specified,
the mime-type is guessed from the file extension.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">lexer</td>
<td valign="top">Class name to use for the syntax highlighting lexer.
If none is specified, it is guessed from the mime-type and file
extension.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">title</td>
<td valign="top">Title to use for the colored html page. If none
is specified, "HTML of <i>filename</i>" is used.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">template</td>
<td valign="top">URL of the BTE template file to use. The URL may
be relative to the projects basedir. If none is
specified, the colored html pages have a simple default look and
feel. For this option to work, the
<a href="http://ostermiller.org/bte/">BTE libraries</a>
must be installed. For a template example, see
<a href="http://ostermiller.org/syntax/page.bte">the template for
the default look and feel. </td>
<td align="center" valign="top">No</td>
</tr>
</table>
<h3>Parameters specified as nested elements</h3>
<h4>parameter type="ignore"</h4>
<p>CSS class name of token to ignore. This is desirable to reduce the size
of the generated html files. It is almost always good idea to ignore
whitespace.</p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">name</td>
<td valign="top">The name of the style to ignore.</td>
<td align="center" valign="top">Yes</td>
</tr>
</table>
<h4>parameter type="translate"</h4>
<p>CSS class name to translate to a new name. Names can be translated
for compatibility purposes. They can also be translated to make files smaller.
For example, it is possible to have a "k" instead of "keyword".</p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">name</td>
<td valign="top">The original name of the style to translate.</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top">value</td>
<td valign="top">The new name of the style.</td>
<td align="center" valign="top">Yes</td>
</tr>
</table>
<h3>Examples</h3>
Create syntax highlighting for java source files:
<blockquote>
<pre><taskdef name="syntax" classname="com.Ostermiller.Syntax.ToHTMLAntTask" />
<target name="highlight">
<syntax includes="*.java" />
</target></pre>
</blockquote>
Create syntax highlighting for all files except the generated highlighted files:
<blockquote>
<pre><taskdef name="syntax" classname="com.Ostermiller.Syntax.ToHTMLAntTask" />
<target name="highlight">
<syntax excludes="*.*.html" />
</target></pre>
</blockquote>
More complete example of highlighting java source files, with some recommended options:
<blockquote>
<pre><taskdef name="syntax" classname="com.Ostermiller.Syntax.ToHTMLAntTask" />
<target name="highlight">
<mkdir dir="colored" />
<syntax destdir="colored" includes="*.java" css="mysyntax.css">
<parameter type="ignore" name="whitespace" />
</syntax>
<copy file="mysyntax.css" todir="colored" />
</target></pre>
</blockquote>
<%/bte.tpl%>
<%/bte.doc%>
--- NEW FILE: release.sh ---
#!/bin/bash
size=`ls -lah syntax.jar | grep -oE '[0-9]+[A-Za-z]'`
if [ -z "`grep -i $size download.html`" ]
then
echo "syntax.jar size is $size but download.html does not show that."
exit 1
fi
FILES=$@
FILES=${FILES/package.html/}
FILES=${FILES/web/}
FILES=${FILES/javadoc/}
FILES=${FILES/compile/}
if [ "$FILES" ]
then
echo Make: Uploading to web site: $FILES
cp -r $FILES ~/ostermiller.org/www/syntax
fi
--- NEW FILE: spell.sh ---
#!/bin/bash
files=$@
for file in $files
do
ext="${file/*./}"
if [ "$ext" == "bte" ] || [ "$ext" == "html" ]
then
mode="sgml"
else
mode="url"
fi
if [ "$ext" != "java" ] || [ ! -e "${file/java/lex}" ]
then
cp "$file" temp
aspell check --mode=$mode -x -p ./syntax.dict temp
if [ "`diff "temp" "$file"`" ]
then
mv temp "$file"
fi
fi
done
head -1 "syntax.dict" > temp
tail +2 "syntax.dict" | sort | uniq >> temp
if [ "`diff "temp" "syntax.dict"`" ]
then
mv temp "syntax.dict"
fi
rm -f temp temp.bak
--- NEW FILE: license.bte ---
<%bte.doc super="syntax.bte"%>
<%bte.tpl name=pageTitle%>License<%/bte.tpl%>
<%bte.tpl name=keywords%>license,usage,use,commercial,open source<%/bte.tpl%>
<%bte.tpl name=description%>The com.Ostermiller.Syntax package is licensed under the GNU GPL.<%/bte.tpl%>
<%bte.tpl name=barlicense%><span class=currentpage>License</span><%/bte.tpl%>
<%bte.tpl name=pageContent%>
<p>Copyright (c) 1999-2005 by <a href="http://ostermiller.org/contact.pl?regarding=Syntax+Highlighting">Stephen Ostermiller</a></p>
<p>This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License or (at
your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
<a href="http://www.gnu.org/copyleft/gpl.html">GNU
General Public License</a> for more details.</p>
<%/bte.tpl%>
<%/bte.doc%>
|