7 Module implementing the editor highlighter keywords configuration page. |
7 Module implementing the editor highlighter keywords configuration page. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import pyqtSlot |
10 from PyQt6.QtCore import pyqtSlot |
11 |
11 |
12 from EricWidgets import EricMessageBox |
12 from eric7.EricWidgets import EricMessageBox |
13 |
13 |
14 from .ConfigurationPageBase import ConfigurationPageBase |
14 from .ConfigurationPageBase import ConfigurationPageBase |
15 from .Ui_EditorKeywordsPage import Ui_EditorKeywordsPage |
15 from .Ui_EditorKeywordsPage import Ui_EditorKeywordsPage |
16 |
16 |
17 import Preferences |
17 from eric7 import Preferences |
18 |
18 |
19 |
19 |
20 class EditorKeywordsPage(ConfigurationPageBase, Ui_EditorKeywordsPage): |
20 class EditorKeywordsPage(ConfigurationPageBase, Ui_EditorKeywordsPage): |
21 """ |
21 """ |
22 Class implementing the editor highlighter keywords configuration page. |
22 Class implementing the editor highlighter keywords configuration page. |
31 super().__init__() |
31 super().__init__() |
32 self.setupUi(self) |
32 self.setupUi(self) |
33 self.setObjectName("EditorKeywordsPage") |
33 self.setObjectName("EditorKeywordsPage") |
34 |
34 |
35 # set initial values |
35 # set initial values |
36 import QScintilla.Lexers |
36 from eric7.QScintilla import Lexers |
37 from QScintilla.Lexers.LexerContainer import LexerContainer |
37 from eric7.QScintilla.Lexers.LexerContainer import LexerContainer |
38 |
38 |
39 self.__keywords = { |
39 self.__keywords = { |
40 "": { |
40 "": { |
41 "Sets": [""] * (self.MaxKeywordSets + 1), |
41 "Sets": [""] * (self.MaxKeywordSets + 1), |
42 "Descriptions": [""] * (self.MaxKeywordSets + 1), |
42 "Descriptions": [""] * (self.MaxKeywordSets + 1), |
43 "MaxSets": 0, |
43 "MaxSets": 0, |
44 } |
44 } |
45 } |
45 } |
46 |
46 |
47 languages = sorted( |
47 languages = sorted([""] + list(Lexers.getSupportedLanguages().keys())) |
48 [""] + list(QScintilla.Lexers.getSupportedLanguages().keys()) |
|
49 ) |
|
50 for lang in languages: |
48 for lang in languages: |
51 if lang: |
49 if lang: |
52 lex = QScintilla.Lexers.getLexer(lang) |
50 lex = Lexers.getLexer(lang) |
53 if isinstance(lex, LexerContainer): |
51 if isinstance(lex, LexerContainer): |
54 continue |
52 continue |
55 keywords = Preferences.getEditorKeywords(lang)[:] |
53 keywords = Preferences.getEditorKeywords(lang)[:] |
56 if keywords: |
54 if keywords: |
57 # set empty entries to default values |
55 # set empty entries to default values |
83 "Sets": keywords, |
81 "Sets": keywords, |
84 "Descriptions": descriptions, |
82 "Descriptions": descriptions, |
85 "DefaultSets": defaults, |
83 "DefaultSets": defaults, |
86 "MaxSets": lex.maximumKeywordSet(), |
84 "MaxSets": lex.maximumKeywordSet(), |
87 } |
85 } |
88 self.languageCombo.addItem( |
86 self.languageCombo.addItem(Lexers.getLanguageIcon(lang, False), lang) |
89 QScintilla.Lexers.getLanguageIcon(lang, False), lang |
|
90 ) |
|
91 |
87 |
92 self.currentLanguage = "" |
88 self.currentLanguage = "" |
93 self.currentSet = 1 |
89 self.currentSet = 1 |
94 self.on_languageCombo_activated(0) |
90 self.on_languageCombo_activated(0) |
95 |
91 |