--- a/src/eric7/Project/LexerAssociationDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Project/LexerAssociationDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -23,10 +23,11 @@ """ Class implementing a dialog to enter lexer associations for the project. """ + def __init__(self, project, parent=None): """ Constructor - + @param project reference to the project object @param parent reference to the parent widget (QWidget) """ @@ -34,39 +35,38 @@ self.setupUi(self) self.editorLexerList.headerItem().setText( - self.editorLexerList.columnCount(), "") + self.editorLexerList.columnCount(), "" + ) header = self.editorLexerList.header() header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents) header.setSortIndicator(0, Qt.SortOrder.AscendingOrder) - + try: self.extsep = os.extsep except AttributeError: self.extsep = "." - + self.extras = ["-----------", self.tr("Alternative")] - + self.editorLexerCombo.addItem("") - self.editorLexerCombo.addItem( - UI.PixmapCache.getIcon("fileText"), - "Text" - ) + self.editorLexerCombo.addItem(UI.PixmapCache.getIcon("fileText"), "Text") for lang in sorted(QScintilla.Lexers.getSupportedLanguages().keys()): self.editorLexerCombo.addItem( - QScintilla.Lexers.getLanguageIcon(lang, False), - lang) + QScintilla.Lexers.getLanguageIcon(lang, False), lang + ) self.editorLexerCombo.addItems(self.extras) - + from pygments.lexers import get_all_lexers - pygmentsLexers = [''] + sorted(lex[0] for lex in get_all_lexers()) + + pygmentsLexers = [""] + sorted(lex[0] for lex in get_all_lexers()) self.pygmentsLexerCombo.addItems(pygmentsLexers) - + # set initial values self.project = project for ext, lexer in list(self.project.pdata["LEXERASSOCS"].items()): QTreeWidgetItem(self.editorLexerList, [ext, lexer]) self.editorLexerList.sortByColumn(0, Qt.SortOrder.AscendingOrder) - + @pyqtSlot() def on_addLexerButton_clicked(self): """ @@ -83,8 +83,7 @@ else: lexer = "Pygments|{0}".format(pygmentsLexer) if ext and lexer: - itmList = self.editorLexerList.findItems( - ext, Qt.MatchFlag.MatchExactly, 0) + itmList = self.editorLexerList.findItems(ext, Qt.MatchFlag.MatchExactly, 0) if itmList: index = self.editorLexerList.indexOfTopLevelItem(itmList[0]) itm = self.editorLexerList.takeTopLevelItem(index) @@ -96,8 +95,9 @@ self.pygmentsLexerCombo.setCurrentIndex(0) self.editorLexerList.sortItems( self.editorLexerList.sortColumn(), - self.editorLexerList.header().sortIndicatorOrder()) - + self.editorLexerList.header().sortIndicatorOrder(), + ) + @pyqtSlot() def on_deleteLexerButton_clicked(self): """ @@ -110,16 +110,16 @@ itm = self.editorLexerList.takeTopLevelItem(index) # __IGNORE_WARNING__ del itm - + self.editorLexerList.clearSelection() self.editorFileExtEdit.clear() self.editorLexerCombo.setCurrentIndex(0) - + def on_editorLexerList_itemClicked(self, itm, column): """ Private slot to handle the clicked signal of the lexer association list. - + @param itm reference to the selecte item (QTreeWidgetItem) @param column column the item was clicked or activated (integer) (ignored) @@ -140,23 +140,23 @@ index = self.editorLexerCombo.findText(lexer) self.editorLexerCombo.setCurrentIndex(index) self.pygmentsLexerCombo.setCurrentIndex(pygmentsIndex) - + def on_editorLexerList_itemActivated(self, itm, column): """ Private slot to handle the activated signal of the lexer association list. - + @param itm reference to the selecte item (QTreeWidgetItem) @param column column the item was clicked or activated (integer) (ignored) """ self.on_editorLexerList_itemClicked(itm, column) - + @pyqtSlot(int) def on_editorLexerCombo_currentIndexChanged(self, index): """ Private slot to handle the selection of a lexer. - + @param index index of the current item @type int """