skip to main | skip to sidebar
Showing posts with label source-highlight-qt. Show all posts
Showing posts with label source-highlight-qt. Show all posts

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 :-)

Pubblicato da betto a 6:52 PM 0 commenti

Etichette: ,

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! :-)

Pubblicato da betto a 9:32 AM 0 commenti

Etichette: , ,

Subscribe to: Comments (Atom)
 

AltStyle によって変換されたページ (->オリジナル) /