Simplify the typewriter mode
This commit is contained in:
+7
-35
@@ -88,8 +88,6 @@ class GuiDocEditor(QTextEdit):
|
||||
self.bigDoc = False # Flag for very large document size
|
||||
self.doReplace = False # Switch to temporarily disable auto-replace
|
||||
self.queuePos = None # Used for delayed change of cursor position
|
||||
self.cursorLast = 0 # The last known vertical position of the cursor
|
||||
self.lengthLast = 0
|
||||
|
||||
# Typography
|
||||
self.typDQOpen = self.mainConf.fmtDoubleQuotes[0]
|
||||
@@ -102,8 +100,6 @@ class GuiDocEditor(QTextEdit):
|
||||
self.qDocument.contentsChange.connect(self._docChange)
|
||||
self.qDocument.documentLayout().documentSizeChanged.connect(self._docSizeChanged)
|
||||
|
||||
self.verticalScrollBar().sliderMoved.connect(self._doVerticalScroll)
|
||||
|
||||
# Document Title
|
||||
self.docHeader = GuiDocEditHeader(self)
|
||||
self.docFooter = GuiDocEditFooter(self)
|
||||
@@ -440,7 +436,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
if self.mainConf.scrollPastEnd:
|
||||
docFrame = self.qDocument.rootFrame().frameFormat()
|
||||
docMargin = wH - uM - lM - 5*self.theTheme.fontPixelSize
|
||||
docMargin = wH - uM - lM - 4*tB - 5*self.theTheme.fontPixelSize
|
||||
docFrame.setBottomMargin(max(0, docMargin))
|
||||
self.qDocument.rootFrame().setFrameFormat(docFrame)
|
||||
|
||||
@@ -496,7 +492,6 @@ class GuiDocEditor(QTextEdit):
|
||||
theCursor.setPosition(thePosition)
|
||||
self.setTextCursor(theCursor)
|
||||
self.docFooter.updateLineCount()
|
||||
self.cursorLast = self.cursorRect().center().y()
|
||||
|
||||
return True
|
||||
|
||||
@@ -777,20 +772,13 @@ class GuiDocEditor(QTextEdit):
|
||||
self.docFooter.updateLineCount()
|
||||
|
||||
if self.mainConf.scollWithCursor:
|
||||
docLen = self.qDocument.characterCount()
|
||||
if docLen == self.lengthLast:
|
||||
# No change, so just update last position
|
||||
self.cursorLast = self.cursorRect().center().y()
|
||||
else:
|
||||
# The user typed something, so check if we need to
|
||||
# scroll, and move the scroll bar the same distance
|
||||
self.lengthLast = docLen
|
||||
self.ensureCursorVisible()
|
||||
kMod = keyEvent.modifiers()
|
||||
if kMod == Qt.NoModifier or kMod == Qt.ShiftModifier:
|
||||
cPos = self.cursorRect().center().y()
|
||||
if cPos != self.cursorLast:
|
||||
vBar = self.verticalScrollBar()
|
||||
vBar.setValue(vBar.value() + cPos - self.cursorLast)
|
||||
self.cursorLast = self.cursorRect().center().y()
|
||||
mPos = self.mainConf.scollFromPoint*self.height()*0.01
|
||||
vBar = self.verticalScrollBar()
|
||||
vBar.setValue(vBar.value() + cPos - round(mPos))
|
||||
self.ensureCursorVisible()
|
||||
|
||||
return
|
||||
|
||||
@@ -817,18 +805,9 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
QTextEdit.mouseReleaseEvent(self, mEvent)
|
||||
self.docFooter.updateLineCount()
|
||||
self.cursorLast = self.cursorRect().center().y()
|
||||
|
||||
return
|
||||
|
||||
def wheelEvent(self, theEvent):
|
||||
"""Briefly capture the mouse wheel event to capture the cursor
|
||||
position.
|
||||
"""
|
||||
QTextEdit.wheelEvent(self, theEvent)
|
||||
self.cursorLast = self.cursorRect().center().y()
|
||||
return
|
||||
|
||||
def resizeEvent(self, theEvent):
|
||||
"""If the text editor is resize, we must make sure the document
|
||||
has its margins adjusted according to user preferences.
|
||||
@@ -863,13 +842,6 @@ class GuiDocEditor(QTextEdit):
|
||||
self._docAutoReplace(self.qDocument.findBlock(thePos))
|
||||
return
|
||||
|
||||
@pyqtSlot(int)
|
||||
def _doVerticalScroll(self, theChange):
|
||||
"""Update the cursor position on vertical scrolling.
|
||||
"""
|
||||
self.cursorLast = self.cursorRect().center().y()
|
||||
return
|
||||
|
||||
@pyqtSlot("QPoint")
|
||||
def _openContextMenu(self, thePos):
|
||||
"""Triggered by right click to open the context menu. Also
|
||||
|
||||
Reference in New Issue
Block a user