Mercurial > hg > octave-lojdl
changeset 16556:ce65326ecd6c
added default colors and fonts to the octave lexer
* lexer-octave-gui.cc: some code formatting
(defaultColor): new function returning the default colors
(defaultFont): new function returning the default fonts
* lexer-octave-gui.h: new functions defaultColor and defaultFont
author | Torsten <ttl@justmail.de> |
---|---|
date | Tue, 23 Apr 2013 21:40:36 +0200 |
parents | 04fb96f4bea1 |
children | d50bca1cdc22 |
files | libgui/src/m-editor/lexer-octave-gui.cc libgui/src/m-editor/lexer-octave-gui.h |
diffstat | 2 files changed, 66 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/lexer-octave-gui.cc +++ b/libgui/src/m-editor/lexer-octave-gui.cc @@ -67,17 +67,20 @@ // 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 +const char * +lexer_octave_gui::language() const { return "Octave"; // return the name of the language } -const char *lexer_octave_gui::lexer() const +const char * +lexer_octave_gui::lexer() const { return "octave"; // return the name of the lexer } -QString lexer_octave_gui::description(int style) const +QString +lexer_octave_gui::description(int style) const { switch (style) { @@ -103,10 +106,66 @@ return QString(); // no valid style, return empty string } + +// ----------------------------------------------------- +// The set of default colors +// ----------------------------------------------------- +QColor +lexer_octave_gui::defaultColor (int style) const +{ + switch (style) + { + case Default: + case Operator: + return QColor (0x00,0x00,0x00); + + case Comment: + return QColor (0x00,0x7f,0x00); + + case Command: + return QColor (0x7f,0x7f,0x00); + + case Number: + return QColor (0x00,0x7f,0x7f); + + case Keyword: + return QColor (0x00,0x00,0x7f); + + case SingleQuotedString: + case DoubleQuotedString: + return QColor (0x7f,0x00,0x7f); + } + + return QsciLexer::defaultColor (style); +} + +// ----------------------------------------------------- +// The defaulot fonts +// ----------------------------------------------------- +QFont +lexer_octave_gui::defaultFont (int style) const +{ + QFont font; + + switch (style) + { + case Keyword: + font = QsciLexer::defaultFont (style); + font.setBold(true); + break; + + default: + font = QsciLexer::defaultFont (style); + } + + return font; +} + // ----------------------------------------------------- // The set of keywords for highlighting // ----------------------------------------------------- -const char *lexer_octave_gui::keywords(int set) const +const char * +lexer_octave_gui::keywords(int set) const { if (set == 1) return resource_manager::octave_keywords ();
--- a/libgui/src/m-editor/lexer-octave-gui.h +++ b/libgui/src/m-editor/lexer-octave-gui.h @@ -53,7 +53,9 @@ virtual const char *keywords (int set) const; virtual const char *lexer () const; virtual const char *language () const; - QString description(int style) const; + QString description (int style) const; + QColor defaultColor (int style) const; + QFont defaultFont (int style) const; private: lexer_octave_gui (const lexer_octave_gui &);