Wed, 13 Jul 2022 14:55:47 +0200
Reformatted the source code using the 'Black' utility.
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
3 | # Copyright (c) 2014 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a Gettext lexer with some additional methods. |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
10 | from PyQt6.Qsci import QsciLexerPO |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from .Lexer import Lexer |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | import Preferences |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | class LexerPO(Lexer, QsciLexerPO): |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | Subclass to implement some additional lexer dependant methods. |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | def __init__(self, parent=None): |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | @param parent parent widget of this lexer |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | QsciLexerPO.__init__(self, parent) |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | Lexer.__init__(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
29 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | self.commentString = "#" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
31 | |
6874
5a3a39442711
Lexers: extended the keyword set handling by introducing a keyword set description and some set adjustments (harmonized with SciTE).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6645
diff
changeset
|
32 | self.keywordSetDescriptions = [] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
33 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | def initProperties(self): |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | Public slot to initialize the properties. |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.setFoldComments(Preferences.getEditor("PoFoldComment")) |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | def isCommentStyle(self, style): |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | Public method to check, if a style is a comment style. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | @param style style to check (integer) |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | @return flag indicating a comment style (boolean) |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | return style in [QsciLexerPO.Comment, QsciLexerPO.ProgrammerComment] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | def isStringStyle(self, style): |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | Public method to check, if a style is a string style. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | @param style style to check (integer) |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @return flag indicating a string style (boolean) |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | return style in [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | QsciLexerPO.MessageIdText, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | QsciLexerPO.MessageStringText, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | QsciLexerPO.MessageContextText, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | ] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | def defaultKeywords(self, kwSet): |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | Public method to get the default keywords. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | |
3557
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | @param kwSet number of the keyword set (integer) |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | @return string giving the keywords (string) or None |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | """ |
3ea8ba471d96
Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | return QsciLexerPO.keywords(self, kwSet) |