changeset 559:fdd8c3619811

Renamed the class Highlighter to UiguiHighlighter. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@799 59b1889a-e5ac-428c-b0c7-476e01d41282
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Thu, 02 Oct 2008 20:33:34 +0000
parents 6211dda17c26
children e246898b556b
files UniversalIndentGUI.pro src/UiguiHighlighter.cpp src/UiguiHighlighter.h src/UniversalIndentGUI.vcproj src/highlighter.cpp src/highlighter.h src/mainwindow.h
diffstat 7 files changed, 541 insertions(+), 541 deletions(-) [+]
line wrap: on
line diff
--- a/UniversalIndentGUI.pro	Thu Oct 02 20:24:55 2008 +0000
+++ b/UniversalIndentGUI.pro	Thu Oct 02 20:33:34 2008 +0000
@@ -158,7 +158,7 @@
 
 # Input
 HEADERS += src/aboutdialog.h \
-           src/highlighter.h \
+           src/UiguiHighlighter.h \
            src/indenthandler.h \
            src/mainwindow.h \
            src/uiguierrormessage.h \
@@ -177,7 +177,7 @@
          src/UpdateCheckDialog.ui
 
 SOURCES += src/aboutdialog.cpp \
-           src/highlighter.cpp \
+           src/UiguiHighlighter.cpp \
            src/indenthandler.cpp \
            src/main.cpp \
            src/mainwindow.cpp \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/UiguiHighlighter.cpp	Thu Oct 02 20:33:34 2008 +0000
