|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2008 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a PostScript lexer with some additional methods. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.Qsci import QsciLexerPostScript |
|
13 |
|
14 from .Lexer import Lexer |
|
15 import Preferences |
|
16 |
|
17 |
|
18 class LexerPostScript(Lexer, QsciLexerPostScript): |
|
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 QsciLexerPostScript.__init__(self, parent) |
|
29 Lexer.__init__(self) |
|
30 |
|
31 self.commentString = "%" |
|
32 |
|
33 self.keywordSetDescriptions = [ |
|
34 self.tr("PS Level 1 operators"), |
|
35 self.tr("PS Level 2 operators"), |
|
36 self.tr("PS Level 3 operators"), |
|
37 self.tr("RIP specific operators"), |
|
38 self.tr("User defined operators"), |
|
39 ] |
|
40 |
|
41 def initProperties(self): |
|
42 """ |
|
43 Public slot to initialize the properties. |
|
44 """ |
|
45 self.setTokenize(Preferences.getEditor("PostScriptTokenize")) |
|
46 self.setLevel(Preferences.getEditor("PostScriptLevel")) |
|
47 self.setFoldAtElse(Preferences.getEditor("PostScriptFoldAtElse")) |
|
48 self.setFoldCompact(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 [QsciLexerPostScript.Comment] |
|
58 |
|
59 def isStringStyle(self, style): |
|
60 """ |
|
61 Public method to check, if a style is a string style. |
|
62 |
|
63 @param style style to check (integer) |
|
64 @return flag indicating a string style (boolean) |
|
65 """ |
|
66 return False |
|
67 |
|
68 def defaultKeywords(self, kwSet): |
|
69 """ |
|
70 Public method to get the default keywords. |
|
71 |
|
72 @param kwSet number of the keyword set (integer) |
|
73 @return string giving the keywords (string) or None |
|
74 """ |
|
75 return QsciLexerPostScript.keywords(self, kwSet) |
|
76 |
|
77 def maximumKeywordSet(self): |
|
78 """ |
|
79 Public method to get the maximum keyword set. |
|
80 |
|
81 @return maximum keyword set (integer) |
|
82 """ |
|
83 return 5 |