Modified sources to be in line with the minimum QScintilla requirement (v 2.9.0). without_py2_and_pyqt4

Mon, 02 Sep 2019 18:51:38 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 02 Sep 2019 18:51:38 +0200
branch
without_py2_and_pyqt4
changeset 7202
d2f2a1fe0129
parent 7201
6b42677d7043
child 7203
2079ccbfa335

Modified sources to be in line with the minimum QScintilla requirement (v 2.9.0).

eric6/Preferences/ConfigurationPages/EditorCalltipsPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/EditorPropertiesPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/EditorSearchPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/EditorStylesPage.py file | annotate | diff | comparison | revisions
eric6/QScintilla/Editor.py file | annotate | diff | comparison | revisions
eric6/QScintilla/Lexers/__init__.py file | annotate | diff | comparison | revisions
eric6/QScintilla/QsciScintillaCompat.py file | annotate | diff | comparison | revisions
--- a/eric6/Preferences/ConfigurationPages/EditorCalltipsPage.py	Mon Sep 02 18:50:38 2019 +0200
+++ b/eric6/Preferences/ConfigurationPages/EditorCalltipsPage.py	Mon Sep 02 18:51:38 2019 +0200
@@ -11,8 +11,6 @@
 
 from PyQt5.Qsci import QsciScintilla
 
-from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION
-
 from .ConfigurationPageBase import ConfigurationPageBase
 from .Ui_EditorCalltipsPage import Ui_EditorCalltipsPage
 
@@ -31,15 +29,12 @@
         self.setupUi(self)
         self.setObjectName("EditorCalltipsPage")
         
