Editor eric7

Sat, 13 Jan 2024 13:01:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 13 Jan 2024 13:01:09 +0100
branch
eric7
changeset 10499
71208bcc7d99
parent 10498
6bbe8e2210d7
child 10500
40fc136e7002

Editor
- Added code to show the indicator margin messages when the mouse hovers over a syntax error or warning indicator.

docs/changelog.md file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.QScintilla.Editor.html file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.QScintilla.QsciScintillaCompat.html file | annotate | diff | comparison | revisions
src/eric7/QScintilla/Editor.py file | annotate | diff | comparison | revisions
--- a/docs/changelog.md	Sat Jan 13 12:58:16 2024 +0100
+++ b/docs/changelog.md	Sat Jan 13 13:01:09 2024 +0100
@@ -9,6 +9,8 @@
 - Editor
     - Added an Edit menu entry tp convert tabs to spaces manually.
     - Added the capability to show local variables in the outline view.
+    - Added code to show the indicator margin messages when the mouse hovers
+      over a syntax error or warning indicator.
 - File Browser
     - Added the capability to show local variables of functions and methods.
 - Find In Files
Binary file src/eric7/Documentation/Help/source.qch has changed
--- a/src/eric7/Documentation/Help/source.qhp	Sat Jan 13 12:58:16 2024 +0100
+++ b/src/eric7/Documentation/Help/source.qhp	Sat Jan 13 13:01:09 2024 +0100
@@ -4669,6 +4669,8 @@
       <keyword name="Editor.__loadEditorConfig" id="Editor.__loadEditorConfig" ref="eric7.QScintilla.Editor.html#Editor.__loadEditorConfig" />
       <keyword name="Editor.__loadEditorConfigObject" id="Editor.__loadEditorConfigObject" ref="eric7.QScintilla.Editor.html#Editor.__loadEditorConfigObject" />
       <keyword name="Editor.__marginClicked" id="Editor.__marginClicked" ref="eric7.QScintilla.Editor.html#Editor.__marginClicked" />
+      <keyword name="Editor.__marginHoverEnd" id="Editor.__marginHoverEnd" ref="eric7.QScintilla.Editor.html#Editor.__marginHoverEnd" />
+      <keyword name="Editor.__marginHoverStart" id="Editor.__marginHoverStart" ref="eric7.QScintilla.Editor.html#Editor.__marginHoverStart" />
       <keyword name="Editor.__marginNumber" id="Editor.__marginNumber" ref="eric7.QScintilla.Editor.html#Editor.__marginNumber" />
       <keyword name="Editor.__markOccurrences" id="Editor.__markOccurrences" ref="eric7.QScintilla.Editor.html#Editor.__markOccurrences" />
       <keyword name="Editor.__menuClearBreakpoints" id="Editor.__menuClearBreakpoints" ref="eric7.QScintilla.Editor.html#Editor.__menuClearBreakpoints" />
--- a/src/eric7/Documentation/Source/eric7.QScintilla.Editor.html	Sat Jan 13 12:58:16 2024 +0100
+++ b/src/eric7/Documentation/Source/eric7.QScintilla.Editor.html	Sat Jan 13 13:01:09 2024 +0100
@@ -594,6 +594,14 @@
 <td>Private slot to handle the marginClicked signal.</td>
 </tr>
 <tr>
+<td><a href="#Editor.__marginHoverEnd">__marginHoverEnd</a></td>
+<td>Private slot cancelling the display of syntax error or a warning marker text.</td>
+</tr>
+<tr>
+<td><a href="#Editor.__marginHoverStart">__marginHoverStart</a></td>
+<td>Private slot showing the text of a syntax error or a warning marker.</td>
+</tr>
+<tr>
 <td><a href="#Editor.__marginNumber">__marginNumber</a></td>
 <td>Private method to calculate the margin number based on a x position.</td>
 </tr>
@@ -3339,6 +3347,35 @@
 keyboard modifiers
 </dd>
 </dl>
