11 |
11 |
12 from PyQt6.QtCore import Qt, pyqtSlot |
12 from PyQt6.QtCore import Qt, pyqtSlot |
13 from PyQt6.QtWidgets import QHeaderView, QTreeWidgetItem, QDialog |
13 from PyQt6.QtWidgets import QHeaderView, QTreeWidgetItem, QDialog |
14 |
14 |
15 from .Ui_LexerAssociationDialog import Ui_LexerAssociationDialog |
15 from .Ui_LexerAssociationDialog import Ui_LexerAssociationDialog |
|
16 |
|
17 import QScintilla.Lexers |
|
18 |
|
19 import UI.PixmapCache |
16 |
20 |
17 |
21 |
18 class LexerAssociationDialog(QDialog, Ui_LexerAssociationDialog): |
22 class LexerAssociationDialog(QDialog, Ui_LexerAssociationDialog): |
19 """ |
23 """ |
20 Class implementing a dialog to enter lexer associations for the project. |
24 Class implementing a dialog to enter lexer associations for the project. |
40 except AttributeError: |
44 except AttributeError: |
41 self.extsep = "." |
45 self.extsep = "." |
42 |
46 |
43 self.extras = ["-----------", self.tr("Alternative")] |
47 self.extras = ["-----------", self.tr("Alternative")] |
44 |
48 |
45 import QScintilla.Lexers |
49 self.editorLexerCombo.addItem("") |
46 languages = ( |
50 self.editorLexerCombo.addItem( |
47 [''] + |
51 UI.PixmapCache.getIcon("fileText"), |
48 sorted(QScintilla.Lexers.getSupportedLanguages().keys()) + |
52 "Text" |
49 self.extras |
|
50 ) |
53 ) |
51 for lang in languages: |
54 for lang in sorted(QScintilla.Lexers.getSupportedLanguages().keys()): |
52 self.editorLexerCombo.addItem( |
55 self.editorLexerCombo.addItem( |
53 QScintilla.Lexers.getLanguageIcon(lang, False), |
56 QScintilla.Lexers.getLanguageIcon(lang, False), |
54 lang) |
57 lang) |
|
58 self.editorLexerCombo.addItems(self.extras) |
55 |
59 |
56 from pygments.lexers import get_all_lexers |
60 from pygments.lexers import get_all_lexers |
57 pygmentsLexers = [''] + sorted(lex[0] for lex in get_all_lexers()) |
61 pygmentsLexers = [''] + sorted(lex[0] for lex in get_all_lexers()) |
58 self.pygmentsLexerCombo.addItems(pygmentsLexers) |
62 self.pygmentsLexerCombo.addItems(pygmentsLexers) |
59 |
63 |