eric6/QScintilla/Lexers/LexerRuby.py

changeset 6942
2602857055c5
parent 6874
5a3a39442711
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2005 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a Ruby lexer with some additional methods.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.Qsci import QsciLexerRuby
13
14 from .Lexer import Lexer
15 import Preferences
16
17
18 class LexerRuby(Lexer, QsciLexerRuby):
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 QsciLexerRuby.__init__(self, parent)
29 Lexer.__init__(self)
30
31 self.commentString = "#"
32
33 self.keywordSetDescriptions = [
34 self.tr("Keywords"),
35 ]
36
37 def initProperties(self):
38 """
39 Public slot to initialize the properties.
40 """
41 try:
42 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
43 self.setFoldComments(Preferences.getEditor("RubyFoldComment"))
44 except AttributeError:
45 pass
46
47 def autoCompletionWordSeparators(self):
48 """
49 Public method to return the list of separators for autocompletion.
50
51 @return list of separators (list of strings)
52 """
53 return ['.']
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 [QsciLexerRuby.Comment]
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 [QsciLexerRuby.DoubleQuotedString,
72 QsciLexerRuby.HereDocument,
73 QsciLexerRuby.PercentStringQ,
74 QsciLexerRuby.PercentStringq,
75 QsciLexerRuby.PercentStringr,
76 QsciLexerRuby.PercentStringw,
77 QsciLexerRuby.PercentStringx,
78 QsciLexerRuby.SingleQuotedString]
79
80 def defaultKeywords(self, kwSet):
81 """
82 Public method to get the default keywords.
83
84 @param kwSet number of the keyword set (integer)
85 @return string giving the keywords (string) or None
86 """
87 return QsciLexerRuby.keywords(self, kwSet)

eric ide

mercurial