Mantid
Loading...
Searching...
No Matches
AlternateCSPythonLexer.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
13AlternateCSPythonLexer::AlternateCSPythonLexer(const QFont &font) : QsciLexerPython(), m_font(font) {}
14
20QColor AlternateCSPythonLexer::defaultColor(int style) const {
21 switch (style) {
22 case Default:
23 return QColor(0x00, 0x00, 0x00);
24
25 case Comment:
26 return QColor(0xad, 0xad, 0xad);
27
28 case Number:
29 return QColor(0x80, 0x00, 0x00);
30
31 case DoubleQuotedString:
32 case SingleQuotedString:
33 return QColor(0x00, 0xaa, 0x00);
34
35 case DoubleQuotedFString:
36 case SingleQuotedFString:
37 return QColor(0x00, 0xaa, 0x00);
38
39 case Keyword:
40 return QColor(0x00, 0x00, 0xff);
41
42 case TripleSingleQuotedString:
43 case TripleDoubleQuotedString:
44 return QColor(0x00, 0xaa, 0x00);
45
46 case TripleSingleQuotedFString:
47 case TripleDoubleQuotedFString:
48 return QColor(0x00, 0xaa, 0x00);
49
50 case ClassName:
51 return QColor(0x00, 0x00, 0x00);
52
53 case FunctionMethodName:
54 return QColor(0x00, 0x7f, 0x7f);
55
56 case Operator:
57 case Identifier:
58 break;
59
60 case CommentBlock:
61 return QColor(0xad, 0xad, 0xad);
62
63 case UnclosedString:
64 return QColor(0x00, 0x00, 0x00);
65
66 case HighlightedIdentifier:
67 return QColor(0x40, 0x70, 0x90);
68
69 case Decorator:
70 return QColor(0x80, 0x50, 0x00);
71 }
72
73 return QsciLexer::defaultColor(style);
74}
75
82 Q_UNUSED(style);
83 return m_font;
84}
85
87// * Returns the keywords used by the lexer for a given set.
88// * @param set The keyword set to retrieve (1 is for keywords)
89// * @return A string containing the keywords
90// */
91const char *AlternateCSPythonLexer::keywords(int set) const {
92 if (set == 1) {
93 // Retrieve default Python keywords from qscintilla
94 const char *defaultKeywords = QsciLexerPython::keywords(1);
95 static std::string combinedKeywords;
96 std::ostringstream stream;
97 stream << defaultKeywords << " " << customKeywords;
98
99 combinedKeywords = stream.str();
100 return combinedKeywords.c_str();
101 }
102
103 return QsciLexerPython::keywords(set);
104}
QColor defaultColor(int style) const override
Returns the foreground colour of the text for a style.
AlternateCSPythonLexer(const QFont &font)
Construct a lexer with a font to be used for all text styles.
QFont defaultFont(int style) const override
Returns the font of the text.
const char * keywords(int set) const override
‍**
static constexpr const char * customKeywords