Sat, 16 Mar 2019 18:38:01 +0100
Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
--- a/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Sat Mar 16 14:11:43 2019 +0100 +++ b/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Sat Mar 16 18:38:01 2019 +0100 @@ -12,15 +12,18 @@ from PyQt5.QtCore import pyqtSlot, Qt, QFileInfo, QFile, QIODevice from PyQt5.QtGui import QPalette, QFont from PyQt5.QtWidgets import QColorDialog, QFontDialog, QInputDialog, QMenu, \ - QTreeWidgetItem + QTreeWidgetItem, QDialog from .ConfigurationPageBase import ConfigurationPageBase from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage +from ..SubstyleDefinitionDialog import SubstyleDefinitionDialog from E5Gui import E5MessageBox, E5FileDialog from Globals import qVersionTuple +import UI.PixmapCache + try: MonospacedFontsOption = QFontDialog.MonospacedFonts except AttributeError: @@ -51,6 +54,11 @@ self.setupUi(self) self.setObjectName("EditorHighlightingStylesPage") + self.addSubstyleButton.setIcon(UI.PixmapCache.getIcon("plus")) + self.deleteSubstyleButton.setIcon(UI.PixmapCache.getIcon("minus")) + self.editSubstyleButton.setIcon(UI.PixmapCache.getIcon("edit")) + self.copySubstyleButton.setIcon(UI.PixmapCache.getIcon("editCopy")) + if qVersionTuple() < (5, 0, 0): self.monospacedButton.setChecked(False) self.monospacedButton.hide() @@ -229,6 +237,13 @@ self.sampleText.setPalette(pl) self.sampleText.repaint() self.eolfillCheckBox.setChecked(eolfill) + + selectedOne = len(self.styleElementList.selectedItems()) == 1 + self.addSubstyleButton.setEnabled( + selectedOne and substyle < 0 and self.lexer.isBaseStyle(style)) + self.deleteSubstyleButton.setEnabled(selectedOne and substyle >= 0) + self.editSubstyleButton.setEnabled(selectedOne and substyle >= 0) + self.copySubstyleButton.setEnabled(selectedOne and substyle >= 0) @pyqtSlot() def on_foregroundButton_clicked(self): @@ -633,6 +648,100 @@ parent = self.styleElementList.topLevelItem(parentIndex) itm = parent.child(index) self.styleElementList.setCurrentItem(itm) + + ####################################################################### + ## Methods to add, delete and edit sub-styles and their definitions + ####################################################################### + + @pyqtSlot() + def on_addSubstyleButton_clicked(self): + """ + Private slot to add a new sub-style. + """ + style, substyle = self.__currentStyles() + dlg = SubstyleDefinitionDialog( + self.lexer, style, substyle, parent=self) + if dlg.exec_() == QDialog.Accepted: + description, words = dlg.getData() + substyle = self.lexer.addSubstyle(style) + self.lexer.setDescription(description, style, substyle) + self.lexer.setWords(words, style, substyle) + + parent = self.styleElementList.findItems( + self.lexer.description(style), Qt.MatchExactly)[0] + parent.setExpanded(True) + itm = QTreeWidgetItem(parent, [description]) + itm.setData(0, self.StyleRole, style) + itm.setData(0, self.SubstyleRole, substyle) + self.__styleOneItem(itm, style, substyle) + + @pyqtSlot() + def on_deleteSubstyleButton_clicked(self): + """ + Private slot to delete the selected sub-style. + """ + style, substyle = self.__currentStyles() + ok = E5MessageBox.yesNo( + self, + self.tr("Delete Sub-Style"), + self.tr("""<p>Shall the sub-style <b>{0}</b> really be""" + """ deleted?</p>""").format( + self.lexer.description(style, substyle)) + ) + if ok: + self.lexer.delSubstyle(style, substyle) + + itm = self.styleElementList.currentItem() + parent = itm.parent() + index = parent.indexOfChild(itm) + parent.takeChild(index) + del itm + + @pyqtSlot() + def on_editSubstyleButton_clicked(self): + """ + Private slot to edit the selected sub-style entry. + """ + style, substyle = self.__currentStyles() + dlg = SubstyleDefinitionDialog( + self.lexer, style, substyle, parent=self) + if dlg.exec_() == QDialog.Accepted: + description, words = dlg.getData() + self.lexer.setDescription(description, style, substyle) + self.lexer.setWords(words, style, substyle) + + itm = self.styleElementList.currentItem() + itm.setText(0, description) + + @pyqtSlot() + def on_copySubstyleButton_clicked(self): + """ + Private slot to copy the selected sub-style. + """ + style, substyle = self.__currentStyles() + newSubstyle = self.lexer.addSubstyle(style) + + description = self.tr("{0} - Copy").format( + self.lexer.description(style, substyle)) + self.lexer.setDescription(description, style, newSubstyle) + self.lexer.setWords(self.lexer.words(style, substyle), + style, newSubstyle) + self.lexer.setColor(self.lexer.color(style, substyle), + style, newSubstyle) + self.lexer.setPaper(self.lexer.paper(style, substyle), + style, newSubstyle) + self.lexer.setFont(self.lexer.font(style, substyle), + style, newSubstyle) + self.lexer.setEolFill(self.lexer.eolFill(style, substyle), + style, newSubstyle) + + parent = self.styleElementList.findItems( + self.lexer.description(style), Qt.MatchExactly)[0] + parent.setExpanded(True) + itm = QTreeWidgetItem(parent, [description]) + itm.setData(0, self.StyleRole, style) + itm.setData(0, self.SubstyleRole, newSubstyle) + self.__styleOneItem(itm, style, newSubstyle) def create(dlg):
--- a/Preferences/ConfigurationPages/EditorHighlightingStylesPage.ui Sat Mar 16 14:11:43 2019 +0100 +++ b/Preferences/ConfigurationPages/EditorHighlightingStylesPage.ui Sat Mar 16 18:38:01 2019 +0100 @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>550</width> - <height>592</height> + <height>700</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> @@ -67,180 +67,14 @@ <string>Style Element</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="1"> - <widget class="QPushButton" name="foregroundButton"> - <property name="toolTip"> - <string>Select the foreground colour.</string> - </property> - <property name="text"> - <string>Foreground Colour</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="backgroundButton"> - <property name="toolTip"> - <string>Select the background colour.</string> - </property> - <property name="text"> - <string>Background Colour</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QPushButton" name="fontButton"> - <property name="toolTip"> - <string>Select the font.</string> - </property> - <property name="text"> - <string>Font</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QCheckBox" name="eolfillCheckBox"> - <property name="toolTip"> - <string>Select end of line fill.</string> - </property> - <property name="text"> - <string>Fill to end of line</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QPushButton" name="defaultButton"> - <property name="toolTip"> - <string>Press to set the current style to its default values</string> - </property> - <property name="text"> - <string>to Default</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <spacer name="spacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>43</height> - </size> - </property> - </spacer> - </item> - <item row="7" column="1"> - <widget class="QPushButton" name="monospacedButton"> - <property name="toolTip"> - <string>Press to show only monospaced fonts</string> - </property> - <property name="text"> - <string>Monospaced Fonts Only</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>true</bool> + <item row="0" column="0"> + <widget class="QTreeWidget" name="styleElementList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - </widget> - </item> - <item row="8" column="1"> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>38</height> - </size> - </property> - </spacer> - </item> - <item row="9" column="1"> - <widget class="QPushButton" name="allBackgroundColoursButton"> - <property name="toolTip"> - <string>Select the background colour for all styles</string> - </property> - <property name="text"> - <string>All Background Colours</string> - </property> - </widget> - </item> - <item row="10" column="1"> - <widget class="QPushButton" name="allFontsButton"> - <property name="toolTip"> - <string>Select the font for all styles.</string> - </property> - <property name="text"> - <string>All Fonts</string> - </property> - </widget> - </item> - <item row="11" column="1"> - <widget class="QPushButton" name="allEolFillButton"> - <property name="toolTip"> - <string>Select the eol fill for all styles</string> - </property> - <property name="text"> - <string>All Fill to end of line</string> - </property> - </widget> - </item> - <item row="12" column="1"> - <widget class="Line" name="line_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="13" column="1"> - <widget class="QPushButton" name="allDefaultButton"> - <property name="toolTip"> - <string>Press to set all styles to their default values</string> - </property> - <property name="text"> - <string>All to Default</string> - </property> - </widget> - </item> - <item row="14" column="0" colspan="2"> - <widget class="QLineEdit" name="sampleText"> - <property name="focusPolicy"> - <enum>Qt::NoFocus</enum> - </property> - <property name="text"> - <string>Sample Text</string> - </property> - <property name="alignment"> - <set>Qt::AlignHCenter</set> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="15" column="0" colspan="2"> - <widget class="QLabel" name="label"> - <property name="text"> - <string><b>Note:</b> The tick in the list above indicates the entrie's 'fill to end of line' setting.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="0" column="0" rowspan="14"> - <widget class="QTreeWidget" name="styleElementList"> <property name="selectionMode"> <enum>QAbstractItemView::ExtendedSelection</enum> </property> @@ -260,6 +94,247 @@ </column> </widget> </item> + <item row="0" column="1"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>13</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="addSubstyleButton"> + <property name="toolTip"> + <string>Press to add a sub-style to the selected style</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="deleteSubstyleButton"> + <property name="toolTip"> + <string>Press to to delete the selected sub-style</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="editSubstyleButton"> + <property name="toolTip"> + <string>Press to edit the selected sub-style</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="copySubstyleButton"> + <property name="toolTip"> + <string>Press to copy the selected sub-style</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>13</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="foregroundButton"> + <property name="toolTip"> + <string>Select the foreground colour.</string> + </property> + <property name="text"> + <string>Foreground Colour</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="backgroundButton"> + <property name="toolTip"> + <string>Select the background colour.</string> + </property> + <property name="text"> + <string>Background Colour</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="fontButton"> + <property name="toolTip"> + <string>Select the font.</string> + </property> + <property name="text"> + <string>Font</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="eolfillCheckBox"> + <property name="toolTip"> + <string>Select end of line fill.</string> + </property> + <property name="text"> + <string>Fill to end of line</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="defaultButton"> + <property name="toolTip"> + <string>Press to set the current style to its default values</string> + </property> + <property name="text"> + <string>to Default</string> + </property> + </widget> + </item> + <item> + <spacer name="spacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>43</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="monospacedButton"> + <property name="toolTip"> + <string>Press to show only monospaced fonts</string> + </property> + <property name="text"> + <string>Monospaced Fonts Only</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>38</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="allBackgroundColoursButton"> + <property name="toolTip"> + <string>Select the background colour for all styles</string> + </property> + <property name="text"> + <string>All Background Colours</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="allFontsButton"> + <property name="toolTip"> + <string>Select the font for all styles.</string> + </property> + <property name="text"> + <string>All Fonts</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="allEolFillButton"> + <property name="toolTip"> + <string>Select the eol fill for all styles</string> + </property> + <property name="text"> + <string>All Fill to end of line</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="allDefaultButton"> + <property name="toolTip"> + <string>Press to set all styles to their default values</string> + </property> + <property name="text"> + <string>All to Default</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QLineEdit" name="sampleText"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>Sample Text</string> + </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QLabel" name="label"> + <property name="text"> + <string><b>Note:</b> The tick in the list above indicates the entrie's 'fill to end of line' setting.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> </layout> </widget> </item> @@ -318,6 +393,10 @@ <tabstops> <tabstop>lexerLanguageComboBox</tabstop> <tabstop>styleElementList</tabstop> + <tabstop>addSubstyleButton</tabstop> + <tabstop>deleteSubstyleButton</tabstop> + <tabstop>editSubstyleButton</tabstop> + <tabstop>copySubstyleButton</tabstop> <tabstop>foregroundButton</tabstop> <tabstop>backgroundButton</tabstop> <tabstop>fontButton</tabstop>
--- a/Preferences/PreferencesLexer.py Sat Mar 16 14:11:43 2019 +0100 +++ b/Preferences/PreferencesLexer.py Sat Mar 16 18:38:01 2019 +0100 @@ -467,6 +467,17 @@ return ok + def isBaseStyle(self, style): + """ + Public method to test, if a given style may have sub-styles. + + @param style base style number + @type int + @return flag indicating that the style may have sub-styles + @rtype bool + """ + return self.__lex.hasSubstyles() and self.__lex.isBaseStyle(style) + def addSubstyle(self, style): """ Public method to add an empty sub-style to a given style. @@ -477,3 +488,16 @@ @rtype int """ return self.__lex.addSubstyle(style) + + def delSubstyle(self, style, substyle): + """ + Public method to delete a given sub-style definition. + + @param style base style number + @type int + @param substyle sub-style number + @type int + @return flag indicating successful deletion + @rtype bool + """ + return self.__lex.delSubstyle(style, substyle)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Preferences/SubstyleDefinitionDialog.py Sat Mar 16 18:38:01 2019 +0100 @@ -0,0 +1,133 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing the sub-style definition dialog. +""" + +from __future__ import unicode_literals + +from PyQt5.QtCore import pyqtSlot +from PyQt5.QtWidgets import QDialog, QDialogButtonBox + +from E5Gui import E5MessageBox + +from .Ui_SubstyleDefinitionDialog import Ui_SubstyleDefinitionDialog + + +class SubstyleDefinitionDialog(QDialog, Ui_SubstyleDefinitionDialog): + """ + Class implementing the sub-style definition dialog. + """ + def __init__(self, lexer, style, substyle, parent=None): + """ + Constructor + + @param lexer reference to the lexer object + @type PreferencesLexer + @param style style number + @type int + @param substyle sub-style number + @type int + @param parent reference to the parent widget + @type QWidget + """ + super(SubstyleDefinitionDialog, self).__init__(parent) + self.setupUi(self) + + self.__lexer = lexer + self.__style = style + self.__substyle = substyle + + self.header.setText(self.tr("<h3>{0} - {1}</h3>").format( + self.__lexer.language(), self.__lexer.description(self.__style))) + if self.__substyle >= 0: + # it's an edit operation + self.descriptionEdit.setText( + self.__lexer.description(self.__style, self.__substyle)) + self.wordsEdit.setPlainText( + self.__lexer.words(self.__style, self.__substyle)) + + def __updateOk(self): + """ + Private slot to update the state of the OK button. + """ + self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( + bool(self.descriptionEdit.text().strip()) and + bool(self.wordsEdit.toPlainText().strip()) + ) + + @pyqtSlot(str) + def on_descriptionEdit_textChanged(self, txt): + """ + Private slot handling changes of the description. + + @param txt text of the description + @type str + """ + self.__updateOk() + + @pyqtSlot() + def on_wordsEdit_textChanged(self): + """ + Private slot handling changes of the word list. + """ + self.__updateOk() + + @pyqtSlot() + def on_resetButton_clicked(self): + """ + Private slot to reset the dialog contents. + """ + ok = E5MessageBox.yesNo( + self, + self.tr("Reset Sub-Style Data"), + self.tr("""Shall the entered sub-style data be reset?""")) + if ok: + if self.__substyle >= 0: + self.descriptionEdit.setText( + self.__lexer.description(self.__style, self.__substyle)) + self.wordsEdit.setPlainText( + self.__lexer.words(self.__style, self.__substyle)) + else: + self.descriptionEdit.clear() + self.wordsEdit.clear() + + @pyqtSlot() + def on_defaultButton_clicked(self): + """ + Private slot to set the dialog contents to default values. + """ + filled = bool(self.descriptionEdit.text().strip()) or \ + bool(self.wordsEdit.toPlainText().strip()) + if filled: + ok = E5MessageBox.yesNo( + self, + self.tr("Set Sub-Style Data to Default"), + self.tr("""Shall the sub-style data be set to default""" + """ values?""")) + else: + ok = True + if ok: + if self.__substyle >= 0: + self.descriptionEdit.setText(self.__lexer.defaultDescription( + self.__style, self.__substyle)) + self.wordsEdit.setPlainText(self.__lexer.defaultWords( + self.__style, self.__substyle)) + else: + self.descriptionEdit.clear() + self.wordsEdit.clear() + + def getData(self): + """ + Public method to get the entered data. + + @return tuple containing the sub-style description and words list. + @rtype tuple of (str, str) + """ + return ( + self.descriptionEdit.text().strip(), + self.wordsEdit.toPlainText().strip(), + )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Preferences/SubstyleDefinitionDialog.ui Sat Mar 16 18:38:01 2019 +0100 @@ -0,0 +1,143 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SubstyleDefinitionDialog</class> + <widget class="QDialog" name="SubstyleDefinitionDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>550</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>Define Sub-Style</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="header"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Description:</string> + </property> + </widget> + </item> + <item> + <widget class="E5ClearableLineEdit" name="descriptionEdit"> + <property name="toolTip"> + <string>Enter a short description for the style</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Words (separated by spaces):</string> + </property> + </widget> + </item> + <item> + <widget class="QPlainTextEdit" name="wordsEdit"> + <property name="toolTip"> + <string>Enter the list of words separated by space</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="resetButton"> + <property name="toolTip"> + <string>Press to reset the data</string> + </property> + <property name="text"> + <string>Reset</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="defaultButton"> + <property name="toolTip"> + <string>Press to set the data to default values (if available)</string> + </property> + <property name="text"> + <string>Defaults</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>E5ClearableLineEdit</class> + <extends>QLineEdit</extends> + <header>E5Gui/E5LineEdit.h</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>descriptionEdit</tabstop> + <tabstop>wordsEdit</tabstop> + <tabstop>resetButton</tabstop> + <tabstop>defaultButton</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>SubstyleDefinitionDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>SubstyleDefinitionDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- a/QScintilla/Lexers/SubstyledLexer.py Sat Mar 16 14:11:43 2019 +0100 +++ b/QScintilla/Lexers/SubstyledLexer.py Sat Mar 16 18:38:01 2019 +0100 @@ -357,7 +357,8 @@ @type int """ if style in self.__subStyles and substyle in self.__subStyles[style]: - self.__subStyles[style][substyle]["Description"] = description + self.__subStyles[style][substyle]["Description"] = \ + description.strip() def substyleDescription(self, style, substyle): """ @@ -371,7 +372,7 @@ @rtype str """ if style in self.__subStyles and substyle in self.__subStyles[style]: - desc = self.__subStyles[style][substyle]["Description"] + desc = self.__subStyles[style][substyle]["Description"].strip() else: desc = "" @@ -389,7 +390,7 @@ @type int """ if style in self.__subStyles and substyle in self.__subStyles[style]: - self.__subStyles[style][substyle]["Words"] = words + self.__subStyles[style][substyle]["Words"] = words.strip() def substyleWords(self, style, substyle): """ @@ -403,7 +404,7 @@ @rtype str """ if style in self.__subStyles and substyle in self.__subStyles[style]: - words = self.__subStyles[style][substyle]["Words"] + words = self.__subStyles[style][substyle]["Words"].strip() else: words = "" @@ -588,8 +589,8 @@ if style in self.defaultSubStyles and \ substyle in self.defaultSubStyles[style]: - styleData = self.defaultSubStyles[style][substyle]["Style"] - description = styleData["Description"] + substyleData = self.defaultSubStyles[style][substyle] + description = substyleData["Description"].strip() return description @@ -608,8 +609,8 @@ if style in self.defaultSubStyles and \ substyle in self.defaultSubStyles[style]: - styleData = self.defaultSubStyles[style][substyle]["Style"] - words = styleData["Words"] + substyleData = self.defaultSubStyles[style][substyle] + words = substyleData["Words"].strip() return words @@ -767,3 +768,14 @@ """ return (style in self.__subStyles and substyle in self.__subStyles[style]) + + def isBaseStyle(self, style): + """ + Public method to test, if a given style may have sub-styles. + + @param style base style number + @type int + @return flag indicating that the style may have sub-styles + @rtype bool + """ + return style in self.baseStyles
--- a/eric6.e4p Sat Mar 16 14:11:43 2019 +0100 +++ b/eric6.e4p Sat Mar 16 18:38:01 2019 +0100 @@ -915,6 +915,7 @@ <Source>Preferences/ShortcutDialog.py</Source> <Source>Preferences/Shortcuts.py</Source> <Source>Preferences/ShortcutsDialog.py</Source> + <Source>Preferences/SubstyleDefinitionDialog.py</Source> <Source>Preferences/ToolConfigurationDialog.py</Source> <Source>Preferences/ToolGroupConfigurationDialog.py</Source> <Source>Preferences/ViewProfileDialog.py</Source> @@ -2090,6 +2091,7 @@ <Form>Preferences/ProgramsDialog.ui</Form> <Form>Preferences/ShortcutDialog.ui</Form> <Form>Preferences/ShortcutsDialog.ui</Form> + <Form>Preferences/SubstyleDefinitionDialog.ui</Form> <Form>Preferences/ToolConfigurationDialog.ui</Form> <Form>Preferences/ToolGroupConfigurationDialog.ui</Form> <Form>Preferences/ViewProfileSidebarsDialog.ui</Form>