+<a NAME="Editor.__marginHoverEnd" ID="Editor.__marginHoverEnd"></a>
+<h4>Editor.__marginHoverEnd</h4>
+<b>__marginHoverEnd</b>(<i></i>)
+<p>
+        Private slot cancelling the display of syntax error or a warning marker text.
+</p>
+
+<a NAME="Editor.__marginHoverStart" ID="Editor.__marginHoverStart"></a>
+<h4>Editor.__marginHoverStart</h4>
+<b>__marginHoverStart</b>(<i>pos, x, y</i>)
+<p>
+        Private slot showing the text of a syntax error or a warning marker.
+</p>
+
+<dl>
+
+<dt><i>pos</i> (int)</dt>
+<dd>
+mouse position into the document
+</dd>
+<dt><i>x</i> (int)</dt>
+<dd>
+x-value of mouse screen position
+</dd>
+<dt><i>y</i> (int)</dt>
+<dd>
+y-value of mouse screen position
+</dd>
+</dl>
 <a NAME="Editor.__marginNumber" ID="Editor.__marginNumber"></a>
 <h4>Editor.__marginNumber</h4>
 <b>__marginNumber</b>(<i>xPos</i>)
--- a/src/eric7/Documentation/Source/eric7.QScintilla.QsciScintillaCompat.html	Sat Jan 13 12:58:16 2024 +0100
+++ b/src/eric7/Documentation/Source/eric7.QScintilla.QsciScintillaCompat.html	Sat Jan 13 13:01:09 2024 +0100
@@ -2083,7 +2083,7 @@
 
 <dl>
 
-<dt><i>point</i> (QPoin)</dt>
+<dt><i>point</i> (QPoint)</dt>
 <dd>
 point to be converted
 </dd>
--- a/src/eric7/QScintilla/Editor.py	Sat Jan 13 12:58:16 2024 +0100
+++ b/src/eric7/QScintilla/Editor.py	Sat Jan 13 13:01:09 2024 +0100
@@ -490,6 +490,11 @@
         self.gotoLine(1)
 
         # connect the mouse hover signals
+        # mouse hover for the editor margins
+        self.SCN_DWELLSTART.connect(self.__marginHoverStart)
+        self.SCN_DWELLEND.connect(self.__marginHoverEnd)
+
+        # mouse hover help for the editor text
         self.SCN_DWELLSTART.connect(self.__showMouseHoverHelp)
         self.SCN_DWELLEND.connect(self.__cancelMouseHoverHelp)
         self.__mouseHoverHelp = None
@@ -3959,6 +3964,51 @@
             elif self.markersAtLine(line) & (1 << self.warning):
                 self.__showWarning(line)
 
+    @pyqtSlot(int, int, int)
+    def __marginHoverStart(self, pos, x, y):
+        """
+        Private slot showing the text of a syntax error or a warning marker.
+
+        @param pos mouse position into the document
+        @type int
+        @param x x-value of mouse screen position
+        @type int
+        @param y y-value of mouse screen position
+        @type int
+        """
+        from PyQt6.QtGui import QCursor
+        from PyQt6.QtWidgets import QToolTip
+        margin = self.__marginNumber(x)
+        if margin == self.__indicMargin:
+            # determine width of all margins; needed to calculate document line
+            width = 0
+            for margin in range(5):
+                width += self.marginWidth(margin)
+
+            message = ""
+            line = self.lineIndexFromPoint(QPoint(width + 1, y))[0]
+            if self.markersAtLine(line) & (1 << self.syntaxerror):
+                for handle in self.syntaxerrors:
+                    if self.markerLine(handle) == line:
+                        message = "\n".join([e[0] for e in self.syntaxerrors[handle]])
+                        break
+            elif self.markersAtLine(line) & (1 << self.warning):
+                for handle in self._warnings:
+                    if self.markerLine(handle) == line:
+                        message = "\n".join([w[0] for w in self._warnings[handle]])
+                        break
+
+            if message:
+                QToolTip.showText(QCursor.pos(), message)
+
+    @pyqtSlot()
+    def __marginHoverEnd(self):
+        """
+        Private slot cancelling the display of syntax error or a warning marker text.
+        """
+        from PyQt6.QtWidgets import QToolTip
+        QToolTip.hideText()
+
     @pyqtSlot()
     def handleMonospacedEnable(self):
         """
@@ -6697,9 +6747,7 @@
         ):
             return
 
-        if Preferences.getEditor("AutoCheckSyntax") and Preferences.getEditor(
-            "OnlineSyntaxCheck"
-        ):
+        if Preferences.getEditor("OnlineSyntaxCheck"):
             self.__onlineSyntaxCheckTimer.stop()
 
         if self.isPy3File():

eric ide

mercurial