/usr/include/srchiliteqt/Qt3SyntaxHighlighter.h is in libsource-highlight-qt4-dev 0.2.2-0ubuntu7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | /*
* Copyright (C) 2008-2010 Lorenzo Bettini, http://www.lorenzobettini.it
* License: See COPYING file that comes with this distribution
*/
#ifndef QT3SYNTAXHIGHLIGHTER_H_
#define QT3SYNTAXHIGHLIGHTER_H_
#include <qsyntaxhighlighter.h>
#include <qtextedit.h>
#include <qfont.h>
#include <qcolor.h>
#include "GNUSyntaxHighlighter.h"
#include "ParagraphMap.h"
namespace srchiliteqt {
/**
* An implementation of QSyntaxHighlighter using GNU Source-highlight library
* (by relying on GNUSyntaxHighlighter provided by the common part of this library).
*
* You can use such highlighter with a QTextEdit, and initialize the highlighter
* with the language definition file, e.g.,
* @code
QTextEdit *editor = new QTextEdit;
srchiliteqt::Qt3SyntaxHighlighter *highlighter =
new srchiliteqt::Qt3SyntaxHighlighter(editor->document());
highlighter->init("java.lang");
* @endcode
*/
class Qt3SyntaxHighlighter: public QSyntaxHighlighter,
public GNUSyntaxHighlighter {
protected:
/// used internally to associate HighlightStateData to paragraphs
ParagraphMap paragraphMap;
int highlightParagraph(const QString & text, int endStateOfLastPara);
public:
Qt3SyntaxHighlighter(QTextEdit *parent = 0);
virtual ~Qt3SyntaxHighlighter();
/**
* Initializes this highlighter with the specified language definition file
* @param langFile
*/
void init(const std::string &langFile);
/**
* This function is applied to the syntax highlighter's current text block
* (i.e. the text that is passed to the highlightParagraph() method).
*
* The specified font and color are applied to the text from the start position
* for a length of count characters
* (if count is 0, nothing is done).
* The formatting properties set in format are merged at display
* time with the formatting information stored directly in the document,
* for example as previously set with QTextCursor's functions.
*
* Note that this helper function will be called by the corresponding
* TextFormatter, from Source-highglight library code, and relies on
* the corresponding protected method of QSyntaxHighlighter: setFormat).
*/
void formatString(int start, int count, const QFont &font,
const QColor &color) {
setFormat(start, count, font, color);
}
void formatString(int start, int count, const QFont &font) {
setFormat(start, count, font);
}
};
}
#endif /* QT3SYNTAXHIGHLIGHTER_H_ */
|