MicroPythonReplWidget: added special handling for the Return and Enter keys to move the cursor to the end of line before passing it on to the REPL. micropython

Sat, 27 Jul 2019 15:43:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Jul 2019 15:43:21 +0200
branch
micropython
changeset 7087
2ca7fb61a82f
parent 7086
b757db426076
child 7088
e29b0ee86b29

MicroPythonReplWidget: added special handling for the Return and Enter keys to move the cursor to the end of line before passing it on to the REPL.

eric6/MicroPython/MicroPythonReplWidget.py file | annotate | diff | comparison | revisions
--- a/eric6/MicroPython/MicroPythonReplWidget.py	Sat Jul 27 15:41:52 2019 +0200
+++ b/eric6/MicroPython/MicroPythonReplWidget.py	Sat Jul 27 15:43:21 2019 +0200
@@ -406,6 +406,7 @@
             
             self.__replRunning = True
             self.__device.setRepl(True)
+            self.replEdit.setFocus(Qt.OtherFocusReason)
     
     @pyqtSlot()
     def on_disconnectButton_clicked(self):
@@ -431,10 +432,13 @@
         Private slot to perform a paste operation.
         """
         clipboard = QApplication.clipboard()
-        if clipboard and clipboard.text():
-            pasteText = clipboard.text().replace('\n\r', '\r')
-            pasteText = pasteText.replace('\n', '\r')
-            self.__serial and self.__serial.write(pasteText.encode("utf-8"))
+        if clipboard:
+            pasteText = clipboard.text()
+            if pasteText:
+                pasteText = pasteText.replace('\n\r', '\r')
+                pasteText = pasteText.replace('\n', '\r')
+                self.__serial and self.__serial.write(
+                    pasteText.encode("utf-8"))
     
     def eventFilter(self, obj, evt):
         """
@@ -483,6 +487,10 @@
                 elif key == Qt.Key_V:
                     self.__paste()
                     msg = b''
+            elif key in (Qt.Key_Return, Qt.Key_Enter):
+                tc = self.replEdit.textCursor()
+                tc.movePosition(QTextCursor.EndOfLine)
+                self.replEdit.setTextCursor(tc)
             self.__serial and self.__serial.write(msg)
             return True
         

eric ide

mercurial