-        if QSCINTILLA_VERSION() >= 0x020700:
-            self.positionComboBox.addItem(
-                self.tr("Below Text"),
-                QsciScintilla.CallTipsBelowText)
-            self.positionComboBox.addItem(
-                self.tr("Above Text"),
-                QsciScintilla.CallTipsAboveText)
-        else:
-            self.calltipsPositionBox.hide()
+        self.positionComboBox.addItem(
+            self.tr("Below Text"),
+            QsciScintilla.CallTipsBelowText)
+        self.positionComboBox.addItem(
+            self.tr("Above Text"),
+            QsciScintilla.CallTipsAboveText)
         
         # set initial values
         self.ctEnabledCheckBox.setChecked(
@@ -53,10 +48,9 @@
         self.ctScintillaCheckBox.setChecked(
             Preferences.getEditor("CallTipsScintillaOnFail"))
         
-        if QSCINTILLA_VERSION() >= 0x020700:
-            self.positionComboBox.setCurrentIndex(
-                self.positionComboBox.findData(
-                    Preferences.getEditor("CallTipsPosition")))
+        self.positionComboBox.setCurrentIndex(
+            self.positionComboBox.findData(
+                Preferences.getEditor("CallTipsPosition")))
         
     def save(self):
         """
@@ -75,11 +69,10 @@
             "CallTipsScintillaOnFail",
             self.ctScintillaCheckBox.isChecked())
         
-        if QSCINTILLA_VERSION() >= 0x020700:
-            Preferences.setEditor(
-                "CallTipsPosition",
-                self.positionComboBox.itemData(
-                    self.positionComboBox.currentIndex()))
+        Preferences.setEditor(
+            "CallTipsPosition",
+            self.positionComboBox.itemData(
+                self.positionComboBox.currentIndex()))
 
 
 def create(dlg):
--- a/eric6/Preferences/ConfigurationPages/EditorPropertiesPage.py	Mon Sep 02 18:50:38 2019 +0200
+++ b/eric6/Preferences/ConfigurationPages/EditorPropertiesPage.py	Mon Sep 02 18:51:38 2019 +0200
@@ -9,8 +9,6 @@
 
 from __future__ import unicode_literals
 
-from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION
-
 from .ConfigurationPageBase import ConfigurationPageBase
 from .Ui_EditorPropertiesPage import Ui_EditorPropertiesPage
 
@@ -304,16 +302,15 @@
         Preferences.setEditor(
             "CppHighlightHashQuotedStrings",
             self.cppHighlightHashQuotedCheckBox.isChecked())
-        if QSCINTILLA_VERSION() >= 0x020900:
-            Preferences.setEditor(
-                "CppHighlightBackQuotedStrings",
-                self.cppHighlightBackQuotedCheckBox.isChecked())
-            Preferences.setEditor(
-                "CppHighlightEscapeSequences",
-                self.cppHighlightEsacepSequencesCheckBox.isChecked())
-            Preferences.setEditor(
-                "CppVerbatimStringEscapeSequencesAllowed",
-                self.cppVerbatimStringEscapeAllowedCheckBox.isChecked())
+        Preferences.setEditor(
+            "CppHighlightBackQuotedStrings",
+            self.cppHighlightBackQuotedCheckBox.isChecked())
+        Preferences.setEditor(
+            "CppHighlightEscapeSequences",
+            self.cppHighlightEsacepSequencesCheckBox.isChecked())
+        Preferences.setEditor(
+            "CppVerbatimStringEscapeSequencesAllowed",
+            self.cppVerbatimStringEscapeAllowedCheckBox.isChecked())
         
         # CMake
         Preferences.setEditor(
--- a/eric6/Preferences/ConfigurationPages/EditorSearchPage.py	Mon Sep 02 18:50:38 2019 +0200
+++ b/eric6/Preferences/ConfigurationPages/EditorSearchPage.py	Mon Sep 02 18:51:38 2019 +0200
@@ -9,8 +9,6 @@
 
 from __future__ import unicode_literals
 
-from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION
-
 from .ConfigurationPageBase import ConfigurationPageBase
 from .Ui_EditorSearchPage import Ui_EditorSearchPage
 
@@ -42,13 +40,10 @@
         self.markOccurrencesTimeoutSpinBox.setValue(
             Preferences.getEditor("MarkOccurrencesTimeout"))
         
-        if QSCINTILLA_VERSION() < 0x020B00:
-            self.regexpModeBox.setEnabled(False)
+        if Preferences.getEditor("SearchRegexpMode") == 0:
+            self.regexpPosixButton.setChecked(True)
         else:
-            if Preferences.getEditor("SearchRegexpMode") == 0:
-                self.regexpPosixButton.setChecked(True)
-            else:
-                self.regexpCxx11Button.setChecked(True)
+            self.regexpCxx11Button.setChecked(True)
         
         self.initColour(
             "SearchMarkers", self.searchMarkerButton,
--- a/eric6/Preferences/ConfigurationPages/EditorStylesPage.py	Mon Sep 02 18:50:38 2019 +0200
+++ b/eric6/Preferences/ConfigurationPages/EditorStylesPage.py	Mon Sep 02 18:51:38 2019 +0200
@@ -37,8 +37,8 @@
         self.setupUi(self)
         self.setObjectName("EditorStylesPage")
         
-        from QScintilla.QsciScintillaCompat import QsciScintillaCompat, \
-            QSCINTILLA_VERSION
+        from QScintilla.QsciScintillaCompat import QsciScintillaCompat
+        
         self.foldStyles = [
             QsciScintilla.PlainFoldStyle,
             QsciScintilla.CircledFoldStyle,
@@ -67,10 +67,9 @@
             self.tr("Indicator by Text"), QsciScintilla.WrapFlagByText)
         self.wrapVisualComboBox.addItem(
             self.tr("Indicator by Margin"), QsciScintilla.WrapFlagByBorder)
-        if QSCINTILLA_VERSION() >= 0x020700:
-            self.wrapVisualComboBox.addItem(
-                self.tr("Indicator in Line Number Margin"),
-                QsciScintilla.WrapFlagInMargin)
+        self.wrapVisualComboBox.addItem(
+            self.tr("Indicator in Line Number Margin"),
+            QsciScintilla.WrapFlagInMargin)
         
         self.wrapIndentComboBox.addItem(
             self.tr("Fixed"), QsciScintilla.WrapIndentFixed)
@@ -79,15 +78,9 @@
         self.wrapIndentComboBox.addItem(
             self.tr("Aligned plus One"),
             QsciScintilla.WrapIndentIndented)
-        if QSCINTILLA_VERSION() >= 0x020B00:
-            self.wrapIndentComboBox.addItem(
-                self.tr("Aligned plus Two"),
-                QsciScintilla.WrapIndentDeeplyIndented)
-        
-        self.caretlineAlwaysVisibleCheckBox.setEnabled(
-            QSCINTILLA_VERSION() >= 0x020800)
-        self.caretlineFrameWidthSpinBox.setEnabled(
-            QSCINTILLA_VERSION() >= 0x020B00)
+        self.wrapIndentComboBox.addItem(
+            self.tr("Aligned plus Two"),
+            QsciScintilla.WrapIndentDeeplyIndented)
         
         # set initial values
         try:
--- a/eric6/QScintilla/Editor.py	Mon Sep 02 18:50:38 2019 +0200
+++ b/eric6/QScintilla/Editor.py	Mon Sep 02 18:51:38 2019 +0200
@@ -24,7 +24,7 @@
 from E5Gui import E5FileDialog, E5MessageBox
 from E5Utilities.E5Cache import E5Cache
 
-from .QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION
+from .QsciScintillaCompat import QsciScintillaCompat
 from .EditorMarkerMap import EditorMarkerMap
 
 import Preferences
@@ -4403,8 +4403,7 @@
         self.caretWidth = Preferences.getEditor("CaretWidth")
         self.setCaretWidth(self.caretWidth)
         self.caretLineFrameWidth = Preferences.getEditor("CaretLineFrameWidth")
-        if QSCINTILLA_VERSION() >= 0x020B00:
-            self.setCaretLineFrameWidth(self.caretLineFrameWidth)
+        self.setCaretLineFrameWidth(self.caretLineFrameWidth)
         self.useMonospaced = Preferences.getEditor("UseMonospacedFont")
         self.setMonospaced(self.useMonospaced)
         edgeMode = Preferences.getEditor("EdgeMode")
--- a/eric6/QScintilla/Lexers/__init__.py	Mon Sep 02 18:50:38 2019 +0200
+++ b/eric6/QScintilla/Lexers/__init__.py	Mon Sep 02 18:51:38 2019 +0200
@@ -157,18 +157,12 @@
                 "lexerXML.png"],
         "YAML": [QCoreApplication.translate('Lexers', "YAML"), 'dummy.yml',
                  "lexerYAML.png"],
+        "Gettext": [QCoreApplication.translate('Lexers', "Gettext"),
+                    'dummy.po', "lexerGettext.png"],
+        "CoffeeScript": [QCoreApplication.translate('Lexers', "CoffeeScript"),
+                         'dummy.coffee', "lexerCoffeeScript.png"],
     }
     
-    if QSCINTILLA_VERSION() >= 0x020802:
-        supportedLanguages["Gettext"] = \
-            [QCoreApplication.translate('Lexers', "Gettext"), 'dummy.po',
-             "lexerGettext.png"]
-    
-    if QSCINTILLA_VERSION() >= 0x020803:
-        supportedLanguages["CoffeeScript"] = \
-            [QCoreApplication.translate('Lexers', "CoffeeScript"),
-             'dummy.coffee', "lexerCoffeeScript.png"]
-    
     if QSCINTILLA_VERSION() >= 0x020a00:
         supportedLanguages["JSON"] = \
             [QCoreApplication.translate('Lexers', "JSON"),
@@ -507,22 +501,14 @@
         QCoreApplication.translate(
             'Lexers',
             'Octave Files (*.m *.m.octave)'),
+        QCoreApplication.translate(
+            'Lexers',
+            'Gettext Files (*.po)'),
+        QCoreApplication.translate(
+            'Lexers',
+            'CoffeeScript Files (*.coffee)'),
     ]
     
-    if QSCINTILLA_VERSION() >= 0x020802:
-        openFileFiltersList.append(
-            QCoreApplication.translate(
-                'Lexers',
-                'Gettext Files (*.po)'),
-        )
-    
-    if QSCINTILLA_VERSION() >= 0x020803:
-        openFileFiltersList.append(
-            QCoreApplication.translate(
-                'Lexers',
-                'CoffeeScript Files (*.coffee)'),
-        )
-    
     if QSCINTILLA_VERSION() >= 0x020a00:
         openFileFiltersList.append(
             QCoreApplication.translate(
@@ -729,22 +715,14 @@
         QCoreApplication.translate(
             'Lexers',
             'Octave Files (*.m.octave)'),
+        QCoreApplication.translate(
+            'Lexers',
+            'Gettext Files (*.po)'),
+        QCoreApplication.translate(
+            'Lexers',
+            'CoffeeScript Files (*.coffee)'),
     ]
     
-    if QSCINTILLA_VERSION() >= 0x020802:
-        saveFileFiltersList.append(
-            QCoreApplication.translate(
-                'Lexers',
-                'Gettext Files (*.po)'),
-        )
-    
-    if QSCINTILLA_VERSION() >= 0x020803:
-        saveFileFiltersList.append(
-            QCoreApplication.translate(
-                'Lexers',
-                'CoffeeScript Files (*.coffee)'),
-        )
-    
     if QSCINTILLA_VERSION() >= 0x020a00:
         saveFileFiltersList.append(
             QCoreApplication.translate(
@@ -907,14 +885,10 @@
         '*.e6s': "XML",
         '*.e6t': "XML",
         '*.proto': "Protocol",
+        '*.po': "Gettext",
+        '*.coffee': "CoffeeScript",
     }
     
-    if QSCINTILLA_VERSION() >= 0x020802:
-        assocs['*.po'] = "Gettext"
-    
-    if QSCINTILLA_VERSION() >= 0x020803:
-        assocs['*.coffee'] = "CoffeeScript"
-    
     if QSCINTILLA_VERSION() >= 0x020a00:
         assocs['*.json'] = "JSON"
         assocs['*.md'] = "Markdown"
--- a/eric6/QScintilla/QsciScintillaCompat.py	Mon Sep 02 18:50:38 2019 +0200
+++ b/eric6/QScintilla/QsciScintillaCompat.py	Mon Sep 02 18:51:38 2019 +0200
@@ -46,15 +46,7 @@
     
     UserSeparator = '\x04'
     
-    if QSCINTILLA_VERSION() < 0x020600:
-        IndicatorStyleMax = QsciScintilla.INDIC_ROUNDBOX
-    elif QSCINTILLA_VERSION() < 0x020700:
-        IndicatorStyleMax = QsciScintilla.INDIC_DOTBOX
-    elif QSCINTILLA_VERSION() < 0x020800:
-        IndicatorStyleMax = QsciScintilla.INDIC_SQUIGGLEPIXMAP
-    elif QSCINTILLA_VERSION() < 0x020900:
-        IndicatorStyleMax = QsciScintilla.INDIC_COMPOSITIONTHICK
-    elif QSCINTILLA_VERSION() < 0x020A00:
+    if QSCINTILLA_VERSION() < 0x020A00:
         IndicatorStyleMax = QsciScintilla.INDIC_TEXTFORE
     elif QSCINTILLA_VERSION() < 0x020B00:
         IndicatorStyleMax = QsciScintilla.INDIC_POINTCHARACTER
@@ -905,7 +897,7 @@
             if cxx11:
                 self.__targetSearchFlags |= QsciScintilla.SCFIND_CXX11REGEX
         except AttributeError:
-            # defined for PyQt >= 2.11.0
+            # defined for QScintilla >= 2.11.0
             pass
         
         if begline < 0 or begindex < 0:
@@ -1451,33 +1443,6 @@
         @return result of the event handling (boolean)
         """
         return QsciScintillaBase.event(self, evt)
-    
-    if "inputMethodEvent" in QsciScintillaBase.__dict__ and \
-            QSCINTILLA_VERSION() < 0x020801:
-        def inputMethodEvent(self, evt):
-            """
-            Protected method to cope with a glitch in some Qscintilla versions
-            handling input events.
-            
-            Note: This simply disables the Qscintilla behavior.
-            
-            @param evt reference to the input method event object
-                (QInputMethodEvent)
-            """
-            pass
-        
-        def inputMethodQuery(self, query):
-            """
-            Public method to cope with a glitch in some Qscintilla versions
-            handling input events.
-            
-            Note: This simply disables the Qscintilla behavior.
-            
-            @param query reference to the input method query object
-                (Qt.InputMethodQuery)
-            @return object containing the requested information
-            """
-            return None     # __IGNORE_WARNING_M831__
 
     ###########################################################################
     ## interface methods to the mini editor
@@ -1673,80 +1638,33 @@
             line, col = self.getCursorPosition()
             self.insertAt(txt, line, col)
     
+    def positionFromLineIndex(self, line, index):
+        """
+        Public method to convert line and index to an absolute position.
+        
+        @param line line number (integer)
+        @param index index number (integer)
+        @return absolute position in the editor (integer)
+        """
+        pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
+        return pos + index
+    
+    def lineIndexFromPosition(self, pos):
+        """
+        Public method to convert an absolute position to line and index.
+        
+        @param pos absolute position in the editor (integer)
+        @return tuple of line number (integer) and index number (integer)
+        """
+        lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos)
+        linpos = self.SendScintilla(
+            QsciScintilla.SCI_POSITIONFROMLINE, lin)
+        return lin, pos - linpos
+    
     ###########################################################################
     ## methods below have been added to QScintilla starting with version 2.5
     ###########################################################################
     
