1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00

syntax colouring for comments

This commit is contained in:
Marc Zinnschlag 2013-04-11 10:50:35 +02:00
parent 6d3a2cd5a0
commit f17cebde0a
2 changed files with 19 additions and 3 deletions

View file

@ -40,6 +40,13 @@ bool CSVWorld::ScriptHighlighter::parseSpecial (int code, const Compiler::TokenL
return true; return true;
} }
bool CSVWorld::ScriptHighlighter::parseComment (const std::string& comment,
const Compiler::TokenLoc& loc, Compiler::Scanner& scanner)
{
highlight (loc, Type_Comment);
return true;
}
void CSVWorld::ScriptHighlighter::parseEOF (Compiler::Scanner& scanner) void CSVWorld::ScriptHighlighter::parseEOF (Compiler::Scanner& scanner)
{} {}
@ -67,7 +74,7 @@ CSVWorld::ScriptHighlighter::ScriptHighlighter (QTextDocument *parent)
{ {
QTextCharFormat format; QTextCharFormat format;
format.setForeground (Qt::green); format.setForeground (Qt::magenta);
mScheme.insert (std::make_pair (Type_Float, format)); mScheme.insert (std::make_pair (Type_Float, format));
} }
@ -88,6 +95,12 @@ CSVWorld::ScriptHighlighter::ScriptHighlighter (QTextDocument *parent)
format.setForeground (Qt::darkYellow); format.setForeground (Qt::darkYellow);
mScheme.insert (std::make_pair (Type_Special, format)); mScheme.insert (std::make_pair (Type_Special, format));
} }
{
QTextCharFormat format;
format.setForeground (Qt::green);
mScheme.insert (std::make_pair (Type_Comment, format));
}
} }
void CSVWorld::ScriptHighlighter::highlightBlock (const QString& text) void CSVWorld::ScriptHighlighter::highlightBlock (const QString& text)

View file

@ -22,7 +22,8 @@ namespace CSVWorld
Type_Float, Type_Float,
Type_Name, Type_Name,
Type_Keyword, Type_Keyword,
Type_Special Type_Special,
Type_Comment
}; };
private: private:
@ -58,7 +59,9 @@ namespace CSVWorld
///< Handle a special character token. ///< Handle a special character token.
/// \return fetch another token? /// \return fetch another token?
///< Handle a special character token. virtual bool parseComment (const std::string& comment, const Compiler::TokenLoc& loc,
Compiler::Scanner& scanner);
///< Handle comment token.
/// \return fetch another token? /// \return fetch another token?
virtual void parseEOF (Compiler::Scanner& scanner); virtual void parseEOF (Compiler::Scanner& scanner);