/usr/include/srchiliteqt/TextEditHighlighted.h is in libsource-highlight-qt4-dev 0.2.2-0ubuntu8.
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /*
* Copyright (C) 2008-2010 Lorenzo Bettini, http://www.lorenzobettini.it
* License: See COPYING file that comes with this distribution
*/
#ifndef TEXTEDITHIGHLIGHTED_H
#define TEXTEDITHIGHLIGHTED_H
#include <QTextEdit>
#include "Qt4SyntaxHighlighter.h"
namespace srchiliteqt {
class LanguageComboBox;
class StyleComboBox;
/**
* A specialized QTextEdit that uses a Qt4SyntaxHighlighter for
* highlighting its contents.
*
* If connected to a LanguageComboBox, it automatically refreshes
* its highlighted contents when the language definition file changes.
* If connected to a StyleComboBox, it automatically refreshes
* its highlighted contents when the style changes.
*/
class TextEditHighlighted : public QTextEdit
{
Q_OBJECT
private:
/// the highlighter object
srchiliteqt::Qt4SyntaxHighlighter *highlighter;
/// the (possible) LanguageComboBox for selecting languages
LanguageComboBox *languageComboBox;
/// the (possible) StyleComboBox for selecting languages
StyleComboBox *styleComboBox;
/// the style file of source-highlight for highlighting (default: "default.style")
QString styleFile;
public:
TextEditHighlighted();
TextEditHighlighted(QWidget * parent);
/**
* Connects a LanguageComboBox so that, if the language is changed
* it automatically rehighlights the contents of the textedit.
* @param lcb the LanguageComboBox
*/
void connectLanguageComboBox(LanguageComboBox *lcb);
/**
* Connects a StyleComboBox so that, if the style is changed
* it automatically rehighlights the contents of the textedit.
* @param lcb the LanguageComboBox
*/
void connectStyleComboBox(StyleComboBox *lcb);
srchiliteqt::Qt4SyntaxHighlighter *getHighlighter() const {
return highlighter;
}
/**
* Sets an highlighter for the specified language definition file
* @param langFile
*/
void setHighlighter(const QString &langFile);
/**
* Opens the file specified by fileName.
* It uses the fileName to detect the source language and automatically
* selects the corresponding syntax highlighting.
*
* @param fileName the name of the file to open (complete path)
* @return a string representing the error. If successful returns the empty string
*/
const QString loadFile(const QString &fileName);
/**
* Changes the foreground and background color.
* @param fgColor the foreground (if empty, the color is not changed)
* @param bgColor the background (if empty, the color is not changed)
*/
void changeColors(const QString &fgColor, const QString &bgColor);
public slots:
/**
* Changes the highlighting according to the new specified language
* @param newLang the new language definition
*/
void changeHighlightingLanguage(const QString &newLang);
/**
* Changes the highlighting style according to the new specified style file
* @param newStyle the new style
*/
void changeHighlightingStyle(const QString &newStyle);
/**
* If the file name changes, then we check whether we need to change
* the language definition for highlighting
* @param fileName the new file name
*/
void changeFileName(const QString &fileName);
/**
* Returns the the lang def file name by using the file name for detecting
* the syntax of the file (e.g., <em>foo.cpp</em> brings to <em>cpp.lang</em>,
* <em>ChangeLog</em> brings to <em>changelog.lang</em>).
* This method already catches possible exceptions thrown from the source-highlight
* library and show them in a message box.
*
* @param filename
* @return the lang def file name or the empty string if no mapping exists
*/
const QString getLangDefFileFromFileName(const QString &filename);
signals:
/**
* This signal is emitted when the highlighting language definition changed
* @param newLang the new language definition
*/
void changedHighlightingLanguage(const QString &newLang);
/**
* This signal is emitted when the highlighting style changed
* @param newLang the new language definition
*/
void changedHighlightingStyle(const QString &newLang);
};
}
#endif // TEXTEDITHIGHLIGHTED_H
|