Mercurial > hg > forks > UniversalIndentGUI
changeset 619:caa817755135
Refactored the class a little bit. Also avoided a crash when using liqscintilla2-dev version 2.1 for example on Ubuntu 8.4. But this is not a good workaround yet.
git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@878 59b1889a-e5ac-428c-b0c7-476e01d41282
author | thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282> |
---|---|
date | Tue, 28 Oct 2008 22:03:10 +0000 |
parents | 0a9defd1b255 |
children | eef4dc07e6f4 |
files | src/UiguiHighlighter.cpp src/UiguiHighlighter.h |
diffstat | 2 files changed, 21 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/UiguiHighlighter.cpp Tue Oct 28 21:05:09 2008 +0000 +++ b/src/UiguiHighlighter.cpp Tue Oct 28 22:03:10 2008 +0000 @@ -37,7 +37,7 @@ UiguiHighlighter::UiguiHighlighter(QsciScintilla *parent) : QObject(parent) { - this->parent = parent; + this->qsciEditorParent = parent; // Create the highlighter settings object from the UiGuiSyntaxHighlightConfig.ini file. this->settings = new QSettings(SettingsPaths::getSettingsPath() + "/UiGuiSyntaxHighlightConfig.ini", QSettings::IniFormat, this); @@ -85,7 +85,7 @@ mapHighlighternameToExtension["YAML"] = QStringList() << "yaml"; #endif - lexer = 0; + lexer = NULL; // This code is only for testing. /* @@ -115,9 +115,9 @@ setLexerForExtension( mapHighlighternameToExtension[highlighterName].first() ); //TODO: This is really no nice way. How do it better? // Need to do this "text update" to update the syntax highlighting. Otherwise highlighting is wrong. - int scrollPos = parent->verticalScrollBar()->value(); - parent->setText( parent->text() ); - parent->verticalScrollBar()->setValue(scrollPos); + int scrollPos = qsciEditorParent->verticalScrollBar()->value(); + qsciEditorParent->setText( qsciEditorParent->text() ); + qsciEditorParent->verticalScrollBar()->setValue(scrollPos); } @@ -126,7 +126,7 @@ */ void UiguiHighlighter::turnHighlightOn() { highlightningIsOn = true; - parent->setLexer(lexer); + qsciEditorParent->setLexer(lexer); readCurrentSettings(""); } @@ -135,15 +135,16 @@ */ void UiguiHighlighter::turnHighlightOff() { highlightningIsOn = false; - parent->setLexer(); - parent->setFont( QFont("Courier", 10, QFont::Normal) ); - parent->setMarginsFont( QFont("Courier", 10, QFont::Normal) ); + qsciEditorParent->setLexer(); + qsciEditorParent->setFont( QFont("Courier", 10, QFont::Normal) ); + qsciEditorParent->setMarginsFont( QFont("Courier", 10, QFont::Normal) ); } /*! \brief Read the settings for the current lexer from the settings file. */ +//TODO: Refactor this function so that the coding style and variable names suit better. bool UiguiHighlighter::readCurrentSettings( const char *prefix ) { bool ok, flag, rc = true; @@ -154,6 +155,12 @@ fontForStyles.clear(); colorForStyles.clear(); +// Somehow I get crashes when using default libqscintilla2-3 and libqscintilla2-dev packages. +// Do not know currently where they come from, but to avoid these return here. +#if ( QSCINTILLA_VERSION < 0x020300 ) + return false; +#endif + // Read the styles. for (int i = 0; i < 128; ++i) { @@ -322,7 +329,7 @@ int indexOfHighlighter = 0; extension = extension.toLower(); - if ( lexer ) { + if ( lexer != NULL ) { writeCurrentSettings(""); delete lexer; } @@ -444,7 +451,7 @@ // Set the lexer for the QScintilla widget. if ( highlightningIsOn ) { - parent->setLexer(lexer); + qsciEditorParent->setLexer(lexer); } // Read the settings for the lexer properties from file.
--- a/src/UiguiHighlighter.h Tue Oct 28 21:05:09 2008 +0000 +++ b/src/UiguiHighlighter.h Tue Oct 28 22:03:10 2008 +0000 @@ -82,11 +82,11 @@ private: bool highlightningIsOn; - QsciScintilla *parent; + QsciScintilla *qsciEditorParent; QMap<int, QFont> fontForStyles; QMap<int, QColor> colorForStyles; - QsciLexer* lexer; - QSettings *settings; + QsciLexer* lexer; + QSettings *settings; QMap<QString, QStringList> mapHighlighternameToExtension; public slots: