Fix clipping of cursor due to no document margin (#1113)
This commit is contained in:
@@ -92,6 +92,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
self._spellCheck = False # Flag for spell checking enabled
|
self._spellCheck = False # Flag for spell checking enabled
|
||||||
self._nonWord = "\"'" # Characters to not include in spell checking
|
self._nonWord = "\"'" # Characters to not include in spell checking
|
||||||
|
self._vpMargin = 0 # The editor viewport margin, set during init
|
||||||
|
|
||||||
# Document Variables
|
# Document Variables
|
||||||
self._charCount = 0 # Character count
|
self._charCount = 0 # Character count
|
||||||
@@ -271,9 +272,12 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.docFooter.matchColours()
|
self.docFooter.matchColours()
|
||||||
|
|
||||||
# Set default text margins
|
# Set default text margins
|
||||||
cM = self.mainConf.getTextMargin()
|
# Due to cursor visibility, a part of the margin must be
|
||||||
qDoc.setDocumentMargin(0)
|
# allocated to the document itself. See issue #1112.
|
||||||
self.setViewportMargins(cM, cM, cM, cM)
|
cW = self.cursorWidth()
|
||||||
|
qDoc.setDocumentMargin(cW)
|
||||||
|
self._vpMargin = max(self.mainConf.getTextMargin() - cW, 0)
|
||||||
|
self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin)
|
||||||
|
|
||||||
# Also set the document text options for the document text flow
|
# Also set the document text options for the document text flow
|
||||||
theOpt = QTextOption()
|
theOpt = QTextOption()
|
||||||
@@ -537,7 +541,6 @@ class GuiDocEditor(QTextEdit):
|
|||||||
"""
|
"""
|
||||||
wW = self.width()
|
wW = self.width()
|
||||||
wH = self.height()
|
wH = self.height()
|
||||||
cM = self.mainConf.getTextMargin()
|
|
||||||
|
|
||||||
vBar = self.verticalScrollBar()
|
vBar = self.verticalScrollBar()
|
||||||
sW = vBar.width() if vBar.isVisible() else 0
|
sW = vBar.width() if vBar.isVisible() else 0
|
||||||
@@ -545,10 +548,10 @@ class GuiDocEditor(QTextEdit):
|
|||||||
hBar = self.horizontalScrollBar()
|
hBar = self.horizontalScrollBar()
|
||||||
sH = hBar.height() if hBar.isVisible() else 0
|
sH = hBar.height() if hBar.isVisible() else 0
|
||||||
|
|
||||||
tM = cM
|
tM = self._vpMargin
|
||||||
if self.mainConf.textWidth > 0 or self.mainGui.isFocusMode:
|
if self.mainConf.textWidth > 0 or self.mainGui.isFocusMode:
|
||||||
tW = self.mainConf.getTextWidth(self.mainGui.isFocusMode)
|
tW = self.mainConf.getTextWidth(self.mainGui.isFocusMode)
|
||||||
tM = max((wW - sW - tW)//2, cM)
|
tM = max((wW - sW - tW)//2, self._vpMargin)
|
||||||
|
|
||||||
tB = self.frameWidth()
|
tB = self.frameWidth()
|
||||||
tW = wW - 2*tB - sW
|
tW = wW - 2*tB - sW
|
||||||
@@ -565,8 +568,8 @@ class GuiDocEditor(QTextEdit):
|
|||||||
rL = wW - sW - rW - 2*tB
|
rL = wW - sW - rW - 2*tB
|
||||||
self.docSearch.move(rL, 2*tB)
|
self.docSearch.move(rL, 2*tB)
|
||||||
|
|
||||||
uM = max(cM, tH, rH)
|
uM = max(self._vpMargin, tH, rH)
|
||||||
lM = max(cM, fH)
|
lM = max(self._vpMargin, fH)
|
||||||
self.setViewportMargins(tM, uM, tM, lM)
|
self.setViewportMargins(tM, uM, tM, lM)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user