Tue, 10 Aug 2021 21:07:19 +0200
Added the capability to suppress syntax highlighting by associating the file type 'Text'.
--- a/docs/changelog Wed Aug 04 15:35:49 2021 +0200 +++ b/docs/changelog Tue Aug 10 21:07:19 2021 +0200 @@ -1,6 +1,12 @@ Change Log ---------- -Version 21.8: +Version 22.1: +- bug fixes +- first release of eric7 (i.e. the PyQt6 port of eric6) +- added the capability to suppress syntax highlighting by associating + the file type 'Text' + +Version 21.9: - bug fixes - MicroPython -- extended the list of known CircuitPython and UF2 capable devices
--- a/eric7/Preferences/ConfigurationPages/EditorHighlightersPage.py Wed Aug 04 15:35:49 2021 +0200 +++ b/eric7/Preferences/ConfigurationPages/EditorHighlightersPage.py Tue Aug 10 21:07:19 2021 +0200 @@ -18,6 +18,7 @@ from .Ui_EditorHighlightersPage import Ui_EditorHighlightersPage import Preferences +import UI.PixmapCache class EditorHighlightersPage(ConfigurationPageBase, Ui_EditorHighlightersPage): @@ -47,11 +48,17 @@ import QScintilla.Lexers self.extras = ["-----------", self.tr("Alternative")] - languages = [''] + sorted(lexers.keys()) + self.extras - for lang in languages: + self.editorLexerCombo.addItem("") + self.editorLexerCombo.addItem( + UI.PixmapCache.getIcon("fileText"), + "Text" + ) + for lang in sorted(lexers.keys()): self.editorLexerCombo.addItem( QScintilla.Lexers.getLanguageIcon(lang, False), - lang) + lang + ) + self.editorLexerCombo.addItems(self.extras) pygmentsLexers = [''] + sorted(lex[0] for lex in get_all_lexers()) self.pygmentsLexerCombo.addItems(pygmentsLexers)
--- a/eric7/Project/LexerAssociationDialog.py Wed Aug 04 15:35:49 2021 +0200 +++ b/eric7/Project/LexerAssociationDialog.py Tue Aug 10 21:07:19 2021 +0200 @@ -14,6 +14,10 @@ from .Ui_LexerAssociationDialog import Ui_LexerAssociationDialog +import QScintilla.Lexers + +import UI.PixmapCache + class LexerAssociationDialog(QDialog, Ui_LexerAssociationDialog): """ @@ -42,16 +46,16 @@ self.extras = ["-----------", self.tr("Alternative")] - import QScintilla.Lexers - languages = ( - [''] + - sorted(QScintilla.Lexers.getSupportedLanguages().keys()) + - self.extras + self.editorLexerCombo.addItem("") + self.editorLexerCombo.addItem( + UI.PixmapCache.getIcon("fileText"), + "Text" ) - for lang in languages: + for lang in sorted(QScintilla.Lexers.getSupportedLanguages().keys()): self.editorLexerCombo.addItem( 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())
--- a/eric7/QScintilla/Editor.py Wed Aug 04 15:35:49 2021 +0200 +++ b/eric7/QScintilla/Editor.py Tue Aug 10 21:07:19 2021 +0200 @@ -1088,7 +1088,7 @@ self.languagesActGrp = QActionGroup(self) self.noLanguageAct = menu.addAction( UI.PixmapCache.getIcon("fileText"), - self.tr("No Language")) + self.tr("Text")) self.noLanguageAct.setCheckable(True) self.noLanguageAct.setData("None") self.languagesActGrp.addAction(self.noLanguageAct) @@ -1538,7 +1538,8 @@ (self.lexer_.lexer() == "container" or self.lexer_.lexer() is None) ): - self.SCN_STYLENEEDED.disconnect(self.__styleNeeded) + with contextlib.suppress(TypeError): + self.SCN_STYLENEEDED.disconnect(self.__styleNeeded) self.apiLanguage = "" self.lexer_ = None @@ -1551,7 +1552,8 @@ self.__setTextDisplay() self.__setMarginsDisplay() self.setMonospaced(useMonospaced) - self.menuActs["MonospacedFont"].setChecked(self.useMonospaced) + with contextlib.suppress(AttributeError): + self.menuActs["MonospacedFont"].setChecked(self.useMonospaced) self.__docstringGenerator = None @@ -1780,6 +1782,11 @@ language = self.project.getEditorLexerAssoc(basename) if not language: language = Preferences.getEditorLexerAssoc(basename) + if language == "Text": + # no highlighting for plain text files + self.__resetLanguage() + return + if not language: bindName = self.__bindName(self.text(0)) if bindName: