eric6/QScintilla/Lexers/LexerContainer.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2008 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a base class for custom lexers.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.Qsci import QsciLexer
13
14 from .Lexer import Lexer
15
16
17 class LexerContainer(Lexer, QsciLexer):
18 """
19 Subclass as a base for the implementation of custom lexers.
20 """
21 def __init__(self, parent=None):
22 """
23 Constructor
24
25 @param parent parent widget of this lexer
26 """
27 QsciLexer.__init__(self, parent)
28 Lexer.__init__(self)
29
30 self.editor = parent
31
32 def language(self):
33 """
34 Public method returning the language of the lexer.
35
36 @return language of the lexer (string)
37 """
38 return "Container"
39
40 def lexer(self):
41 """
42 Public method returning the type of the lexer.
43
44 @return type of the lexer (string)
45 """
46 if hasattr(self, 'lexerId'):
47 return None
48 else:
49 return "container"
50
51 def description(self, style):
52 """
53 Public method returning the descriptions of the styles supported
54 by the lexer.
55
56 <b>Note</b>: This methods needs to be overridden by the lexer class.
57
58 @param style style number (integer)
59 @return description for the given style (string)
60 """
61 return ""
62
63 def styleText(self, start, end):
64 """
65 Public method to perform the styling.
66
67 @param start position of first character to be styled (integer)
68 @param end position of last character to be styled (integer)
69 """
70 self.editor.startStyling(start, 0x1f)
71 self.editor.setStyling(end - start + 1, 0)
72
73 def keywords(self, kwSet):
74 """
75 Public method to get the keywords.
76
77 @param kwSet number of the keyword set (integer)
78 @return string giving the keywords (string) or None
79 """
80 return Lexer.keywords(self, kwSet)

eric ide

mercurial