QScintilla/Lexers/LexerJSON.py

changeset 5420
53ca6ddb4acf
child 6048
82ad8ec9548c
equal deleted inserted replaced
5419:6f7a196d25da 5420:53ca6ddb4acf
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2017 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a JSON lexer with some additional methods.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.Qsci import QsciLexerJSON
13
14 from .Lexer import Lexer
15 import Preferences
16
17
18 class LexerJSON(Lexer, QsciLexerJSON):
19 """
20 Subclass to implement some additional lexer dependent methods.
21 """
22 def __init__(self, parent=None):
23 """
24 Constructor
25
26 @param parent parent widget of this lexer
27 """
28 QsciLexerJSON.__init__(self, parent)
29 Lexer.__init__(self)
30
31 self.commentString = "//"
32 self.streamCommentString = {
33 'start': '/* ',
34 'end': ' */'
35 }
36
37 def initProperties(self):
38 """
39 Public slot to initialize the properties.
40 """
41 self.setHighlightComments(
42 Preferences.getEditor("JSONHightlightComments"))
43 self.setHighlightEscapeSequences(
44 Preferences.getEditor("JSONHighlightEscapeSequences"))
45 self.setFoldCompact(
46 Preferences.getEditor("AllFoldCompact"))
47
48 def isCommentStyle(self, style):
49 """
50 Public method to check, if a style is a comment style.
51
52 @param style style to check (integer)
53 @return flag indicating a comment style (boolean)
54 """
55 return style in [QsciLexerJSON.CommentLine,
56 QsciLexerJSON.CommentBlock]
57
58 def isStringStyle(self, style):
59 """
60 Public method to check, if a style is a string style.
61
62 @param style style to check (integer)
63 @return flag indicating a string style (boolean)
64 """
65 return style in [QsciLexerJSON.String,
66 QsciLexerJSON.UnclosedString]
67
68 def defaultKeywords(self, kwSet):
69 """
70 Public method to get the default keywords.
71
72 @param kwSet number of the keyword set (integer)
73 @return string giving the keywords (string) or None
74 """
75 return QsciLexerJSON.keywords(self, kwSet)
76
77 def maximumKeywordSet(self):
78 """
79 Public method to get the maximum keyword set.
80
81 @return maximum keyword set (integer)
82 """
83 return 2

eric ide

mercurial