-    if "positionFromLineIndex" not in QsciScintilla.__dict__:
-        def positionFromLineIndex(self, line, index):
-            """
-            Public method to convert line and index to an absolute position.
-            
-            @param line line number (integer)
-            @param index index number (integer)
-            @return absolute position in the editor (integer)
-            """
-            pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
-            
-            # Allow for multi-byte characters
-            for _ in range(index):
-                pos = self.positionAfter(pos)
-            
-            return pos
-    
-    elif QSCINTILLA_VERSION() >= 0x020700:
-        def positionFromLineIndex(self, line, index):
-            """
-            Public method to convert line and index to an absolute position.
-            
-            @param line line number (integer)
-            @param index index number (integer)
-            @return absolute position in the editor (integer)
-            """
-            pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
-            return pos + index
-    
-    if "lineIndexFromPosition" not in QsciScintilla.__dict__:
-        def lineIndexFromPosition(self, pos):
-            """
-            Public method to convert an absolute position to line and index.
-            
-            @param pos absolute position in the editor (integer)
-            @return tuple of line number (integer) and index number (integer)
-            """
-            lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos)
-            linpos = self.SendScintilla(
-                QsciScintilla.SCI_POSITIONFROMLINE, lin)
-            indx = 0
-            
-            # Allow for multi-byte characters.
-            while linpos < pos:
-                new_linpos = self.positionAfter(linpos)
-                
-                # If the position hasn't moved then we must be at the end of
-                # the text (which implies that the position passed was beyond
-                # the end of the text).
-                if new_linpos == linpos:
-                    break
-                
-                linpos = new_linpos
-                indx += 1
-            
-            return lin, indx
-    
-    elif QSCINTILLA_VERSION() >= 0x020700:
-        def lineIndexFromPosition(self, pos):
-            """
-            Public method to convert an absolute position to line and index.
-            
-            @param pos absolute position in the editor (integer)
-            @return tuple of line number (integer) and index number (integer)
-            """
-            lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos)
-            linpos = self.SendScintilla(
-                QsciScintilla.SCI_POSITIONFROMLINE, lin)
-            return lin, pos - linpos
-    
     if "contractedFolds" not in QsciScintilla.__dict__:
         def contractedFolds(self):
             """

eric ide

mercurial