--- a/QScintilla/Lexers/LexerPython.py Sat Mar 09 10:04:18 2019 +0100 +++ b/QScintilla/Lexers/LexerPython.py Sat Mar 09 17:36:44 2019 +0100 @@ -11,13 +11,14 @@ import re +from PyQt5.QtCore import QCoreApplication from PyQt5.Qsci import QsciLexerPython, QsciScintilla -from .Lexer import Lexer +from .SubstyledLexer import SubstyledLexer import Preferences -class LexerPython(Lexer, QsciLexerPython): +class LexerPython(SubstyledLexer, QsciLexerPython): """ Subclass to implement some additional lexer dependant methods. """ @@ -29,10 +30,65 @@ @param parent parent widget of this lexer """ QsciLexerPython.__init__(self, parent) - Lexer.__init__(self) + SubstyledLexer.__init__(self) self.variant = variant self.commentString = "#" + + ############################################################## + ## default sub-style definitions + ############################################################## + + # list of style numbers, that support sub-styling + self.baseStyles = [11] + + self.defaultSubStyles = { + 11: { + "SubStyleLength": 2, + "SubStyles": [ + { + "Description": QCoreApplication.translate( + "LexerPython", "Standard Library Modules"), + "Words": """ +__main__ _dummy_thread _thread abc aifc argparse array ast asynchat asyncio + asyncore atexit audioop base64 bdb binascii binhex bisect builtins bz2 + calendar cgi cgitb chunk cmath cmd code codecs codeop collections colorsys + compileall concurrent configparser contextlib copy copyreg crypt csv ctypes + curses datetime dbm decimal difflib dis distutils dummy_threading email + ensurepip enum errno faulthandler fcntl filecmp fileinput fnmatch formatter + fpectl fractions ftplib functools gc getopt getpass gettext glob grp gzip + hashlib heapq hmac html http http imaplib imghdr importlib inspect io + ipaddress itertools json keyword linecache locale logging lzma macpath + mailbox mailcap marshal math mimetypes mmap modulefinder msilib msvcrt + multiprocessing netrc nis nntplib numbers operator os os.path ossaudiodev + parser pathlib pdb pickle pickletools pipes pkgutil platform plistlib + poplib posix pprint pty pwd py_compile pyclbr queue quopri random re readline + reprlib resource rlcompleter runpy sched select selectors shelve shlex shutil + signal site smtpd smtplib sndhdr socket socketserver spwd sqlite3 ssl stat + statistics string stringprep struct subprocess sunau symbol symtable sys + sysconfig syslog tabnanny tarfile telnetlib tempfile termios textwrap + threading time timeit tkinter token tokenize trace traceback tracemalloc tty + turtle types unicodedata unittest urllib uu uuid venv warnings wave weakref + webbrowser winreg winsound wsgiref xdrlib xml xmlrpc zipfile zipimport + zlib""", + "Style": { + "fore": 0xDD9900, + } + }, + { + "Description": QCoreApplication.translate( + "LexerPython", "__future__ Imports"), + "Words": """ +__future__ with_statement unicode_literals print_function division + absolute_import generator_stop annotations""", + "Style": { + "fore": 0xEE00AA, + "font_italic": True, + } + } + ] + }, + } def language(self): """