8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import QCoreApplication, QObject |
10 from PyQt6.QtCore import QCoreApplication, QObject |
11 from PyQt6.Qsci import QsciScintillaBase |
11 from PyQt6.Qsci import QsciScintillaBase |
12 |
12 |
13 import Preferences |
13 from eric7 import Globals, Preferences |
14 import Globals |
|
15 |
14 |
16 |
15 |
17 class PreferencesLexerError(Exception): |
16 class PreferencesLexerError(Exception): |
18 """ |
17 """ |
19 Class defining a special error for the PreferencesLexer class. |
18 Class defining a special error for the PreferencesLexer class. |
80 @exception PreferencesLexerLanguageError raised to indicate an invalid |
79 @exception PreferencesLexerLanguageError raised to indicate an invalid |
81 lexer language |
80 lexer language |
82 """ |
81 """ |
83 super().__init__(parent) |
82 super().__init__(parent) |
84 |
83 |
85 # These default font families are taken from QScintilla |
84 # These default font families are taken from eric7.QScintilla |
86 if Globals.isWindowsPlatform(): |
85 if Globals.isWindowsPlatform(): |
87 self.__defaultFontFamily = "Courier New" |
86 self.__defaultFontFamily = "Courier New" |
88 elif Globals.isMacPlatform(): |
87 elif Globals.isMacPlatform(): |
89 self.__defaultFontFamily = "Courier" |
88 self.__defaultFontFamily = "Courier" |
90 else: |
89 else: |
91 self.__defaultFontFamily = "Bitstream Vera Sans Mono" |
90 self.__defaultFontFamily = "Bitstream Vera Sans Mono" |
92 |
91 |
93 # instantiate a lexer object for the given language |
92 # instantiate a lexer object for the given language |
94 import QScintilla.Lexers |
93 from eric7.QScintilla import Lexers |
95 |
94 |
96 self.__lex = QScintilla.Lexers.getLexer(language) |
95 self.__lex = Lexers.getLexer(language) |
97 if self.__lex is None: |
96 if self.__lex is None: |
98 raise PreferencesLexerLanguageError(language) |
97 raise PreferencesLexerLanguageError(language) |
99 |
98 |
100 # read the last stored values from preferences file |
99 # read the last stored values from preferences file |
101 self.__lex.readSettings(Preferences.getSettings(), "Scintilla") |
100 self.__lex.readSettings(Preferences.getSettings(), "Scintilla") |