QScintilla/Lexers/LexerCoffeeScript.py

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

eric ide

mercurial