Improved the undo/redo of autoreplace, bgut still not perfect.

This commit is contained in:
Veronica K. B. Olsen
2019-04-23 17:09:23 +02:00
parent ffc577c943
commit 5f5088a928
+22 -12
View File
@@ -168,42 +168,52 @@ class GuiDocEditor(QTextEdit):
theThree = theText[thePos-3:thePos] theThree = theText[thePos-3:thePos]
if self.mainConf.doReplaceDQuote and theTwo == " \"": if self.mainConf.doReplaceDQuote and theTwo == " \"":
theCursor.deletePreviousChar() theCursor.beginEditBlock()
theCursor.insertText(self.typSQOpen) theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, 1)
theCursor.insertText(self.typDQOpen)
theCursor.endEditBlock()
elif self.mainConf.doReplaceDQuote and theOne == "\"": elif self.mainConf.doReplaceDQuote and theOne == "\"":
theCursor.deletePreviousChar() theCursor.beginEditBlock()
theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, 1)
if thePos == 1: if thePos == 1:
theCursor.insertText(self.typDQOpen) theCursor.insertText(self.typDQOpen)
else: else:
theCursor.insertText(self.typDQClose) theCursor.insertText(self.typDQClose)
theCursor.endEditBlock()
elif self.mainConf.doReplaceSQuote and theTwo == " '": elif self.mainConf.doReplaceSQuote and theTwo == " '":
theCursor.deletePreviousChar() theCursor.beginEditBlock()
theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, 1)
theCursor.insertText(self.typSQOpen) theCursor.insertText(self.typSQOpen)
theCursor.endEditBlock()
elif self.mainConf.doReplaceSQuote and theOne == "'": elif self.mainConf.doReplaceSQuote and theOne == "'":
theCursor.deletePreviousChar() theCursor.beginEditBlock()
theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, 1)
if thePos == 1: if thePos == 1:
theCursor.insertText(self.typSQOpen) theCursor.insertText(self.typSQOpen)
else: else:
theCursor.insertText(self.typSQClose) theCursor.insertText(self.typSQClose)
theCursor.endEditBlock()
elif self.mainConf.doReplaceDash and theTwo == "--": elif self.mainConf.doReplaceDash and theTwo == "--":
theCursor.deletePreviousChar() theCursor.beginEditBlock()
theCursor.deletePreviousChar() theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, 2)
theCursor.insertText("") theCursor.insertText("")
theCursor.endEditBlock()
elif self.mainConf.doReplaceDash and theTwo == "-": elif self.mainConf.doReplaceDash and theTwo == "-":
theCursor.deletePreviousChar() theCursor.beginEditBlock()
theCursor.deletePreviousChar() theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, 2)
theCursor.insertText("") theCursor.insertText("")
theCursor.endEditBlock()
elif self.mainConf.doReplaceDots and theThree == "...": elif self.mainConf.doReplaceDots and theThree == "...":
theCursor.deletePreviousChar() theCursor.beginEditBlock()
theCursor.deletePreviousChar() theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, 3)
theCursor.deletePreviousChar()
theCursor.insertText("") theCursor.insertText("")
theCursor.endEditBlock()
return return