Skip to content

Commit c5ff5ee

Browse files
committedSep 22, 2012
improved paste action and minor bug fixes
1 parent 7e6ec9b commit c5ff5ee

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed
 

‎python/console_sci.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ def showPrevious(self):
326326
self.move_cursor_to_end()
327327
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)
328328

329-
330329
def showNext(self):
331330
if self.historyIndex > 0 and not self.history.isEmpty():
332331
line, pos = self.getCurLine()
@@ -367,7 +366,6 @@ def keyPressEvent(self, e):
367366
QsciScintilla.keyPressEvent(self, e)
368367
elif e.key() == Qt.Key_Delete:
369368
if self.hasSelectedText():
370-
self.check_selection()
371369
self.removeSelectedText()
372370
elif self.is_cursor_on_last_line():
373371
self.SendScintilla(QsciScintilla.SCI_CLEAR)
@@ -418,28 +416,29 @@ def keyPressEvent(self, e):
418416
def paste(self):
419417
"""Reimplement QScintilla method"""
420418
stringPaste = unicode(QApplication.clipboard().text())
419+
if self.hasSelectedText():
420+
self.removeSelectedText()
421421
self.insertFromDropPaste(stringPaste)
422422

423423
## Drag and drop
424-
def dragEnterEvent(self, e):
425-
if e.mimeData().hasFormat('text/plain'):
424+
def dropEvent(self, e):
425+
if e.mimeData().hasText():
426+
stringDrag = e.mimeData().text()
427+
self.insertFromDropPaste(stringDrag)
428+
e.setDropAction(Qt.MoveAction)
426429
e.accept()
427430
else:
428-
e.ignore()
431+
QsciScintillaCompat.dropEvent(self, e)
429432

430-
def dropEvent(self, e):
431-
stringDrag = e.mimeData().text()
432-
self.insertFromDropPaste(stringDrag)
433-
434433
def insertFromDropPaste(self, textDP):
435434
pasteList = QStringList()
436435
pasteList = textDP.split("\n")
437436
for line in pasteList[:-1]:
438-
self.append(line)
437+
self.insert(line)
439438
self.move_cursor_to_end()
440439
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)
441440
self.runCommand(unicode(self.currentCommand()))
442-
self.append(unicode(pasteList[-1]))
441+
self.insert(unicode(pasteList[-1]))
443442
self.move_cursor_to_end()
444443

445444
def getTextFromEditor(self):

0 commit comments

Comments
 (0)
Please sign in to comment.