|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a SQL lexer with some additional methods. |
|
8 """ |
|
9 |
|
10 from PyQt4.Qsci import QsciLexerSQL |
|
11 |
|
12 from Lexer import Lexer |
|
13 import Preferences |
|
14 |
|
15 class LexerSQL(QsciLexerSQL, Lexer): |
|
16 """ |
|
17 Subclass to implement some additional lexer dependant methods. |
|
18 """ |
|
19 def __init__(self, parent=None): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param parent parent widget of this lexer |
|
24 """ |
|
25 QsciLexerSQL.__init__(self, parent) |
|
26 Lexer.__init__(self) |
|
27 |
|
28 def initProperties(self): |
|
29 """ |
|
30 Public slot to initialize the properties. |
|
31 """ |
|
32 self.setFoldComments(Preferences.getEditor("SqlFoldComment")) |
|
33 self.setBackslashEscapes(Preferences.getEditor("SqlBackslashEscapes")) |
|
34 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
|
35 |
|
36 def isCommentStyle(self, style): |
|
37 """ |
|
38 Public method to check, if a style is a comment style. |
|
39 |
|
40 @return flag indicating a comment style (boolean) |
|
41 """ |
|
42 return style in [QsciLexerSQL.Comment, |
|
43 QsciLexerSQL.CommentDoc, |
|
44 QsciLexerSQL.CommentLine, |
|
45 QsciLexerSQL.CommentLineHash] |
|
46 |
|
47 def isStringStyle(self, style): |
|
48 """ |
|
49 Public method to check, if a style is a string style. |
|
50 |
|
51 @return flag indicating a string style (boolean) |
|
52 """ |
|
53 return style in [QsciLexerSQL.DoubleQuotedString, |
|
54 QsciLexerSQL.SingleQuotedString] |