Skip to content

Commit

Permalink
Merge pull request #228 from slarosa/master
Browse files Browse the repository at this point in the history
added support to paste code with multi-line text in console
  • Loading branch information
timlinux committed Sep 12, 2012
2 parents 7ce99b8 + e2fff49 commit aa063f6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions python/console_sci.py
Expand Up @@ -351,7 +351,10 @@ def keyPressEvent(self, e):
#pass
else:
if (e.key() == Qt.Key_Return or e.key() == Qt.Key_Enter) and not self.isListActive():
self.entered()
self.entered()
elif e.modifiers() & Qt.ControlModifier:
if e.key() == Qt.Key_V:
self.paste()
elif e.key() == Qt.Key_Backspace:
curPos, pos = self.getCursorPosition()
line = self.lines() -1
Expand Down Expand Up @@ -419,12 +422,8 @@ def keyPressEvent(self, e):

def paste(self):
"""Reimplement QScintilla method"""
# Moving cursor to the end of the last line
self.move_cursor_to_end()
#QsciScintilla.paste(self)
QMessageBox.warning(self, "Python Console",
"Currently the action paste in console is not supported!")
return
stringPaste = unicode(QApplication.clipboard().text())
self.insertFromDropPaste(stringPaste)

## Drag and drop
def dragEnterEvent(self, e):
Expand All @@ -435,8 +434,11 @@ def dragEnterEvent(self, e):

def dropEvent(self, e):
stringDrag = e.mimeData().text()
self.insertFromDropPaste(stringDrag)

def insertFromDropPaste(self, textDP):
pasteList = QStringList()
pasteList = stringDrag.split("\n")
pasteList = textDP.split("\n")
for line in pasteList[:-1]:
self.append(line)
self.move_cursor_to_end()
Expand Down

0 comments on commit aa063f6

Please sign in to comment.