7 Module implementing a dialog to enter lexer associations for the project. |
7 Module implementing a dialog to enter lexer associations for the project. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
|
12 from pygments.lexers import get_all_lexers |
12 from PyQt6.QtCore import Qt, pyqtSlot |
13 from PyQt6.QtCore import Qt, pyqtSlot |
13 from PyQt6.QtWidgets import QDialog, QHeaderView, QTreeWidgetItem |
14 from PyQt6.QtWidgets import QDialog, QHeaderView, QTreeWidgetItem |
14 |
15 |
15 from eric7.EricGui import EricPixmapCache |
16 from eric7.EricGui import EricPixmapCache |
16 from eric7.QScintilla import Lexers |
17 from eric7.QScintilla import Lexers |
38 ) |
39 ) |
39 header = self.editorLexerList.header() |
40 header = self.editorLexerList.header() |
40 header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents) |
41 header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents) |
41 header.setSortIndicator(0, Qt.SortOrder.AscendingOrder) |
42 header.setSortIndicator(0, Qt.SortOrder.AscendingOrder) |
42 |
43 |
43 try: |
44 self.extsep = os.extsep |
44 self.extsep = os.extsep |
|
45 except AttributeError: |
|
46 self.extsep = "." |
|
47 |
|
48 self.extras = ["-----------", self.tr("Alternative")] |
45 self.extras = ["-----------", self.tr("Alternative")] |
49 |
46 |
50 self.editorLexerCombo.addItem("") |
47 self.editorLexerCombo.addItem("") |
51 self.editorLexerCombo.addItem(EricPixmapCache.getIcon("fileText"), "Text") |
48 self.editorLexerCombo.addItem(EricPixmapCache.getIcon("fileText"), "Text") |
52 for lang in sorted(Lexers.getSupportedLanguages().keys()): |
49 for lang in sorted(Lexers.getSupportedLanguages().keys()): |
53 self.editorLexerCombo.addItem(Lexers.getLanguageIcon(lang, False), lang) |
50 self.editorLexerCombo.addItem(Lexers.getLanguageIcon(lang, False), lang) |
54 self.editorLexerCombo.addItems(self.extras) |
51 self.editorLexerCombo.addItems(self.extras) |
55 |
|
56 from pygments.lexers import get_all_lexers |
|
57 |
52 |
58 pygmentsLexers = [""] + sorted(lex[0] for lex in get_all_lexers()) |
53 pygmentsLexers = [""] + sorted(lex[0] for lex in get_all_lexers()) |
59 self.pygmentsLexerCombo.addItems(pygmentsLexers) |
54 self.pygmentsLexerCombo.addItems(pygmentsLexers) |
60 |
55 |
61 # set initial values |
56 # set initial values |