Wed, 23 Oct 2019 19:59:23 +0200
Editor:
- extended the spell checking functionality for all text files
--- a/docs/changelog Wed Oct 23 19:57:49 2019 +0200 +++ b/docs/changelog Wed Oct 23 19:59:23 2019 +0200 @@ -2,6 +2,8 @@ ---------- Version 19.11: - bug fixes +- Editor + -- extended the spell checking functionality for all text files - MicroPython -- added support for PyBoard - Previewers
--- a/eric6/Preferences/ConfigurationPages/EditorSpellCheckingPage.py Wed Oct 23 19:57:49 2019 +0200 +++ b/eric6/Preferences/ConfigurationPages/EditorSpellCheckingPage.py Wed Oct 23 19:59:23 2019 +0200 @@ -55,8 +55,12 @@ self.stringsOnlyCheckBox.setChecked( Preferences.getEditor("SpellCheckStringsOnly")) + self.fullCheckUnknownCheckBox.setChecked( + Preferences.getEditor("FullSpellCheckUnknown")) self.minimumWordSizeSlider.setValue( Preferences.getEditor("SpellCheckingMinWordSize")) + self.spellCheckTextFilesLineEdit.setText( + " ".join(Preferences.getEditor("FullSpellCheckExtensions"))) self.initColour( "SpellingMarkers", self.spellingMarkerButton, @@ -89,7 +93,14 @@ Preferences.setEditor( "SpellCheckStringsOnly", self.stringsOnlyCheckBox.isChecked()) Preferences.setEditor( + "FullSpellCheckUnknown", + self.fullCheckUnknownCheckBox.isChecked()) + Preferences.setEditor( "SpellCheckingMinWordSize", self.minimumWordSizeSlider.value()) + Preferences.setEditor( + "FullSpellCheckExtensions", + [ext.strip() for ext in + self.spellCheckTextFilesLineEdit.text().split()]) self.saveColours(Preferences.setEditorColour)
--- a/eric6/Preferences/ConfigurationPages/EditorSpellCheckingPage.ui Wed Oct 23 19:57:49 2019 +0200 +++ b/eric6/Preferences/ConfigurationPages/EditorSpellCheckingPage.ui Wed Oct 23 19:59:23 2019 +0200 @@ -112,14 +112,28 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QCheckBox" name="stringsOnlyCheckBox"> - <property name="toolTip"> - <string>Select to check strings only</string> - </property> - <property name="text"> - <string>Spell check strings only</string> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QCheckBox" name="stringsOnlyCheckBox"> + <property name="toolTip"> + <string>Select to check strings only</string> + </property> + <property name="text"> + <string>Spell check strings only</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="fullCheckUnknownCheckBox"> + <property name="toolTip"> + <string>Select to perform a complete check of files without extension</string> + </property> + <property name="text"> + <string>Spell check unknown files</string> + </property> + </widget> + </item> + </layout> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout"> @@ -153,7 +167,7 @@ </widget> </item> <item> - <widget class="QLCDNumber" name="lCDNumber"> + <widget class="QLCDNumber" name="lcdNumber"> <property name="toolTip"> <string>Displays the minimum size of words to be checked</string> </property> @@ -170,6 +184,28 @@ </item> </layout> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Textfiles:</string> + </property> + </widget> + </item> + <item> + <widget class="E5ClearableLineEdit" name="spellCheckTextFilesLineEdit"> + <property name="toolTip"> + <string>Enter the file extensions of pure text files (separated by a space)</string> + </property> + <property name="whatsThis"> + <string><b>Textfiles</b> +<p>Enter the file extension of pure text files. The complete contents of files with these extensions will be checked.</p></string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item> @@ -365,12 +401,19 @@ <header>E5Gui/E5PathPicker.h</header> <container>1</container> </customwidget> + <customwidget> + <class>E5ClearableLineEdit</class> + <extends>QLineEdit</extends> + <header>E5Gui/E5LineEdit.h</header> + </customwidget> </customwidgets> <tabstops> <tabstop>checkingEnabledCheckBox</tabstop> <tabstop>defaultLanguageCombo</tabstop> <tabstop>stringsOnlyCheckBox</tabstop> + <tabstop>fullCheckUnknownCheckBox</tabstop> <tabstop>minimumWordSizeSlider</tabstop> + <tabstop>spellCheckTextFilesLineEdit</tabstop> <tabstop>spellingMarkerButton</tabstop> <tabstop>pwlPicker</tabstop> <tabstop>pelPicker</tabstop> @@ -382,7 +425,7 @@ <connection> <sender>minimumWordSizeSlider</sender> <signal>valueChanged(int)</signal> - <receiver>lCDNumber</receiver> + <receiver>lcdNumber</receiver> <slot>display(int)</slot> <hints> <hint type="sourcelabel">
--- a/eric6/QScintilla/Editor.py Wed Oct 23 19:57:49 2019 +0200 +++ b/eric6/QScintilla/Editor.py Wed Oct 23 19:59:23 2019 +0200 @@ -173,7 +173,7 @@ self.dbs = dbs self.taskViewer = tv - self.fileName = fn + self.__setFileName(fn) self.vm = vm self.filetype = filetype self.filetypeByFlag = False @@ -528,6 +528,22 @@ self.SCN_ZOOM.connect(self.__markerMap.update) self.__markerMap.update() + def __setFileName(self, name): + """ + Private method to set the file name of the current file. + + @param name name of the current file + @type str + """ + self.fileName = name + + if self.fileName: + self.__fileNameExtension = ( + os.path.splitext(self.fileName)[1][1:].lower() + ) + else: + self.__fileNameExtension = "" + def __registerImages(self): """ Private method to register images for autocompletion lists. @@ -3261,7 +3277,7 @@ if self.writeFile(fn): if saveas: self.__clearBreakpoints(self.fileName) - self.fileName = fn + self.__setFileName(fn) self.setModified(False) self.setReadOnly(False) self.setWindowTitle(self.fileName) @@ -3318,7 +3334,7 @@ """ self.__clearBreakpoints(fn) - self.fileName = fn + self.__setFileName(fn) self.setWindowTitle(self.fileName) self.__loadEditorConfig() @@ -7617,16 +7633,35 @@ Public method to check, if the given position is within a region, that should be spell checked. - @param pos position to be checked (integer) - @return flag indicating pos is in a spell check region (boolean) + For files with a configured full text file extension all regions will + be regarded as to be checked. Depending on configuration, all unknown + files (i.e. those without a file extension) will be checked fully as + well. + + @param pos position to be checked + @type int + @return flag indicating pos is in a spell check region + @rtype bool """ if self.__spellCheckStringsOnly: - style = self.styleAt(pos) - if self.lexer_ is not None: - return ( - self.lexer_.isCommentStyle(style) or - self.lexer_.isStringStyle(style) - ) + if ( + self.__fileNameExtension in + Preferences.getEditor("FullSpellCheckExtensions") + ): + return True + elif ( + not self.__fileNameExtension and + Preferences.getEditor("FullSpellCheckUnknown") + ): + return True + else: + style = self.styleAt(pos) + if self.lexer_ is not None: + return ( + self.lexer_.isCommentStyle(style) or + self.lexer_.isStringStyle(style) + ) + return True @pyqtSlot(int)