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.
Thursday, March 11, 2010
Source-Highlight-Ide 1.0
Pubblicato da
betto
a
10:39 PM
0
commenti
Etichette: source-highlight, sourcehighlightide
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
asm
; |
applescript
(* |
awk
$6 !~ /^ack/ && $5 !~ /[SFR]/ { |
bat
@ECHO OFF |
clipper
Function MAIN() |
cobol
$ SET SOURCEFORMAT "FREE" |
D
#!/usr/bin/dmd -run |
erlang
-module(sudoku). |
compiler output
no need to highlight this |
manifest files
Manifest-Version: 1.0 |
vbscript
' The script can be called via |
That's all for now :)
Pubblicato da
betto
a
5:02 PM
2
commenti
Etichette: source-highlight
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 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).
Pubblicato da
betto
a
10:14 PM
0
commenti
Etichette: qsource-highlight, source-highlight, source-highlight-qt
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 :-)
Pubblicato da
betto
a
6:52 PM
0
commenti
Etichette: source-highlight, source-highlight-qt
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).
texinfo
(@ref{Generating References}). |
haskell
-- A test snippet based on |
Pubblicato da
betto
a
4:27 PM
0
commenti
Etichette: source-highlight
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;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).
srchiliteqt::Qt4SyntaxHighlighter *highlighter =
new srchiliteqt::Qt4SyntaxHighlighter(editor->document());
highlighter->init("java.lang");
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! :-)
Pubblicato da
betto
a
9:32 AM
0
commenti
Etichette: qt, source-highlight, source-highlight-qt
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!
Pubblicato da
betto
a
8:58 PM
0
commenti
Etichette: php, source-highlight
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\">ä</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\">ä</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 :-)
Pubblicato da
betto
a
9:47 PM
0
commenti
Etichette: source-highlight