src/eric7/QScintilla/Lexers/LexerCoffeeScript.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a CoffeeScript lexer with some additional methods.
8 """
9
10 from PyQt6.Qsci import QsciLexerCoffeeScript
11
12 from .Lexer import Lexer
13 import Preferences
14
15
16 class LexerCoffeeScript(Lexer, QsciLexerCoffeeScript):
17 """
18 Subclass to implement some additional lexer dependant methods.
19 """
20 def __init__(self, parent=None):
21 """
22 Constructor
23
24 @param parent parent widget of this lexer
25 """
26 QsciLexerCoffeeScript.__init__(self, parent)
27 Lexer.__init__(self)
28
29 self.commentString = "#"
30 self.streamCommentString = {
31 'start': '###\n',
32 'end': '\n###'
33 }
34
35 self.keywordSetDescriptions = [
36 self.tr("Keywords"),
37 self.tr("Secondary keywords"),
38 self.tr("Unused"),
39 self.tr("Global classes"),
40 ]
41
42 def initProperties(self):
43 """
44 Public slot to initialize the properties.
45 """
46 self.setDollarsAllowed(
47 Preferences.getEditor("CoffeeScriptDollarsAllowed"))
48 self.setFoldComments(
49 Preferences.getEditor("CoffeScriptFoldComment"))
50 self.setStylePreprocessor(
51 Preferences.getEditor("CoffeeScriptStylePreprocessor"))
52 self.setFoldCompact(
53 Preferences.getEditor("AllFoldCompact"))
54
55 def isCommentStyle(self, style):
56 """
57 Public method to check, if a style is a comment style.
58
59 @param style style to check (integer)
60 @return flag indicating a comment style (boolean)
61 """
62 return style in [QsciLexerCoffeeScript.Comment,
63 QsciLexerCoffeeScript.CommentDoc,
64 QsciLexerCoffeeScript.CommentLine,
65 QsciLexerCoffeeScript.CommentLineDoc,
66 QsciLexerCoffeeScript.CommentBlock,
67 QsciLexerCoffeeScript.BlockRegexComment]
68
69 def isStringStyle(self, style):
70 """
71 Public method to check, if a style is a string style.
72
73 @param style style to check (integer)
74 @return flag indicating a string style (boolean)
75 """
76 return style in [QsciLexerCoffeeScript.DoubleQuotedString,
77 QsciLexerCoffeeScript.SingleQuotedString,
78 QsciLexerCoffeeScript.UnclosedString,
79 QsciLexerCoffeeScript.VerbatimString]
80
81 def defaultKeywords(self, kwSet):
82 """
83 Public method to get the default keywords.
84
85 @param kwSet number of the keyword set (integer)
86 @return string giving the keywords (string) or None
87 """
88 return QsciLexerCoffeeScript.keywords(self, kwSet)
89
90 def maximumKeywordSet(self):
91 """
92 Public method to get the maximum keyword set.
93
94 @return maximum keyword set (integer)
95 """
96 return 4

eric ide

mercurial