Mercurial > hg > octave-lyh
changeset 16501:3781abc74540
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
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 12 Apr 2013 19:10:32 +0200 |
parents | 06bdf84aa3d9 |
children | 45ae1038ee89 |
files | libgui/src/m-editor/lexer-octave-gui.cc libgui/src/m-editor/lexer-octave-gui.h |
diffstat | 2 files changed, 62 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 // -----------------------------------------------------
--- 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 <QObject> #include <Qsci/qsciglobal.h> -#include <Qsci/qscilexeroctave.h> +#include <Qsci/qscilexer.h> #include <Qsci/qsciapis.h> -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 &);