QScintilla/Lexers/LexerPython.py

branch
sub_styles
changeset 6845
4680adb641e0
parent 6645
ad476851d7e0
child 6846
6ca9ef2c0907
equal deleted inserted replaced
6844:d706eb5bc040 6845:4680adb641e0
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import re 12 import re
13 13
14 from PyQt5.QtCore import QCoreApplication
14 from PyQt5.Qsci import QsciLexerPython, QsciScintilla 15 from PyQt5.Qsci import QsciLexerPython, QsciScintilla
15 16
16 from .Lexer import Lexer 17 from .SubstyledLexer import SubstyledLexer
17 import Preferences 18 import Preferences
18 19
19 20
20 class LexerPython(Lexer, QsciLexerPython): 21 class LexerPython(SubstyledLexer, QsciLexerPython):
21 """ 22 """
22 Subclass to implement some additional lexer dependant methods. 23 Subclass to implement some additional lexer dependant methods.
23 """ 24 """
24 def __init__(self, variant="", parent=None): 25 def __init__(self, variant="", parent=None):
25 """ 26 """
27 28
28 @param variant name of the language variant (string) 29 @param variant name of the language variant (string)
29 @param parent parent widget of this lexer 30 @param parent parent widget of this lexer
30 """ 31 """
31 QsciLexerPython.__init__(self, parent) 32 QsciLexerPython.__init__(self, parent)
32 Lexer.__init__(self) 33 SubstyledLexer.__init__(self)
33 34
34 self.variant = variant 35 self.variant = variant
35 self.commentString = "#" 36 self.commentString = "#"
37
38 ##############################################################
39 ## default sub-style definitions
40 ##############################################################
41
42 # list of style numbers, that support sub-styling
43 self.baseStyles = [11]
44
45 self.defaultSubStyles = {
46 11: {
47 "SubStyleLength": 2,
48 "SubStyles": [
49 {
50 "Description": QCoreApplication.translate(
51 "LexerPython", "Standard Library Modules"),
52 "Words": """
53 __main__ _dummy_thread _thread abc aifc argparse array ast asynchat asyncio
54 asyncore atexit audioop base64 bdb binascii binhex bisect builtins bz2
55 calendar cgi cgitb chunk cmath cmd code codecs codeop collections colorsys
56 compileall concurrent configparser contextlib copy copyreg crypt csv ctypes
57 curses datetime dbm decimal difflib dis distutils dummy_threading email
58 ensurepip enum errno faulthandler fcntl filecmp fileinput fnmatch formatter
59 fpectl fractions ftplib functools gc getopt getpass gettext glob grp gzip
60 hashlib heapq hmac html http http imaplib imghdr importlib inspect io
61 ipaddress itertools json keyword linecache locale logging lzma macpath
62 mailbox mailcap marshal math mimetypes mmap modulefinder msilib msvcrt
63 multiprocessing netrc nis nntplib numbers operator os os.path ossaudiodev
64 parser pathlib pdb pickle pickletools pipes pkgutil platform plistlib
65 poplib posix pprint pty pwd py_compile pyclbr queue quopri random re readline
66 reprlib resource rlcompleter runpy sched select selectors shelve shlex shutil
67 signal site smtpd smtplib sndhdr socket socketserver spwd sqlite3 ssl stat
68 statistics string stringprep struct subprocess sunau symbol symtable sys
69 sysconfig syslog tabnanny tarfile telnetlib tempfile termios textwrap
70 threading time timeit tkinter token tokenize trace traceback tracemalloc tty
71 turtle types unicodedata unittest urllib uu uuid venv warnings wave weakref
72 webbrowser winreg winsound wsgiref xdrlib xml xmlrpc zipfile zipimport
73 zlib""",
74 "Style": {
75 "fore": 0xDD9900,
76 }
77 },
78 {
79 "Description": QCoreApplication.translate(
80 "LexerPython", "__future__ Imports"),
81 "Words": """
82 __future__ with_statement unicode_literals print_function division
83 absolute_import generator_stop annotations""",
84 "Style": {
85 "fore": 0xEE00AA,
86 "font_italic": True,
87 }
88 }
89 ]
90 },
91 }
36 92
37 def language(self): 93 def language(self):
38 """ 94 """
39 Public method to get the lexer language. 95 Public method to get the lexer language.
40 96

eric ide

mercurial