Shell: corrected inserting (pasting) text via the middel mouse button.

Sun, 17 Jan 2021 12:40:19 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 17 Jan 2021 12:40:19 +0100
changeset 7990
3b865f4b7dff
parent 7989
a21d673a8f99
child 7992
0d1e35a10a0b

Shell: corrected inserting (pasting) text via the middel mouse button.

eric6/APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
eric6/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
eric6/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
eric6/Documentation/Source/eric6.QScintilla.Shell.html file | annotate | diff | comparison | revisions
eric6/QScintilla/Shell.py file | annotate | diff | comparison | revisions
--- a/eric6/APIs/Python3/eric6.api	Sat Jan 16 16:51:23 2021 +0100
+++ b/eric6/APIs/Python3/eric6.api	Sun Jan 17 12:40:19 2021 +0100
@@ -962,6 +962,8 @@
 eric6.DocumentationTools.TemplatesListsStyle.signalsListEntryTemplate?7
 eric6.DocumentationTools.TemplatesListsStyle.signalsListTemplate?7
 eric6.DocumentationTools.TemplatesListsStyle.sinceInfoTemplate?7
+eric6.DocumentationTools.TemplatesListsStyle.yieldTypesTemplate?7
+eric6.DocumentationTools.TemplatesListsStyle.yieldsTemplate?7
 eric6.DocumentationTools.TemplatesListsStyleCSS.authorInfoTemplate?7
 eric6.DocumentationTools.TemplatesListsStyleCSS.classTemplate?7
 eric6.DocumentationTools.TemplatesListsStyleCSS.constructorTemplate?7
@@ -999,6 +1001,8 @@
 eric6.DocumentationTools.TemplatesListsStyleCSS.signalsListEntryTemplate?7
 eric6.DocumentationTools.TemplatesListsStyleCSS.signalsListTemplate?7
 eric6.DocumentationTools.TemplatesListsStyleCSS.sinceInfoTemplate?7
+eric6.DocumentationTools.TemplatesListsStyleCSS.yieldTypesTemplate?7
+eric6.DocumentationTools.TemplatesListsStyleCSS.yieldsTemplate?7
 eric6.DocumentationTools.supportedExtensionsDictForApis?7
 eric6.E5Graphics.E5ArrowItem.ArrowheadAngleFactor?7
 eric6.E5Graphics.E5ArrowItem.E5ArrowItem.boundingRect?4()
@@ -8362,7 +8366,7 @@
 eric6.QScintilla.Shell.Shell.keyPressEvent?4(ev)
 eric6.QScintilla.Shell.Shell.loadHistory?4(clientType)
 eric6.QScintilla.Shell.Shell.mousePressEvent?4(event)
-eric6.QScintilla.Shell.Shell.paste?4()
+eric6.QScintilla.Shell.Shell.paste?4(lines=None)
 eric6.QScintilla.Shell.Shell.queueText?7
 eric6.QScintilla.Shell.Shell.reloadHistory?4()
 eric6.QScintilla.Shell.Shell.saveHistory?4(clientType)
Binary file eric6/Documentation/Help/source.qch has changed
--- a/eric6/Documentation/Help/source.qhp	Sat Jan 16 16:51:23 2021 +0100
+++ b/eric6/Documentation/Help/source.qhp	Sun Jan 17 12:40:19 2021 +0100
@@ -13009,7 +13009,6 @@
       <keyword name="Shell.__insertTextNoEcho" id="Shell.__insertTextNoEcho" ref="eric6.QScintilla.Shell.html#Shell.__insertTextNoEcho" />
       <keyword name="Shell.__isCursorOnLastLine" id="Shell.__isCursorOnLastLine" ref="eric6.QScintilla.Shell.html#Shell.__isCursorOnLastLine" />
       <keyword name="Shell.__isHistoryIndexValid" id="Shell.__isHistoryIndexValid" ref="eric6.QScintilla.Shell.html#Shell.__isHistoryIndexValid" />
-      <keyword name="Shell.__middleMouseButton" id="Shell.__middleMouseButton" ref="eric6.QScintilla.Shell.html#Shell.__middleMouseButton" />
       <keyword name="Shell.__projectClosed" id="Shell.__projectClosed" ref="eric6.QScintilla.Shell.html#Shell.__projectClosed" />
       <keyword name="Shell.__projectOpened" id="Shell.__projectOpened" ref="eric6.QScintilla.Shell.html#Shell.__projectOpened" />
       <keyword name="Shell.__raw_input" id="Shell.__raw_input" ref="eric6.QScintilla.Shell.html#Shell.__raw_input" />
