Showing posts with label source-highlight. Show all posts
Showing posts with label source-highlight. Show all posts

Thursday, March 11, 2010

Source-Highlight-Ide 1.0

I've just released a new version of Source-Highlight-IDE, an IDE for GNU Source-highlight (given a source file, produces a document with syntax highlighting).

Sourcehighlightide home page is http://srchighliteide.sourceforge.net.

This new version is a complete rewriting using Qt4 (instead of KDE3) and it is based on Source-Highlight-Qt (which I've already blogged about) additional library, http://srchiliteqt.sourceforge.net, which provides highlighting in Qt relying on GNU Source-Highlight.

Sourcehighlightide is useful when you have to develop a new language definition file for source-highlight. A language definition file makes use of regular expressions, and if they become complex it might be hard to understand how they are matched. Source-highlight already provides some mechanisms for debugging a language definition file; Sourcehighlightide provides a graphical interface to debug a language definition file: it will show which regular expression is matched during the formatting of the input file, and you can process the input file step by step (i.e., an expression at time), and you can also see the output while it is produced.

As you can see from the following screenshot, Sourcehighlightide is a MDI (Multi Document Interface) application, so you can have many files open at one time. Moreover, it provides the basic commands that are common to every GUI application, so we will assume their knowledge throughout this manual.

The online manual is available here.

The main window

Debugging a language definition file

Wednesday, December 23, 2009

GNU Source-Highlight 3.1.2

In this new version of GNU Source-Highlight some new features were added:

  • infer language for files starting with <? and <!doctype
  • qmake based build system available is available to be used as an alternative to the configure based one; this is useful to compile source-highlight with MSVC for instance
  • searches for home directory correctly also on Windows systems
Besides this, many new language definitions were added:

asm




;
; screen handling primitives
;

.model large

.data

vseg dw 0b000h
vmode db ?
x dw 0
y dw 0
color db 07h
ofs dw 0
xhite db 8

; video information block



applescript




(*
TODO just a comment

foo bar
*)

displayName(choose file with prompt "Select a file:") --if double-clicked
return -- not needed, but shows that the script stops here when "run"

on open of finderObjects -- "open" handler triggered by drag'n'drop launches
repeat with i in (finderObjects) -- in case multiple objects dropped on applet
displayName(i) -- show file/folder's info
if folder of (info for i) is true then -- process folder's contents too
tell application "Finder" to set temp to (entire contents of i)
repeat with j in (temp)
display dialog j as string -- example of doing something with each item
end repeat
end if
end repeat
end open

if CurState is 0 then
connect configuration "pccard-serial"
end if

on GetParentPath(myPath)
set oldDelimiters to AppleScript's text item delimiters -- always preserve original delimiters
set AppleScript's text item delimiters to {":"}
set pathItems to text items of (myPath as text)
if last item of pathItems is "" then set pathItems to items 1 thru -2 of pathItems -- its a folder
set parentPath to ((reverse of the rest of reverse of pathItems) as string) & ":"
(* The above line works better than the more obvious set parentPath to ((items 1 thru -2 of pathItems) as string) & ":"
because it will not return an error when passed a path for a volume, i.e., "Macintosh HD:", but rather will return ":"
indicating the desktop is the root of the given path. Andy Bachorski <andyb@APPLE.COM> *)
set AppleScript's text item delimiters to oldDelimiters -- always restore original delimiters
return parentPath
end GetParentPath



awk




$6 !~ /^ack/ && $5 !~ /[SFR]/   {
# given a tcpdump ftp trace, output one line for each send
# in the form
# <send time> <seq no>
# where <send time> is the time packet was sent (in seconds with
# zero at time of first packet) and <seq no> is the tcp sequence
# number of the packet divided by 1024 (i.e., Kbytes sent).
#
# convert time to seconds
n = split ($1,t,":")
tim = t[1]*3600 + t[2]*60 + t[3]
if (! tzero) {
tzero = tim
OFS = "\t"
}
# get packet sequence number
i = index($6,":")
printf "%7.2f\t%g\n", tim-tzero, substr($6,1,i-1)/1024
}

BEGIN{
buffer = "";
}

/\015*$/ {
gsub(/\015*$/, "");
}

/^%%S NL/ {
print "";
next;
}



bat




@ECHO OFF
REM - LABEL INDICATING THE BEGINNING OF THE DOCUMENT.
:BEGIN
CLS
REM - THE BELOW LINE GIVES THE USER 3 CHOICES (DEFINED AFTER /C:)
CHOICE /N /C:123 PICK A NUMBER (1, 2, or 3)%1
REM - THE NEXT THREE LINES ARE DIRECTING USER DEPENDING UPON INPUT
IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE
GOTO END
:THREE
ECHO YOU HAVE PRESSED THREE
GOTO END
:TWO
ECHO YOU HAVE PRESSED TWO
GOTO END
:ONE
ECHO YOU HAVE PRESSED ONE
:END

:: Renames a Text File with the Current Date as the Name
:: The File Extension is Kept
::
C:\BATCH\DOS\XSET CUR-DATE DATE YY-MM-DD
REN %1.* %CUR-DATE%.*

IF "%1" == "" XCOPY B:\*.*
IF NOT "%1" == "" XCOPY B:\%1
ECHO.
C:\BATCH\DR

FOR %%F IN (%1 %2 %3 %4 %5 %6 %7 %8 %9) DO DEL %%F



clipper




Function MAIN()
LOCAL number
INPUT "Key in a number: " TO number
IF number % 2 = 0
? "You keyed in an even number"
? "I can prove it:"
? "the result of ",number," % 2 = 0 is ", number % 2 = 0
ELSE
? "You keyed in an odd number"
? "I can prove it:"
? "the result of ",number," % 2 = 0 is ", number % 2 = 0
ENDIF
RETURN

/* Load the table.dbf and table.cdx, on unix,
you should ensure that file extensions are on
lowercase.*/
USE table INDEX table VIA "DBFCDX"
REINDEX



cobol




      $ SET SOURCEFORMAT "FREE"
IDENTIFICATION DIVISION.
PROGRAM-ID. ShortestProgram.

PROCEDURE DIVISION.
DisplayPrompt.
DISPLAY "I did it".
STOP RUN.
* Uses the ACCEPT and DISPLAY verbs to accept a student record
* from the user and display some of the fields. Also shows how
* the ACCEPT may be used to get the system date and time.
WORKING-STORAGE SECTION.
01 Num1 PIC 9 VALUE ZEROS.
01 Num2 PIC 9 VALUE ZEROS.
01 Result PIC 99 VALUE ZEROS.

PROCEDURE DIVISION.
DISPLAY "Enter first number (1 digit) : " WITH NO ADVANCING.
ACCEPT Num1.
DISPLAY "Enter second number (1 digit) : " WITH NO ADVANCING.
ACCEPT Num2.
MULTIPLY Num1 BY Num2 GIVING Result.
DISPLAY "Result is = ", Result.
STOP RUN.



D




#!/usr/bin/dmd -run
/* sh style script syntax is supported */

/* Hello World in D
To compile:
dmd hello.d
or to optimize:
dmd -O -inline -release hello.d
*/

/+
a nested /+
comment
+/
+/

a = /+ // +/ 1; // parses as if 'a = 1;'
a = /+ "+/" +/ 1"; // parses as if 'a = " +/ 1";'
a = /+ /* +/ */ 3; // parses as if 'a = */ 3;'

r"hello"
r"c:\root\foo.exe"
r"ab\n" // string is 4 characters, 'a', 'b', '\', 'n'

`hello`
`c:\root\foo.exe`
`ab\n` // string is 4 characters, 'a', 'b', '\', 'n'

x"0A" // same as "\x0A"
x"00 FBCD 32FD 0A" // same as "\x00\xFB\xCD\x32\xFD\x0A"

"hello"c // char[]
"hello"w // wchar[]
"hello"d // dchar[]

import std.stdio;

void main(string[] args)
{
writefln("Hello World, Reloaded");

// auto type inference and built-in foreach
foreach (argc, argv; args)
{
// Object Oriented Programming
auto cl = new CmdLin(argc, argv);
// Improved typesafe printf
writeln(cl.argnum, cl.suffix, " arg: ", cl.argv);
// Automatic or explicit memory management
delete cl;
}

// Nested structs and classes
struct specs
{
// all members automatically initialized
int count, allocated;
}

// Nested functions can refer to outer
// variables like args
specs argspecs()
{
specs* s = new specs;
// no need for '->'
s.count = args.length; // get length of array with .length
s.allocated = typeof(args).sizeof; // built-in native type properties
foreach (argv; args)
s.allocated += argv.length * typeof(argv[0]).sizeof;
return *s;
}

// built-in string and common string operations
writefln("argc = %d, " ~ "allocated = %d",
argspecs().count, argspecs().allocated);
}

class CmdLin
{
private int _argc;
private string _argv;

public:
this(int argc, string argv) // constructor
{
_argc = argc;
_argv = argv;
}

int argnum()
{
return _argc + 1;
}

string argv()
{
return _argv;
}

string suffix()
{
string suffix = "th";
switch (_argc)
{
case 0:
suffix = "st";
break;
case 1:
suffix = "nd";
break;
case 2:
suffix = "rd";
break;
default:
break;
}
return suffix;
}
}



erlang




-module(sudoku).
-author(vmiklos@frugalware.org).
-vsn('2009-11-10').
-compile(export_all).

% Return the value of Fun or an empty list based on the value of If.
% @spec fun_or_empty(If::bool(), Fun::fun() -> [any()]) -> Ret::[any()]
% Ret = Fun() if If is true, [] otherwise.
fun_or_empty(If, Fun) ->
case If of
true -> Fun();
_ -> []
end.

% Return a cell from a field.
% @spec field(I::integer(), J::integer(), Table::[any()], M::integer()) ->
% Ret::any()
% Table is a flatten list of lists, M is the length of a row,
% representing a matrix, Ret is the cell in the Ith row and Jth column.
field(I, J, Table, M) ->
P = (I-1)*M+J,
case P > length(Table) of
true -> 0;
_ -> lists:nth((I-1)*M+J, Table)
end.

% Return a cell from a field.
% @spec field(I::integer(), J::integer(), Table::[[any()]]) ->
% Ret::any()
% Ret is the cell in the Ith row and Jth column of Table.
field(I, J, Table) ->
lists:nth(J, lists:nth(I, Table)).



compiler output




no need to highlight this
c:\f\g\Makefile:1346:10: warning: overriding commands for target `styleformatter.h.texinfo' foo
/f/g/Makefile:1346:10: warning: overriding commands for target `styleformatter.h.texinfo' foo
/foo/bar/Makefile:1337: error: ignoring old commands for target 'styleformatter.h.texinfo' bar
\foo\bar\Makefile:1346: warning: overriding commands for target `styleformatter.h.texinfo'
Makefile:1337: warning: ignoring old commands for target `styleformatter.h.texinfo'



manifest files




Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mindmap.diagram; singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.mindmap.diagram.part.MindmapDiagramEditorPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.mindmap.diagram.edit.parts,
org.eclipse.mindmap.diagram.part,
org.eclipse.mindmap.diagram.providers
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.core.expressions,
org.eclipse.draw2d;visibility:=reexport,
org.eclipse.gmf.runtime.draw2d.ui;visibility:=reexport,
org.eclipse.mindmap;visibility:=reexport,
org.eclipse.mindmap.edit;visibility:=reexport,
org.eclipse.gef;visibility:=reexport,
org.eclipse.ocl.ecore;visibility:=reexport,
org.eclipse.emf.validation;visibility:=reexport,
org.eclipse.emf.validation.ocl;visibility:=reexport
Eclipse-LazyStart: true



vbscript




' The script can be called via

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

if AQresponse <> "" then
response.write(AQresponse)
else
response.write("ERROR")
end if

%>

' Actual script follows. This could be placed in a separate file,
' such as the smslib.asp file described above

<%
Dim method, secured, error_on_length, username, password, AQresponse
' User Editable Variables
secured = 0 ' Set to either 1 for SSL connection
' or 0 for normal connection.
error_on_length = 1 ' Whether to give and error on messages over 160 chracters.
' 1 for true, 0 for false.
username = "testusername" ' Your aql username, can either be set here
' or done on a per call basis from the function.
password = "testpassword" ' Your aql password, can either be set here
' or done on a per call basis from the function.

Dim objXMLHTTP, xml
message = replace(message," ","+")
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
if secured = null or secured = 0 then
xml.Open "POST", "http://gw1.aql.com/sms/sms_gw.php", False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send "username=" & username & "&password=" & password & "&destination=" & destination &
"&message=" & message & "&originator=" & originator & "&flash=" & flash
else if secured = 1 then
xml.Open "POST", "https://gw1.aql.com/sms/sms_gw.php", False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send "username=" & username & "&password=" & password & "&destination=" & destination &
"&message=" & message & "&originator=" & originator & "&flash=" & flash
else
call senderror(7)
end if
end if

AQresponse = xml.responseText
Set xml = nothing

End Function


%>




That's all for now :)

Sunday, October 04, 2009

QSource-Highlight - a Qt interface for GNU Source-Highlight

I recently released a new software developed with Qt 4 (this summer I took a chance to use qt and really enjoyed this wonderful framework): QSource-Highlight - a Qt interface for GNU Source-Highlight.

You can highlight your code on the fly, and have the highlighted output in all the formats supported by source-highlight (e.g., HTML, LaTeX, Texinfo, etc.). You can then copy the formatted output and paste it (e.g., in your blog), or save it to a file.

A preview of the highlighted output is available for some output formats (e.g., HTML, XHTML, etc.).


Here are some screenshots:

The preview of highlighting of some selected lines, with line numbers and 4 context lines.

The preview with line numbers (using '-' as padding char).

Latex (with color) output (source, no preview), with "entire doc" option.

The language definition file is automatically selected according to the input file extension, but you can change it manually by using the corresponding combo box. In particular you have three combo boxes:

  • the combo box for the input language definition (e.g., C, C++, Java, etc.); in particular, the combo box refers to the .lang files of Source-Highlight, which, however, should have quite intuitive names.
  • the combo box for the output format (e.g., HTML, LaTeX, etc.); in particular, the combo box refers to the .outlang files of Source-Highlight, which, however, should have quite intuitive names (e.g., htmltable.outlang generates HTML output into an html table).
  • the combo box for the highlighting style (e.g., colors, and formats of the elements of the language); these elements refer to Source-Highlight .style files and to .css files.

All the files named in these combo boxes refer to files shipped with Source-highlight, and they are searched for in the Source-highlight corresponding installation path. In case the combo boxes are empty, then the path where source-highlight searches for these files is wrong: you should then configure the correct path for source-highlight using the settings dialog (Source-Highlight Settings).


The complete documentation is available here.


QSource-Highlight uses the library included in GNU Source-Highlight, since version 3, thus you need that library to build QSource-Highlight; in particular it uses Source-Highlight-Qt (which I've already blogged about) additional library, http://srchiliteqt.sourceforge.net, which provides highlighting in Qt relying on GNU Source-Highlight. Thus, you need to install Source-Highlight-Qt as well. we refer to GNU Source-Highlight's and Source-Highlight-Qt's websites for further information about the library and its installation (you may want to check whether your distribution already provides packages for these two libraries).

Monday, September 28, 2009

Source-Highlight-Qt 0.2

The release 0.2 of Source-Highlight-Qt is out! Source-Highlight-Qt is a library for performing syntax highlighting in Qt documents by relying on GNU Source-Highlight library.

The main new features are (besides some bugfixes):

  • You can customize colors in the color dialog also for elements not defined in the current style
  • A new dialog for source-highlight settings is now provided (see the screenshot)
  • A combo box is provided also for selecting the output format of highlighting
  • Some functionalities are provided for generating a .style file (e.g., starting from the settings of the color and style dialog)
  • Some message boxes can be used to display source-highlight exceptions

Basically, all the new additions were functional for the new software I released (I'll blog about that in the next few days): QSource-Highlight, i.e., a Qt4 graphical interface for source-highlight itself :-)

Tuesday, September 22, 2009

GNU Source-Highlight 3.1.1

In this new version of GNU Source-Highlight some additions were made to the API of the library; the most important are:

  • access to static global LangDefManager, LangMaps is provided through the new class Instances so that there's no need to create continuously instances of these classes;
  • the library also provides now utility functions for accessing .lang and .outlang files;
  • functions are provided for setting the data dir option globally, in order to increase consistency in applications that use the library (changing such value globally makes sure that the change will be visible in all parts of the library).
Moreover, two new language definition files were added: Texinfo and Haskell (thanks to Sergey Astanin); here are two examples:

texinfo

(@ref{Generating References}).
\input texinfo @c -*-texinfo-*-
@c This file uses the @command command introduced in Texinfo 4.0.
@c %**start of header
@setfilename source-highlight.info
@include version.texi
@settitle GNU Source-highlight @value{VERSION}
@finalout
@c @setchapternewpage odd
@c %**end of header

@example
my example
@end example

@set myhomepage @uref{http://www.lorenzobettini.it}

field names, etc.) by relying on the program @emph{ctags},
@url{http://ctags.sourceforge.net}
@xref{My Long
Reference}.

@inforef{Introduction,,source-highlight-info}.

@c All the menus can be updated with the EMACS command
@c texinfo-all-menus-update, which is normally bound to C-c C-u C-a.
@menu
* Introduction:: What's it for?
* Installation:: Download and installation
* Invoking source-highlight:: How to run @command{source-highlight}.
* Language Definitions:: How to define an input language
* Problems:: Reporting bugs.
* Mailing Lists::
* Concept Index:: Index of concepts.
@end menu

This is an escaped @@ at symbol.

This ``is a string''.

@example
@i{/// read the files }FIXME@i{ of a directory }@@param@i{ }@b{<f} foo="bar"@b{>}

@b{#include} <stddef.h>
@b{#include} <stdio.h>
@b{#include} <sys/types.h>
@b{#include} <dirent.h>

int
@b{main} (void)
@{
DIR *dp;
@b{struct} dirent *ep;

dp = @b{opendir} ("./");
@b{if} (dp != NULL)
@{
@b{while} (ep = @b{readdir} (dp))
@b{puts} (ep->d_name);
(void) @b{closedir} (dp);
@}
@b{else}
@b{perror} ("Couldn't open the directory");

@b{return} 0;
@}

@end example



haskell

-- A test snippet based on
-- http://google-code-prettify.googlecode.com/svn/trunk/tests/prettify_test.html
--
-- A comment
These --> are --| not |-- comments
--but this is a comment again

module Foo(bar) where
import Blah
import BlahBlah(blah)
import Monads(Exception(..), FIO(..),unFIO,handle,runFIO,fixFIO,fio,
write,writeln,HasNext(..),HasOutput(..))

{- nested comments
- should {- just -} work -}
instance Thingy Foo where
a = b

data Foo :: (* -> * -> *) -> * > * -> * where
Nil :: Foo a b c
Cons :: a b c -> Foo abc -> Foo a b c

str = "Foo\\Bar"
chars = [ 'x', '\'', '\\', '\"', '\120', '\o100', '\xbeef' ] -- Escapes too
Not.A.Char = 'too long' -- Don't barf. Show that 't is a lexical error.

(ident, ident', Fo''o.b'ar)

(0, 12, 0x45, 0xA7, 0o177, 0O377, 0.1, 1.0, 1e3, 0.5E-3, 1.0E+45)

[1,2..10]

(#) = \x y -> s x y
where s x y = (x+y) `mod` 13

bar (x:_) = putStrLn x

main = do
let foo x = do { spam $ eggs x }
foo >>= bar

Thursday, July 16, 2009

Source-highlight-qt: A library for highlighting Qt documents using GNU Source-highlight

A few days ago I released a new software that uses the new library provided by GNU Source-highlight: Source-highlight-qt, "a library for performing syntax highlighting in Qt documents by relying on GNU Source-Highlight library".

This library provides an implementation of the qt abstract class QSyntaxHighlighter class, and it deals both with Qt3 and Qt4 (you will need to build a separate version of the library for the two different qt frameworks). Please note, the Qt3 version has less features and it is there only for old qt applications; furthermore, QSyntaxHighlighter class in Qt3 has some design problems which make it quite inefficient to use.

The library can be downloaded from the sourceforge site using this link: http://sourceforge.net/projects/srchiliteqt/files.

For standard usage, it's just a matter of executing this code (you can pass the language syntax, i.e., the source-highlight language definition file, to the init method):

QTextEdit *editor = new QTextEdit;
srchiliteqt::Qt4SyntaxHighlighter *highlighter =
new srchiliteqt::Qt4SyntaxHighlighter(editor->document());
highlighter->init("java.lang");
We also suggest to take a look at the example program qeditexample, for some use cases of the library. Please notice that this qeditexample program is not intended to be used as an editor for production, it's just to show how to use source-highlight-qt library (and it uses the qt4 version).

This is a screenshot of the program qeditexample, editing a C file; basically most of the code is taken directly from the library. For instance, it provides the combo boxes for selecting the highlighting language and the output style (and they be connected to the editor, so that all the changes are automatically applied):


This is another screenshot, where we're editing a C++ file, with a different style


The library also provides a dialog to customize the output style:


Happy Qt Highlighting! :-)

Thursday, June 11, 2009

Php-source-highlight

Just after one week I released version 3.0 of source-highlight with the C++ library, I got an email from Pascal Bleser, telling me that he created a php extension using the library, for highlighting code from php without relying on CGI scripts! You can find its plugin extension here: http://code.google.com/p/php-source-highlight. I took a quick look at his code and it's really simple and clean, hopefully this also means that the library of source-highlight can be smooth to use :-).

You can also might want to take a look at his blog post!

Thursday, May 14, 2009

GNU Source-higlight 3.0: now with a Library

I finally made it to release the new major version of GNU Source-highlight 3.0, where the main novelty is that it now includes a C++ library that can be used in other programs to highlight text (not necessarily to generated highlighted text as source-highlight itself does, but for instance, to highlight text in a text editor). This was the first time I implemented a C++ library, so I hope I got it right, mostly at least ;-)

Source-highlight now includes also the program source-highlight-settings, which can be used to check whether source-highlight will be able find its language definition files, and other configuration files, and in case, to store the correct settings in a configuration file, in the user home directory. In particular, the stored configuration file will be called source-highlight.conf and stored in $HOME/.source-highlight/. For the moment, this file only stores the default value for the --data-dir option.

Another new feature is the command line option --regex-range, which, similarly to the option --line-range, allows to specify only a part of the input source to be highlighted (of course, as for --line-range option, environments or states, such as, e.g., comments and strings, are handled correctly even though they cross the range). Ranges can be expressed using regular expressions, with the command line option --regex-range. In this case the beginning of the range will be detected by a line containing (in any point) a string matching the specified regular expression; the end will be detected by a line containing a string matching the same regular expression that started the range. This feature is very useful when we want to document some code (e.g., in this very manual) by showing only specific parts, that are delimited in a ad-hoc way in the source code (e.g., with specific comment patterns).

For instance, consider the following listing:

01: /*
02: This is a classical Hello program
03: to test source-highlight with Java programs.
04:
05: to have an html translation type
06:
07: source-highlight -s java -f html --input Hello.java --output Hello.html
08: source-highlight -s java -f html < Hello.java > Hello.html
09:
10: or type source-highlight --help for the list of options
11:
12: written by
13: Lorenzo Bettini
14: http://www.lorenzobettini.it
15: http://www.gnu.org/software/src-highlite
16: */
17:
18: package hello;
19:
20: import java.io.* ;
21:
22: /**
23: * <p>
24: * A simple Hello World class, used to demonstrate some
25: * features of Java source highlighting.
26: * </p>
27: * TODO: nothing, just to show an highlighted TODO or FIXME
28: *
29: * @author Lorenzo Bettini
30: * @version 2.0
31: */ /// class
32: public class Hello {
33: int foo = 1998 ;
34: int hex_foo = 0xCAFEBABE;
35: boolean b = false;
36: Integer i = null ;
37: char c = '\'', d = 'n', e = '\\' ;
38: String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;
39:
40: /* mymethod */
41: public void mymethod(int i) {
42: // just a foo method
43: }
44: /* mymethod */
45:
46: /* main */
47: public static void main( String args[] ) {
48: // just some greetings ;-) /*
49: System.out.println( "Hello from java2html :-)" ) ;
50: System.out.println( "\tby Lorenzo Bettini" ) ;
51: System.out.println( "\thttp://www.lorenzobettini.it" ) ;
52: if (argc > 0)
53: String param = argc[0];
54: //System.out.println( "bye bye... :-D" ) ; // see you soon
55: }
56: /* main */
57: }
58: /// class
59:
60: // end of file test.java

If we invoke source-highlight with the following command line option:
--regex-range="/// [[:alpha:]]+"
we will get this output (thus, only the part in the range delimited by "/// class", which matches the specified regular expression:

32: public class Hello {
33: int foo = 1998 ;
34: int hex_foo = 0xCAFEBABE;
35: boolean b = false;
36: Integer i = null ;
37: char c = '\'', d = 'n', e = '\\' ;
38: String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;
39:
40: /* mymethod */
41: public void mymethod(int i) {
42: // just a foo method
43: }
44: /* mymethod */
45:
46: /* main */
47: public static void main( String args[] ) {
48: // just some greetings ;-) /*
49: System.out.println( "Hello from java2html :-)" ) ;
50: System.out.println( "\tby Lorenzo Bettini" ) ;
51: System.out.println( "\thttp://www.lorenzobettini.it" ) ;
52: if (argc > 0)
53: String param = argc[0];
54: //System.out.println( "bye bye... :-D" ) ; // see you soon
55: }
56: /* main */
57: }

if we invoke it with
--regex-range="/\* main \*/"
we get the part concerning main:

47:     public static void main( String args[] ) {
48: // just some greetings ;-) /*
49: System.out.println( "Hello from java2html :-)" ) ;
50: System.out.println( "\tby Lorenzo Bettini" ) ;
51: System.out.println( "\thttp://www.lorenzobettini.it" ) ;
52: if (argc > 0)
53: String param = argc[0];
54: //System.out.println( "bye bye... :-D" ) ; // see you soon
55: }

Finally, with
--regex-range="/\* [[:alpha:]]+ \*/"
you'll get only the parts concerning methods:

41:     public void mymethod(int i) {
42: // just a foo method
43: }
47: public static void main( String args[] ) {
48: // just some greetings ;-) /*
49: System.out.println( "Hello from java2html :-)" ) ;
50: System.out.println( "\tby Lorenzo Bettini" ) ;
51: System.out.println( "\thttp://www.lorenzobettini.it" ) ;
52: if (argc > 0)
53: String param = argc[0];
54: //System.out.println( "bye bye... :-D" ) ; // see you soon
55: }

This is quite useful for inserting some parts of input files in manuals (e.g., I used it myself to insert some parts of files in the source-highlight manuals).

Another added functionality is that source-highlight also uses the filename (not only its extension) to detect the source language (for instance, if you pass as input ChangeLog, it will use the changelog.lang language definition).

Finally, two more input languages were added: the one for generic configuration files (including, e.g., xorg.conf, qmake.conf, etc.), and the one for pkg-config files; here are some examples

configuration files

# test file for some configuration files, such as
# xorg, qmake.conf and generic conf files (based on properties)

# xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#

Section "Files"
EndSection

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "SHMConfig" "on"
Option "HorizEdgeScroll" "0"
Option "MinSpeed" "0.5" # touchpad speed when moving slowly
Option "MaxSpeed" "2.0" # touchpad speed when moving fast
Option "AccelFactor" "0.10"
Option "CircularScrolling" "on"
Option "EdgeMotionMinSpeed" "0.5"
EndSection

#
# qmake configuration for win32-g++
#
# Written for MinGW
#

MAKEFILE_GENERATOR = MINGW
TEMPLATE = app
CONFIG += qt warn_on release link_prl copy_dir_files debug_and_release debug_and_release_target precompile_header

QMAKE_INCDIR =
QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS]
QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS]

QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src
QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<


# settings for source-highlight

datadir = "/home/bettini/usr/local/share/source-highlight"

# other conf file
[PlaylistColumnsLayout]
ColumnNames=Filename,Title,Artist,AlbumArtist,Composer,Year,Album,DiscNumber,Track,BPM,Genre,Comment,Directory,Type,Length,Bitrate,SampleRate,Score,Rating,PlayCount,LastPlayed,Mood,Filesize
ColumnOrder=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
ColumnWidths=0,184,92,0,0,100,92,0,0,0,0,0,73,0,80,0,0,0,0,0,0,0,0
ColumnsVersion=1
SortAscending=true
SortColumn=200

pkg-config files

prefix=/home/bettini/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: libsource-highlight
Description: GNU Source-highlight library.
URL: http://www.gnu.org/software/src-highlite/
Version: 3.0
Libs: -L${libdir} -lsource-highlight -L/usr/lib -lboost_regex-gcc43-1_35
Cflags: -I${includedir} -I${libdir}/include -I/usr/include



Hope to have another program using source-highlight library ready soon :-)