Skip to content
This repository
tree: 76a327a8d2
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 118 lines (91 sloc) 2.337 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
#include "lexer_python.hpp"
#include "lexer_factory.hpp"

#include "syntax_standards.hpp"

#include <QtPlugin>

using namespace Kiss::Lexer;

Base *ConstructorPython::construct() const
{
return Factory::ref().newLexerFromConstructor(this);
}

Base *ConstructorPython::construct(const QString& apis) const
{
return construct();
}

Base *ConstructorPython::_new() const
{
return new Python(this);
}

void ConstructorPython::_delete(Base *base) const
{
delete base;
}

QStringList ConstructorPython::extensions() const
{
return QStringList() << "py" << "python";
}

ConstructorPython::ConstructorPython()
: Constructor("Python Files")
{
}

Python::Python(const Constructor *constructor)
: Base(new PythonLexer(), constructor)
{
}

Python::~Python()
{
delete lexer();
}

QColor PythonLexer::defaultColor(int style) const
{
    switch (style)
    {
case Default:
case ClassName:
case FunctionMethodName:
case Identifier:
case HighlightedIdentifier:
return Lexer::Settings::ref().getSetting(DEFAULT, SyntaxStandards::defaultColor());

case Comment:
case CommentBlock:
return Lexer::Settings::ref().getSetting(COMMENT, SyntaxStandards::commentColor());

case Number: return Lexer::Settings::ref().getSetting(NUMBER, SyntaxStandards::numberColor());
case Keyword: return Lexer::Settings::ref().getSetting(KEYWORD, SyntaxStandards::keywordColor());

case DoubleQuotedString:
case SingleQuotedString:
case TripleDoubleQuotedString:
case TripleSingleQuotedString:
return Lexer::Settings::ref().getSetting(STRING, SyntaxStandards::stringColor());

case Operator: return Lexer::Settings::ref().getSetting(OPERATOR, SyntaxStandards::operatorColor());
case UnclosedString: return Lexer::Settings::ref().getSetting(UNCLOSED_STRING, SyntaxStandards::unclosedStringColor());
    }

    return QsciLexerPython::defaultColor(style);
}

QFont PythonLexer::font(int style) const
{
QFont f = QsciLexer::font(style);

switch (style)
{
case Keyword:
case Operator:
f.setBold(true);
break;
}

return f;
}

QFont PythonLexer::defaultFont(int style) const
{
QFont f = QsciLexer::defaultFont(style);

switch (style)
{
case Keyword:
case Operator:
f.setBold(true);
break;
}


return f;
}

const bool Python::cStyleBlocks() const
{
return false;
}

Q_EXPORT_PLUGIN2(python_lexer, Kiss::Lexer::ConstructorPython);
Something went wrong with that request. Please try again.