--- a/eric6/Documentation/Source/eric6.QScintilla.Shell.html	Sat Jan 16 16:51:23 2021 +0100
+++ b/eric6/Documentation/Source/eric6.QScintilla.Shell.html	Sun Jan 17 12:40:19 2021 +0100
@@ -316,10 +316,6 @@
 <td>Private method to test, if the history index is valid.</td>
 </tr>
 <tr>
-<td><a href="#Shell.__middleMouseButton">__middleMouseButton</a></td>
-<td>Private method to handle the middle mouse button press.</td>
-</tr>
-<tr>
 <td><a href="#Shell.__projectClosed">__projectClosed</a></td>
 <td>Private slot to restart the default shell when the project is closed.</td>
 </tr>
@@ -1269,13 +1265,6 @@
 bool
 </dd>
 </dl>
-<a NAME="Shell.__middleMouseButton" ID="Shell.__middleMouseButton"></a>
-<h4>Shell.__middleMouseButton</h4>
-<b>__middleMouseButton</b>(<i></i>)
-
-<p>
-        Private method to handle the middle mouse button press.
-</p>
 <a NAME="Shell.__projectClosed" ID="Shell.__projectClosed"></a>
 <h4>Shell.__projectClosed</h4>
 <b>__projectClosed</b>(<i></i>)
@@ -2001,11 +1990,18 @@
 </dl>
 <a NAME="Shell.paste" ID="Shell.paste"></a>
 <h4>Shell.paste</h4>
-<b>paste</b>(<i></i>)
+<b>paste</b>(<i>lines=None</i>)
 
 <p>
         Public slot to handle the paste action.
 </p>
+<dl>
+
+<dt><i>lines</i> (list of str)</dt>
+<dd>
+list of lines to be inserted
+</dd>
+</dl>
 <a NAME="Shell.reloadHistory" ID="Shell.reloadHistory"></a>
 <h4>Shell.reloadHistory</h4>
 <b>reloadHistory</b>(<i></i>)
--- a/eric6/QScintilla/Shell.py	Sat Jan 16 16:51:23 2021 +0100
+++ b/eric6/QScintilla/Shell.py	Sun Jan 17 12:40:19 2021 +0100
@@ -1075,9 +1075,12 @@
             # move cursor to end of line
             self.moveCursorToEOL()
         
-    def paste(self):
+    def paste(self, lines=None):
         """
         Public slot to handle the paste action.
+        
+        @param lines list of lines to be inserted
+        @type list of str
         """
         if self.__isCursorOnLastLine():
             line, col = self.getCursorPosition()
@@ -1113,20 +1116,15 @@
             self.setCursorPosition(line, len(prompt))
             self.deleteLineRight()
             
-            lines = QApplication.clipboard().text()
+            if lines is None:
+                lines = QApplication.clipboard().text()
+            
             lines = lastLine[:col] + lines + lastLine[col:]
             self.executeLines(lines)
             line, _ = self.getCursorPosition()
             pos = len(self.text(line)) - (len(lastLine) - col)
             self.setCursorPosition(line, pos)
-        
-    def __middleMouseButton(self):
-        """
-        Private method to handle the middle mouse button press.
-        """
-        lines = QApplication.clipboard().text(QClipboard.Selection)
-        self.executeLines(lines)
-        
+    
     def executeLines(self, lines, historyIndex=None):
         """
         Public method to execute a set of lines as multiple commands.
@@ -1150,12 +1148,9 @@
             else:
                 line = line[indentLen:]
             
-            if line.endswith("\r\n"):
+            if line.endswith(("\r\n", "\r", "\n")):
                 fullline = True
-                cmd = line[:-2]
-            elif line.endswith("\r") or line.endswith("\n"):
-                fullline = True
-                cmd = line[:-1]
+                cmd = line.rstrip()
             else:
                 fullline = False
             
@@ -1237,7 +1232,8 @@
         """
         self.setFocus()
         if event.button() == Qt.MidButton:
-            self.__middleMouseButton()
+            lines = QApplication.clipboard().text(QClipboard.Selection)
+            self.paste(lines)
         else:
             super(Shell, self).mousePressEvent(event)
         

eric ide

mercurial