Skip to content

Commit e2fff49

Browse files
committed
added support to paste multi-line text
1 parent a090559 commit e2fff49

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

python/console_sci.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ def keyPressEvent(self, e):
351351
#pass
352352
else:
353353
if (e.key() == Qt.Key_Return or e.key() == Qt.Key_Enter) and not self.isListActive():
354-
self.entered()
354+
self.entered()
355+
elif e.modifiers() & Qt.ControlModifier:
356+
if e.key() == Qt.Key_V:
357+
self.paste()
355358
elif e.key() == Qt.Key_Backspace:
356359
curPos, pos = self.getCursorPosition()
357360
line = self.lines() -1
@@ -419,12 +422,8 @@ def keyPressEvent(self, e):
419422

420423
def paste(self):
421424
"""Reimplement QScintilla method"""
422-
# Moving cursor to the end of the last line
423-
self.move_cursor_to_end()
424-
#QsciScintilla.paste(self)
425-
QMessageBox.warning(self, "Python Console",
426-
"Currently the action paste in console is not supported!")
427-
return
425+
stringPaste = unicode(QApplication.clipboard().text())
426+
self.insertFromDropPaste(stringPaste)
428427

429428
## Drag and drop
430429
def dragEnterEvent(self, e):
@@ -435,8 +434,11 @@ def dragEnterEvent(self, e):
435434

436435
def dropEvent(self, e):
437436
stringDrag = e.mimeData().text()
437+
self.insertFromDropPaste(stringDrag)
438+
439+
def insertFromDropPaste(self, textDP):
438440
pasteList = QStringList()
439-
pasteList = stringDrag.split("\n")
441+
pasteList = textDP.split("\n")
440442
for line in pasteList[:-1]:
441443
self.append(line)
442444
self.move_cursor_to_end()

0 commit comments

Comments
 (0)