Skip to content

Commit

Permalink
improved paste action and minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed Sep 22, 2012
1 parent 7e6ec9b commit c5ff5ee
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions python/console_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ def showPrevious(self):
self.move_cursor_to_end()
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)


def showNext(self):
if self.historyIndex > 0 and not self.history.isEmpty():
line, pos = self.getCurLine()
Expand Down Expand Up @@ -367,7 +366,6 @@ def keyPressEvent(self, e):
QsciScintilla.keyPressEvent(self, e)
elif e.key() == Qt.Key_Delete:
if self.hasSelectedText():
self.check_selection()
self.removeSelectedText()
elif self.is_cursor_on_last_line():
self.SendScintilla(QsciScintilla.SCI_CLEAR)
Expand Down Expand Up @@ -418,28 +416,29 @@ def keyPressEvent(self, e):
def paste(self):
"""Reimplement QScintilla method"""
stringPaste = unicode(QApplication.clipboard().text())
if self.hasSelectedText():
self.removeSelectedText()
self.insertFromDropPaste(stringPaste)

## Drag and drop
def dragEnterEvent(self, e):
if e.mimeData().hasFormat('text/plain'):
def dropEvent(self, e):
if e.mimeData().hasText():
stringDrag = e.mimeData().text()
self.insertFromDropPaste(stringDrag)
e.setDropAction(Qt.MoveAction)
e.accept()
else:
e.ignore()
QsciScintillaCompat.dropEvent(self, e)

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

def insertFromDropPaste(self, textDP):
pasteList = QStringList()
pasteList = textDP.split("\n")
for line in pasteList[:-1]:
self.append(line)
self.insert(line)
self.move_cursor_to_end()
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)
self.runCommand(unicode(self.currentCommand()))
self.append(unicode(pasteList[-1]))
self.insert(unicode(pasteList[-1]))
self.move_cursor_to_end()

def getTextFromEditor(self):
Expand Down

0 comments on commit c5ff5ee

Please sign in to comment.