@@ -0,0 +1,436 @@
+/***************************************************************************
+ *   Copyright (C) 2006-2008 by Thomas Schweitzer                          *
+ *   thomas-schweitzer(at)arcor.de                                         *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License version 2.0 as   *
+ *   published by the Free Software Foundation.                            *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program in the file LICENSE.GPL; if not, write to the *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include <QtGui>
+
+#include "UiguiHighlighter.h"
+
+#include "SettingsPaths.h"
+
+//! \defgroup grp_EditorComponent All concerning editor widget.
+
+/*!
+    \class UiguiHighlighter
+    \ingroup grp_EditorComponent
+    \brief UiguiHighlighter used for selecting the syntax highlighter/lexer for the QsciScintilla component.
+*/
+
+/*!
+    \brief The constructor initializes some regular expressions and keywords to identify cpp tokens
+ */
+UiguiHighlighter::UiguiHighlighter(QsciScintilla *parent)
+: QObject(parent)
+{
+    this->parent = parent;
+
+    // If a "indenters" subdir in the applications binary path exists, use local config files (portable mode)
+    if ( SettingsPaths::getPortableMode() ) {
+        this->settings = new QSettings(SettingsPaths::getGlobalFilesPath() + "/config/UiGuiSyntaxHighlightConfig.ini", QSettings::IniFormat, this);
+    } 
+    // ... otherwise use the users application data default dir.
+    else {
+        this->settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), "UiGuiSyntaxHighlightConfig", this);
+    }
+
+    highlightningIsOn = true;
+
+    mapHighlighternameToExtension["Bash"] = QStringList() << "sh";
+    mapHighlighternameToExtension["Batch"] = QStringList() << "bat";
+    mapHighlighternameToExtension["CMake"] = QStringList() << "cmake";
+    mapHighlighternameToExtension["C++"] = QStringList() << "c" << "h" << "cpp" << "hpp" << "cxx" << "hxx";
+    mapHighlighternameToExtension["C#"] = QStringList() << "cs";
+    mapHighlighternameToExtension["CSS"] = QStringList() << "css";
+    mapHighlighternameToExtension["D"] = QStringList() << "d";
+    mapHighlighternameToExtension["Diff"] = QStringList() << "diff";
+    mapHighlighternameToExtension["Fortran"] = QStringList() << "f" << "for";
+    mapHighlighternameToExtension["Fortran77"] = QStringList() << "f77";
+    mapHighlighternameToExtension["HTML"] = QStringList() << "html";
+    mapHighlighternameToExtension["IDL"] = QStringList() << "idl";
+    mapHighlighternameToExtension["Java"] = QStringList() << "java";
+    mapHighlighternameToExtension["JavaScript"] = QStringList() << "js";
+    mapHighlighternameToExtension["LUA"] = QStringList() << "lua";
+    mapHighlighternameToExtension["Makefile"] = QStringList() << "makefile";
+    mapHighlighternameToExtension["Pascal"] = QStringList() << "pas";
+    mapHighlighternameToExtension["Perl"] = QStringList() << "perl" << "pl" << "pm";
+    mapHighlighternameToExtension["PHP"] = QStringList() << "php";
+    mapHighlighternameToExtension["PostScript"] = QStringList() << "ps" << "eps" << "pdf" << "ai" << "fh";
+    mapHighlighternameToExtension["POV"] = QStringList() << "pov";
+    mapHighlighternameToExtension["Ini"] = QStringList() << "ini";
+    mapHighlighternameToExtension["Python"] = QStringList() << "py";
+    mapHighlighternameToExtension["Ruby"] = QStringList() << "rub" << "rb";
+    mapHighlighternameToExtension["SQL"] = QStringList() << "sql";
+    mapHighlighternameToExtension["TCL"] = QStringList() << "tcl";
+    mapHighlighternameToExtension["TeX"] = QStringList() << "tex";
+    mapHighlighternameToExtension["VHDL"] = QStringList() << "vhdl";
+    mapHighlighternameToExtension["XML"] = QStringList() << "xml";
+    mapHighlighternameToExtension["YAML"] = QStringList() << "yaml";
+
+    lexer = 0;
+
+    // This code is only for testing.
+    /*
+    foreach(QStringList extensionList, mapHighlighternameToExtension.values() ) {
+        setLexerForExtension( extensionList.at(0) );
+    }
+    */
+
+    // Set default highlighter to C++ highlighter.
+    setLexerForExtension( "cpp" );
+}
+
+
+/*!
+    \brief Returns the available highlighters as QStringList.
+ */
+QStringList UiguiHighlighter::getAvailableHighlighters() {
+    return mapHighlighternameToExtension.keys();
+}
+
+
+/*!
+    \brief This slot handles signals coming from selecting another syntax highlighter.
+ */
+void UiguiHighlighter::setHighlighterByAction(QAction* highlighterAction) {
+	QString highlighterName = highlighterAction->text();
+    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);
+}
+
+
+/*!
+    \brief Turns the syntax parser on.
+*/
+void UiguiHighlighter::turnHighlightOn() {
+    highlightningIsOn = true;
+	parent->setLexer(lexer);
+    readCurrentSettings("");
+}
+
+/*!
+    \brief Turns the syntax parser off.
+*/
+void UiguiHighlighter::turnHighlightOff() {
+    highlightningIsOn = false;
+	parent->setLexer();
+    parent->setFont( QFont("Courier", 10, QFont::Normal) );
+    parent->setMarginsFont( QFont("Courier", 10, QFont::Normal) );
+}
+
+
+/*!
+    \brief Read the settings for the current lexer from the settings file.
+ */
+bool UiguiHighlighter::readCurrentSettings( const char *prefix )
+{
+    bool ok, flag, rc = true;
+    int num;
+    QString key;
+
+    // Reset lists containing fonts and colors for each style
+    fontForStyles.clear();
+    colorForStyles.clear();
+
+    // Read the styles.
+    for (int i = 0; i < 128; ++i)
+    {
+        // Ignore invalid styles.
+        if ( lexer->description(i).isEmpty() )
+            continue;
+
+        key.sprintf( "%s/%s/style%d/", prefix, lexer->language(), i );
+		key.replace("+", "p");
+
+        // Read the foreground color.
+        ok = settings->contains(key + "color");
+        num = settings->value(key + "color", 0).toInt();
+
+        if (ok)
+            setColor( QColor((num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff), i );
+        else
+            rc = false;
+
+        // Read the end-of-line fill.
+        ok = settings->contains(key + "eolfill");
+        flag = settings->value(key + "eolfill", false).toBool();
+
+        if (ok)
+            lexer->setEolFill( flag, i );
+        else
+            rc = false;
+
+        // Read the font
+        QStringList fdesc;
+
+        ok = settings->contains(key + "font");
+        fdesc = settings->value(key + "font").toStringList();
+
+        if (ok && fdesc.count() == 5)
+        {
+            QFont f;
+
+            f.setFamily(fdesc[0]);
+            f.setPointSize(fdesc[1].toInt());
+            f.setBold(fdesc[2].toInt());
+            f.setItalic(fdesc[3].toInt());
+            f.setUnderline(fdesc[4].toInt());
+
+            setFont(f, i);
+        }
+        else
+            rc = false;
+
+        // Read the background color.
+        ok = settings->contains(key + "paper");
+        num = settings->value(key + "paper", 0).toInt();
+
+        if (ok)
+            lexer->setPaper( QColor((num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff), i );
+        else
+            rc = false;
+    }
+
+    // Read the properties.
+    key.sprintf( "%s/%s/properties/", prefix, lexer->language() );
+
+    lexer->refreshProperties();
+
+    return rc;
+}
+
+
+/*!
+    \brief Write the settings for the current lexer to the settings file.
+ */
+void UiguiHighlighter::writeCurrentSettings( const char *prefix )
+{
+    QString key;
+
+    // Write the styles.
+    for (int i = 0; i < 128; ++i) {
+        // Ignore invalid styles.
+        if ( lexer->description(i).isEmpty() )
+            continue;
+
+        int num;
+        QColor c;
+
+        key.sprintf( "%s/%s/style%d/", prefix, lexer->language(), i );
+		key.replace("+", "p");
+
+		// Write style name
+		settings->setValue( key + "", lexer->description(i) );
+
+        // Write the foreground color.
+		if ( colorForStyles.contains(i) ) {
+			c = colorForStyles[i];
+		}
+		else {
+			c = lexer->color(i);
+		}
+        num = (c.red() << 16) | (c.green() << 8) | c.blue();
+
+        settings->setValue(key + "color", num);
+
+        // Write the end-of-line fill.
+        settings->setValue( key + "eolfill", lexer->eolFill(i) );
+
+        // Write the font
+        QStringList fdesc;
+        QString fmt("%1");
+        QFont f;
+
+		if ( fontForStyles.contains(i) ) {
+			f = fontForStyles[i];
+		}
+		else {
+			f = lexer->font(i);
+		}
+
+        fdesc += f.family();
+        fdesc += fmt.arg( f.pointSize() );
+
+        // The casts are for Borland.
+        fdesc += fmt.arg( (int)f.bold() );
+        fdesc += fmt.arg( (int)f.italic() );
+        fdesc += fmt.arg( (int)f.underline() );
+
+        settings->setValue(key + "font", fdesc);
+
+        // Write the background color.
+        c = lexer->paper(i);
+        num = (c.red() << 16) | (c.green() << 8) | c.blue();
+
+        settings->setValue(key + "paper", num);
+    }
+}
+
+
+/*!
+    \brief Sets the \a color for the given \a style.
+ */
+void UiguiHighlighter::setColor(const QColor &color, int style) {
+    colorForStyles[style] = color;
+    lexer->setColor( color, style );
+}
+
+
+/*!
+    \brief Sets the \a font for the given \a style.
+ */
+void UiguiHighlighter::setFont(const QFont &font, int style) {
+    fontForStyles[style] = font;
+    lexer->setFont( font, style );
+}
+
+
+/*!
+    \brief Sets the to be used lexer by giving his name.
+ */
+void UiguiHighlighter::setLexerByName( QString lexerName ) {
+    setLexerForExtension( mapHighlighternameToExtension[lexerName].first() );
+}
+
+
+/*!
+    \brief Sets the proper highlighter / lexer for the given file \a extension. Returns the index of the used lexer in the list.
+ */
+int UiguiHighlighter::setLexerForExtension( QString extension ) {
+    int indexOfHighlighter = 0;
+	extension = extension.toLower();
+
+	if ( lexer ) {
+		writeCurrentSettings("");
+		delete lexer;
+	}
+
+	if ( extension == "cpp" || extension == "hpp" || extension == "c" || extension == "h" || extension == "cxx" || extension == "hxx" ) {
+		lexer = new QsciLexerCPP();
+	} 
+	else if ( extension == "sh" ) {
+		lexer = new QsciLexerBash();
+	}
+	else if ( extension == "bat" ) {
+		lexer = new QsciLexerBatch();
+	}
+    else if ( extension == "cmake" ) {
+        lexer = new QsciLexerCMake();
+    }
+	else if ( extension == "cs" ) {
+		lexer = new QsciLexerCSharp();
+	}
+	else if ( extension == "css" ) {
+		lexer = new QsciLexerCSS();
+	}
+	else if ( extension == "d" ) {
+		lexer = new QsciLexerD();
+	}
+	else if ( extension == "diff" ) {
+		lexer = new QsciLexerDiff();
+	}
+    else if ( extension == "f" || extension == "for" ) {
+        lexer = new QsciLexerFortran();
+    }
+    else if ( extension == "f77" ) {
+        lexer = new QsciLexerFortran77();
+    }
+	else if ( extension == "html" ) {
+		lexer = new QsciLexerHTML();
+	}
+	else if ( extension == "idl" ) {
+		lexer = new QsciLexerIDL();
+	}
+	else if ( extension == "java" ) {
+		lexer = new QsciLexerJava();
+	}
+	else if ( extension == "js" ) {
+		lexer = new QsciLexerJavaScript();
+	}
+	else if ( extension == "lua" ) {
+		lexer = new QsciLexerLua();
+	}
+    else if ( extension == "makefile" ) {
+		lexer = new QsciLexerMakefile();
+	}
+    else if ( extension == "pas" ) {
+        lexer = new QsciLexerPascal();
+    }
+	else if ( extension == "perl" || extension == "pl" || extension == "pm" ) {
+		lexer = new QsciLexerPerl();
+	}
+    else if ( extension == "php" ) {
+		lexer = new QsciLexerHTML();
+	}
+    else if ( extension == "ps" || extension == "eps" || extension == "pdf" || extension == "ai" || extension == "fh") {
+        lexer = new QsciLexerPostScript();
+    }
+	else if ( extension == "pov" ) {
+		lexer = new QsciLexerPOV();
+	}
+	else if ( extension == "ini" ) {
+		lexer = new QsciLexerProperties();
+	}
+	else if ( extension == "py" ) {
+		lexer = new QsciLexerPython();
+	}
+	else if ( extension == "rub" || extension == "rb" ) {
+		lexer = new QsciLexerRuby();
+	}
+	else if ( extension == "sql" ) {
+		lexer = new QsciLexerSQL();
+	}
+    else if ( extension == "tcl" ) {
+        lexer = new QsciLexerTCL();
+    }
+	else if ( extension == "tex" ) {
+		lexer = new QsciLexerTeX();
+	}
+    else if ( extension == "vhdl" ) {
+        lexer = new QsciLexerVHDL();
+    }
+    else if ( extension == "xml" ) {
+		lexer = new QsciLexerXML();
+	}
+    else if ( extension == "yaml" ) {
+        lexer = new QsciLexerYAML();
+    }
+	else {
+		lexer = new QsciLexerCPP();
+        extension = "cpp";
+	}
+
+    // Find the index of the selected lexer.
+    indexOfHighlighter = 0;
+    while ( !mapHighlighternameToExtension.values().at(indexOfHighlighter).contains(extension) ) {
+        indexOfHighlighter++;
+    }
+
+    // Set the lexer for the QScintilla widget.
+    if ( highlightningIsOn ) {
+	    parent->setLexer(lexer);
+    }
+
+    // Read the settings for the lexer properties from file.
+	readCurrentSettings("");
+
+    return indexOfHighlighter;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/UiguiHighlighter.h	Thu Oct 02 20:33:34 2008 +0000
@@ -0,0 +1,99 @@
+/***************************************************************************
+ *   Copyright (C) 2006-2008 by Thomas Schweitzer                          *
+ *   thomas-schweitzer(at)arcor.de                                         *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License version 2.0 as   *
+ *   published by the Free Software Foundation.                            *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program in the file LICENSE.GPL; if not, write to the *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef UIGUIHIGHLIGHTER_H
+#define UIGUIHIGHLIGHTER_H
+
+#include <QObject>
+#include <QMap>
+#include <QMenu>
+#include <QCoreApplication>
+#include <Qsci/qsciscintilla.h>
+#include <Qsci/qscilexer.h>
+#include <Qsci/qscilexerbash.h>
+#include <Qsci/qscilexerbatch.h>
+#include <Qsci/qscilexercmake.h>
+#include <Qsci/qscilexercpp.h>
+#include <Qsci/qscilexercsharp.h>
+#include <Qsci/qscilexercss.h>
+#include <Qsci/qscilexerd.h>
+#include <Qsci/qscilexerdiff.h>
+#include <Qsci/qscilexerfortran.h>
+#include <Qsci/qscilexerfortran77.h>
+#include <Qsci/qscilexerhtml.h>
+#include <Qsci/qscilexeridl.h>
+#include <Qsci/qscilexerjava.h>
+#include <Qsci/qscilexerjavascript.h>
+#include <Qsci/qscilexerlua.h>
+#include <Qsci/qscilexermakefile.h>
+#include <Qsci/qscilexerpascal.h>
+#include <Qsci/qscilexerperl.h>
+#include <Qsci/qscilexerpostscript.h>
+#include <Qsci/qscilexerpov.h>
+#include <Qsci/qscilexerproperties.h>
+#include <Qsci/qscilexerpython.h>
+#include <Qsci/qscilexerruby.h>
+#include <Qsci/qscilexersql.h>
+#include <Qsci/qscilexertcl.h>
+#include <Qsci/qscilexertex.h>
+#include <Qsci/qscilexervhdl.h>
+#include <Qsci/qscilexerxml.h>
+#include <Qsci/qscilexeryaml.h>
+
+
+class UiguiHighlighter : public QObject
+{
+    Q_OBJECT
+
+public:
+    UiguiHighlighter(QsciScintilla *parent);
+    void turnHighlightOff();
+    void turnHighlightOn();
+	
+	bool readCurrentSettings(const char *prefix);
+	void writeCurrentSettings(const char *prefix);
+    QStringList getAvailableHighlighters();
+
+private:
+    bool highlightningIsOn;
+    QsciScintilla *parent;
+    QMap<int, QFont> fontForStyles;
+    QMap<int, QColor> colorForStyles;
+	QsciLexer* lexer;
+	QSettings *settings;
+    QMap<QString, QStringList> mapHighlighternameToExtension;
+
+public slots:
+    //! The foreground color for style number \a style is set to \a color.  If
+    //! \a style is -1 then the color is set for all styles.
+    void setColor(const QColor &color, int style = -1);
+
+    //! The font for style number \a style is set to \a font.  If \a style is
+    //! -1 then the font is set for all styles.
+    void setFont(const QFont &font, int style = -1);
+
+	//! Sets the lexer that is responsible for the given \a extension.
+	int setLexerForExtension( QString extension );
+
+    void setLexerByName( QString lexerName );
+
+	void setHighlighterByAction(QAction* highlighterAction);
+};
+
+#endif  // UIGUIHIGHLIGHTER_H
--- a/src/UniversalIndentGUI.vcproj	Thu Oct 02 20:24:55 2008 +0000
+++ b/src/UniversalIndentGUI.vcproj	Thu Oct 02 20:33:34 2008 +0000
@@ -224,7 +224,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath=".\highlighter.cpp"
+				RelativePath=".\UiguiHighlighter.cpp"
 				>
 			</File>
 			<File
@@ -293,7 +293,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath=".\highlighter.h"
+				RelativePath=".\UiguiHighlighter.h"
 				>
 			</File>
 			<File
@@ -394,7 +394,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="$(OutDir)\tmp\moc\moc_highlighter.cpp"
+				RelativePath="$(OutDir)\tmp\moc\moc_UiguiHighlighter.cpp"
 				>
 			</File>
 			<File
--- a/src/highlighter.cpp	Thu Oct 02 20:24:55 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,436 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006-2008 by Thomas Schweitzer                          *
- *   thomas-schweitzer(at)arcor.de                                         *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License version 2.0 as   *
- *   published by the Free Software Foundation.                            *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program in the file LICENSE.GPL; if not, write to the *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include <QtGui>
-
-#include "highlighter.h"
-
-#include "SettingsPaths.h"
-
-//! \defgroup grp_EditorComponent All concerning editor widget.
-
-/*!
-    \class UiguiHighlighter
-    \ingroup grp_EditorComponent
-    \brief UiguiHighlighter used for selecting the syntax highlighter/lexer for the QsciScintilla component.
-*/
-
-/*!
-    \brief The constructor initializes some regular expressions and keywords to identify cpp tokens
- */
-UiguiHighlighter::UiguiHighlighter(QsciScintilla *parent)
-: QObject(parent)
-{
-    this->parent = parent;
-
-    // If a "indenters" subdir in the applications binary path exists, use local config files (portable mode)
-    if ( SettingsPaths::getPortableMode() ) {
-        this->settings = new QSettings(SettingsPaths::getGlobalFilesPath() + "/config/UiGuiSyntaxHighlightConfig.ini", QSettings::IniFormat, this);
-    } 
-    // ... otherwise use the users application data default dir.
-    else {
-        this->settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), "UiGuiSyntaxHighlightConfig", this);
-    }
-
-    highlightningIsOn = true;
-
-    mapHighlighternameToExtension["Bash"] = QStringList() << "sh";
-    mapHighlighternameToExtension["Batch"] = QStringList() << "bat";
-    mapHighlighternameToExtension["CMake"] = QStringList() << "cmake";
-    mapHighlighternameToExtension["C++"] = QStringList() << "c" << "h" << "cpp" << "hpp" << "cxx" << "hxx";
-    mapHighlighternameToExtension["C#"] = QStringList() << "cs";
-    mapHighlighternameToExtension["CSS"] = QStringList() << "css";
-    mapHighlighternameToExtension["D"] = QStringList() << "d";
-    mapHighlighternameToExtension["Diff"] = QStringList() << "diff";
-    mapHighlighternameToExtension["Fortran"] = QStringList() << "f" << "for";
-    mapHighlighternameToExtension["Fortran77"] = QStringList() << "f77";
-    mapHighlighternameToExtension["HTML"] = QStringList() << "html";
-    mapHighlighternameToExtension["IDL"] = QStringList() << "idl";
-    mapHighlighternameToExtension["Java"] = QStringList() << "java";
-    mapHighlighternameToExtension["JavaScript"] = QStringList() << "js";
-    mapHighlighternameToExtension["LUA"] = QStringList() << "lua";
-    mapHighlighternameToExtension["Makefile"] = QStringList() << "makefile";
-    mapHighlighternameToExtension["Pascal"] = QStringList() << "pas";
-    mapHighlighternameToExtension["Perl"] = QStringList() << "perl" << "pl" << "pm";
-    mapHighlighternameToExtension["PHP"] = QStringList() << "php";
-    mapHighlighternameToExtension["PostScript"] = QStringList() << "ps" << "eps" << "pdf" << "ai" << "fh";
-    mapHighlighternameToExtension["POV"] = QStringList() << "pov";
-    mapHighlighternameToExtension["Ini"] = QStringList() << "ini";
-    mapHighlighternameToExtension["Python"] = QStringList() << "py";
-    mapHighlighternameToExtension["Ruby"] = QStringList() << "rub" << "rb";
-    mapHighlighternameToExtension["SQL"] = QStringList() << "sql";
-    mapHighlighternameToExtension["TCL"] = QStringList() << "tcl";
-    mapHighlighternameToExtension["TeX"] = QStringList() << "tex";
-    mapHighlighternameToExtension["VHDL"] = QStringList() << "vhdl";
-    mapHighlighternameToExtension["XML"] = QStringList() << "xml";
-    mapHighlighternameToExtension["YAML"] = QStringList() << "yaml";
-
-    lexer = 0;
-
-    // This code is only for testing.
-    /*
-    foreach(QStringList extensionList, mapHighlighternameToExtension.values() ) {
-        setLexerForExtension( extensionList.at(0) );
-    }
-    */
-
-    // Set default highlighter to C++ highlighter.
-    setLexerForExtension( "cpp" );
-}
-
-
-/*!
-    \brief Returns the available highlighters as QStringList.
- */
-QStringList UiguiHighlighter::getAvailableHighlighters() {
-    return mapHighlighternameToExtension.keys();
-}
-
-
-/*!
-    \brief This slot handles signals coming from selecting another syntax highlighter.
- */
-void UiguiHighlighter::setHighlighterByAction(QAction* highlighterAction) {
-	QString highlighterName = highlighterAction->text();
-    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);
-}
-
-
-/*!
-    \brief Turns the syntax parser on.
-*/
-void UiguiHighlighter::turnHighlightOn() {
-    highlightningIsOn = true;
-	parent->setLexer(lexer);
-    readCurrentSettings("");
-}
-
-/*!
-    \brief Turns the syntax parser off.
-*/
-void UiguiHighlighter::turnHighlightOff() {
-    highlightningIsOn = false;
-	parent->setLexer();
-    parent->setFont( QFont("Courier", 10, QFont::Normal) );
-    parent->setMarginsFont( QFont("Courier", 10, QFont::Normal) );
-}
-
-
-/*!
-    \brief Read the settings for the current lexer from the settings file.
- */
-bool UiguiHighlighter::readCurrentSettings( const char *prefix )
-{
-    bool ok, flag, rc = true;
-    int num;
-    QString key;
-
-    // Reset lists containing fonts and colors for each style
-    fontForStyles.clear();
-    colorForStyles.clear();
-
-    // Read the styles.
-    for (int i = 0; i < 128; ++i)
-    {
-        // Ignore invalid styles.
-        if ( lexer->description(i).isEmpty() )
-            continue;
-
-        key.sprintf( "%s/%s/style%d/", prefix, lexer->language(), i );
-		key.replace("+", "p");
-
-        // Read the foreground color.
-        ok = settings->contains(key + "color");
-        num = settings->value(key + "color", 0).toInt();
-
-        if (ok)
-            setColor( QColor((num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff), i );
-        else
-            rc = false;
-
-        // Read the end-of-line fill.
-        ok = settings->contains(key + "eolfill");
-        flag = settings->value(key + "eolfill", false).toBool();
-
-        if (ok)
-            lexer->setEolFill( flag, i );
-        else
-            rc = false;
-
-        // Read the font
-        QStringList fdesc;
-
-        ok = settings->contains(key + "font");
-        fdesc = settings->value(key + "font").toStringList();
-
-        if (ok && fdesc.count() == 5)
-        {
-            QFont f;
-
-            f.setFamily(fdesc[0]);
-            f.setPointSize(fdesc[1].toInt());
-            f.setBold(fdesc[2].toInt());
-            f.setItalic(fdesc[3].toInt());
-            f.setUnderline(fdesc[4].toInt());
-
-            setFont(f, i);
-        }
-        else
-            rc = false;
-
-        // Read the background color.
-        ok = settings->contains(key + "paper");
-        num = settings->value(key + "paper", 0).toInt();
-
-        if (ok)
-            lexer->setPaper( QColor((num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff), i );
-        else
-            rc = false;
-    }
-
-    // Read the properties.
-    key.sprintf( "%s/%s/properties/", prefix, lexer->language() );
-
-    lexer->refreshProperties();
-
-    return rc;
-}
-
-
-/*!
-    \brief Write the settings for the current lexer to the settings file.
- */
-void UiguiHighlighter::writeCurrentSettings( const char *prefix )
-{
-    QString key;
-
-    // Write the styles.
-    for (int i = 0; i < 128; ++i) {
-        // Ignore invalid styles.
-        if ( lexer->description(i).isEmpty() )
-            continue;
-
-        int num;
-        QColor c;
-
-        key.sprintf( "%s/%s/style%d/", prefix, lexer->language(), i );
-		key.replace("+", "p");
-
-		// Write style name
-		settings->setValue( key + "", lexer->description(i) );
-
-        // Write the foreground color.
-		if ( colorForStyles.contains(i) ) {
-			c = colorForStyles[i];
-		}
-		else {
-			c = lexer->color(i);
-		}
-        num = (c.red() << 16) | (c.green() << 8) | c.blue();
-
-        settings->setValue(key + "color", num);
-
-        // Write the end-of-line fill.
-        settings->setValue( key + "eolfill", lexer->eolFill(i) );
-
-        // Write the font
-        QStringList fdesc;
-        QString fmt("%1");
-        QFont f;
-
-		if ( fontForStyles.contains(i) ) {
-			f = fontForStyles[i];
-		}
-		else {
-			f = lexer->font(i);
-		}
-
-        fdesc += f.family();
-        fdesc += fmt.arg( f.pointSize() );
-
-        // The casts are for Borland.
-        fdesc += fmt.arg( (int)f.bold() );
-        fdesc += fmt.arg( (int)f.italic() );
-        fdesc += fmt.arg( (int)f.underline() );
-
-        settings->setValue(key + "font", fdesc);
-
-        // Write the background color.
-        c = lexer->paper(i);
-        num = (c.red() << 16) | (c.green() << 8) | c.blue();
-
-        settings->setValue(key + "paper", num);
-    }
-}
-
-
-/*!
-    \brief Sets the \a color for the given \a style.
- */
-void UiguiHighlighter::setColor(const QColor &color, int style) {
-    colorForStyles[style] = color;
-    lexer->setColor( color, style );
-}
-
-
-/*!
-    \brief Sets the \a font for the given \a style.
- */
-void UiguiHighlighter::setFont(const QFont &font, int style) {
-    fontForStyles[style] = font;
-    lexer->setFont( font, style );
-}
-
-
-/*!
-    \brief Sets the to be used lexer by giving his name.
- */
-void UiguiHighlighter::setLexerByName( QString lexerName ) {
-    setLexerForExtension( mapHighlighternameToExtension[lexerName].first() );
-}
-
-
-/*!
-    \brief Sets the proper highlighter / lexer for the given file \a extension. Returns the index of the used lexer in the list.
- */
-int UiguiHighlighter::setLexerForExtension( QString extension ) {
-    int indexOfHighlighter = 0;
-	extension = extension.toLower();
-
-	if ( lexer ) {
-		writeCurrentSettings("");
-		delete lexer;
-	}
-
-	if ( extension == "cpp" || extension == "hpp" || extension == "c" || extension == "h" || extension == "cxx" || extension == "hxx" ) {
-		lexer = new QsciLexerCPP();
-	} 
-	else if ( extension == "sh" ) {
-		lexer = new QsciLexerBash();
-	}
-	else if ( extension == "bat" ) {
-		lexer = new QsciLexerBatch();
-	}
-    else if ( extension == "cmake" ) {
-        lexer = new QsciLexerCMake();
-    }
-	else if ( extension == "cs" ) {
-		lexer = new QsciLexerCSharp();
-	}
-	else if ( extension == "css" ) {
-		lexer = new QsciLexerCSS();
-	}
-	else if ( extension == "d" ) {
-		lexer = new QsciLexerD();
-	}
-	else if ( extension == "diff" ) {
-		lexer = new QsciLexerDiff();
-	}
-    else if ( extension == "f" || extension == "for" ) {
-        lexer = new QsciLexerFortran();
-    }
-    else if ( extension == "f77" ) {
-        lexer = new QsciLexerFortran77();
-    }
-	else if ( extension == "html" ) {
-		lexer = new QsciLexerHTML();
-	}
-	else if ( extension == "idl" ) {
-		lexer = new QsciLexerIDL();
-	}
-	else if ( extension == "java" ) {
-		lexer = new QsciLexerJava();
-	}
-	else if ( extension == "js" ) {
-		lexer = new QsciLexerJavaScript();
-	}
-	else if ( extension == "lua" ) {
-		lexer = new QsciLexerLua();
-	}
-    else if ( extension == "makefile" ) {
-		lexer = new QsciLexerMakefile();
-	}
-    else if ( extension == "pas" ) {
-        lexer = new QsciLexerPascal();
-    }
-	else if ( extension == "perl" || extension == "pl" || extension == "pm" ) {
-		lexer = new QsciLexerPerl();
-	}
-    else if ( extension == "php" ) {
-		lexer = new QsciLexerHTML();
-	}
-    else if ( extension == "ps" || extension == "eps" || extension == "pdf" || extension == "ai" || extension == "fh") {
-        lexer = new QsciLexerPostScript();
-    }
-	else if ( extension == "pov" ) {
-		lexer = new QsciLexerPOV();
-	}
-	else if ( extension == "ini" ) {
-		lexer = new QsciLexerProperties();
-	}
-	else if ( extension == "py" ) {
-		lexer = new QsciLexerPython();
-	}
-	else if ( extension == "rub" || extension == "rb" ) {
-		lexer = new QsciLexerRuby();
-	}
-	else if ( extension == "sql" ) {
-		lexer = new QsciLexerSQL();
-	}
-    else if ( extension == "tcl" ) {
-        lexer = new QsciLexerTCL();
-    }
-	else if ( extension == "tex" ) {
-		lexer = new QsciLexerTeX();
-	}
-    else if ( extension == "vhdl" ) {
-        lexer = new QsciLexerVHDL();
-    }
-    else if ( extension == "xml" ) {
-		lexer = new QsciLexerXML();
-	}
-    else if ( extension == "yaml" ) {
-        lexer = new QsciLexerYAML();
-    }
-	else {
-		lexer = new QsciLexerCPP();
-        extension = "cpp";
-	}
-
-    // Find the index of the selected lexer.
-    indexOfHighlighter = 0;
-    while ( !mapHighlighternameToExtension.values().at(indexOfHighlighter).contains(extension) ) {
-        indexOfHighlighter++;
-    }
-
-    // Set the lexer for the QScintilla widget.
-    if ( highlightningIsOn ) {
-	    parent->setLexer(lexer);
-    }
-
-    // Read the settings for the lexer properties from file.
-	readCurrentSettings("");
-
-    return indexOfHighlighter;
-}
--- a/src/highlighter.h	Thu Oct 02 20:24:55 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006-2008 by Thomas Schweitzer                          *
- *   thomas-schweitzer(at)arcor.de                                         *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License version 2.0 as   *
- *   published by the Free Software Foundation.                            *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program in the file LICENSE.GPL; if not, write to the *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef UIGUIHIGHLIGHTER_H
-#define UIGUIHIGHLIGHTER_H
-
-#include <QObject>
-#include <QMap>
-#include <QMenu>
-#include <QCoreApplication>
-#include <Qsci/qsciscintilla.h>
-#include <Qsci/qscilexer.h>
-#include <Qsci/qscilexerbash.h>
-#include <Qsci/qscilexerbatch.h>
-#include <Qsci/qscilexercmake.h>
-#include <Qsci/qscilexercpp.h>
-#include <Qsci/qscilexercsharp.h>
-#include <Qsci/qscilexercss.h>
-#include <Qsci/qscilexerd.h>
-#include <Qsci/qscilexerdiff.h>
-#include <Qsci/qscilexerfortran.h>
-#include <Qsci/qscilexerfortran77.h>
-#include <Qsci/qscilexerhtml.h>
-#include <Qsci/qscilexeridl.h>
-#include <Qsci/qscilexerjava.h>
-#include <Qsci/qscilexerjavascript.h>
-#include <Qsci/qscilexerlua.h>
-#include <Qsci/qscilexermakefile.h>
-#include <Qsci/qscilexerpascal.h>
-#include <Qsci/qscilexerperl.h>
-#include <Qsci/qscilexerpostscript.h>
-#include <Qsci/qscilexerpov.h>
-#include <Qsci/qscilexerproperties.h>
-#include <Qsci/qscilexerpython.h>
-#include <Qsci/qscilexerruby.h>
-#include <Qsci/qscilexersql.h>
-#include <Qsci/qscilexertcl.h>
-#include <Qsci/qscilexertex.h>
-#include <Qsci/qscilexervhdl.h>
-#include <Qsci/qscilexerxml.h>
-#include <Qsci/qscilexeryaml.h>
-
-
-class UiguiHighlighter : public QObject
-{
-    Q_OBJECT
-
-public:
-    UiguiHighlighter(QsciScintilla *parent);
-    void turnHighlightOff();
-    void turnHighlightOn();
-	
-	bool readCurrentSettings(const char *prefix);
-	void writeCurrentSettings(const char *prefix);
-    QStringList getAvailableHighlighters();
-
-private:
-    bool highlightningIsOn;
-    QsciScintilla *parent;
-    QMap<int, QFont> fontForStyles;
-    QMap<int, QColor> colorForStyles;
-	QsciLexer* lexer;
-	QSettings *settings;
-    QMap<QString, QStringList> mapHighlighternameToExtension;
-
-public slots:
-    //! The foreground color for style number \a style is set to \a color.  If
-    //! \a style is -1 then the color is set for all styles.
-    void setColor(const QColor &color, int style = -1);
-
-    //! The font for style number \a style is set to \a font.  If \a style is
-    //! -1 then the font is set for all styles.
-    void setFont(const QFont &font, int style = -1);
-
-	//! Sets the lexer that is responsible for the given \a extension.
-	int setLexerForExtension( QString extension );
-
-    void setLexerByName( QString lexerName );
-
-	void setHighlighterByAction(QAction* highlighterAction);
-};
-
-#endif  // UIGUIHIGHLIGHTER_H
--- a/src/mainwindow.h	Thu Oct 02 20:24:55 2008 +0000
+++ b/src/mainwindow.h	Thu Oct 02 20:33:34 2008 +0000
@@ -26,7 +26,7 @@
 #include "AboutDialogGraphicsView.h"
 #include "uiguisettings.h"
 #include "uiguisettingsdialog.h"
-#include "highlighter.h"
+#include "UiguiHighlighter.h"
 #include "indenthandler.h"
 #include "updatecheckdialog.h"