# HG changeset patch # User Torsten # Date 1365786632 -7200 # Node ID 3781abc745407918535497112c021b25dec0583a # Parent 06bdf84aa3d924b3e447bc4d3989a725056d55bb gui: use general qscintilla lexer configured for octave * lexer-octave-gui.cc/.h: lexer derived from QsciLexer, not from QsciLexerOctave (lexer,language,description): redefined virtual functions from QsciLexer * lexer-octave-gui.cc(constructor): settings not needed * lexer-octave-gui.h: enum with octave styles diff --git a/libgui/src/m-editor/lexer-octave-gui.cc b/libgui/src/m-editor/lexer-octave-gui.cc --- a/libgui/src/m-editor/lexer-octave-gui.cc +++ b/libgui/src/m-editor/lexer-octave-gui.cc @@ -34,7 +34,7 @@ // Some basic functions // ----------------------------------------------------- lexer_octave_gui::lexer_octave_gui (QObject *p) - : QsciLexerOctave (p) + : QsciLexer (p) { // The API info that is used for auto completion // TODO: Where to store a file with API info (raw or prepared?)? @@ -52,9 +52,6 @@ lexer_api->add (keywordList.at (i)); lexer_api->prepare (); // prepare API info ... this may take some time } - - // get the settings from the settings file - QSettings *settings = resource_manager::get_settings (); } lexer_octave_gui::~lexer_octave_gui() @@ -63,6 +60,49 @@ delete lexer_api; } +// ----------------------------------------------------------------------------- +// Redefined functions to make an octave lexer from the abtract class Qscilexer. +// Scintilla has an octave/matlab-lexer but the interface in Qscintilla is +// only available in version 2.5.1. Redefining the following purely virtual +// functions of the class QsciLexer () and the enum of available styles (see +// lexer-octave-gui.h provides the functionality of the octave lexer. +// ----------------------------------------------------------------------------- +const char *lexer_octave_gui::language() const +{ + return "Octave"; // return the name of the language +} + +const char *lexer_octave_gui::lexer() const +{ + return "octave"; // return the name of the lexer +} + +QString lexer_octave_gui::description(int style) const +{ + switch (style) + { + case Default: + return tr("Default"); + case Comment: + return tr("Comment"); + case Command: + return tr("Command"); + case Number: + return tr("Number"); + case Keyword: + return tr("Keyword"); + case SingleQuotedString: + return tr("Single-quoted string"); + case Operator: + return tr("Operator"); + case Identifier: + return tr("Identifier"); + case DoubleQuotedString: + return tr("Double-quoted string"); + } + return QString(); // no valid style, return empty string +} + // ----------------------------------------------------- // The set of keywords for highlighting // ----------------------------------------------------- diff --git a/libgui/src/m-editor/lexer-octave-gui.h b/libgui/src/m-editor/lexer-octave-gui.h --- a/libgui/src/m-editor/lexer-octave-gui.h +++ b/libgui/src/m-editor/lexer-octave-gui.h @@ -26,18 +26,34 @@ #include "resource-manager.h" #include #include -#include +#include #include -class lexer_octave_gui : public QsciLexerOctave +class lexer_octave_gui : public QsciLexer { Q_OBJECT public: + enum { + Default = 0, + Comment = 1, + Command = 2, + Number = 3, + Keyword = 4, + SingleQuotedString = 5, + Operator = 6, + Identifier = 7, + DoubleQuotedString = 8 + }; + + lexer_octave_gui (QObject *parent = 0); ~lexer_octave_gui (); virtual const char *keywords (int set) const; + virtual const char *lexer () const; + virtual const char *language () const; + QString description(int style) const; private: lexer_octave_gui (const lexer_octave_gui &);