Only apply format to the first block when multiple blocks are selected
This commit is contained in:
+1
-1
@@ -955,4 +955,4 @@ class Config:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# End Class Config
|
# END Class Config
|
||||||
|
|||||||
+13
-1
@@ -1299,13 +1299,25 @@ class GuiDocEditor(QTextEdit):
|
|||||||
return theCursor
|
return theCursor
|
||||||
|
|
||||||
def _toggleFormat(self, fLen, fChar):
|
def _toggleFormat(self, fLen, fChar):
|
||||||
"""Toggle strikethrough text.
|
"""Toggle the formatting of a specific type for a piece of text.
|
||||||
|
If more than one block is selected, the formatting is applied to
|
||||||
|
the first block.
|
||||||
"""
|
"""
|
||||||
theCursor = self._autoSelect()
|
theCursor = self._autoSelect()
|
||||||
if theCursor.hasSelection():
|
if theCursor.hasSelection():
|
||||||
posS = theCursor.selectionStart()
|
posS = theCursor.selectionStart()
|
||||||
posE = theCursor.selectionEnd()
|
posE = theCursor.selectionEnd()
|
||||||
|
|
||||||
|
blockS = self.qDocument.findBlock(posS)
|
||||||
|
blockE = self.qDocument.findBlock(posE)
|
||||||
|
|
||||||
|
if blockS != blockE:
|
||||||
|
posE = blockS.position() + blockS.length() - 1
|
||||||
|
theCursor.clearSelection()
|
||||||
|
theCursor.setPosition(posS, QTextCursor.MoveAnchor)
|
||||||
|
theCursor.setPosition(posE, QTextCursor.KeepAnchor)
|
||||||
|
self.setTextCursor(theCursor)
|
||||||
|
|
||||||
numB = 0
|
numB = 0
|
||||||
for n in range(fLen):
|
for n in range(fLen):
|
||||||
if self.qDocument.characterAt(posS-n-1) == fChar:
|
if self.qDocument.characterAt(posS-n-1) == fChar:
|
||||||
|
|||||||
Reference in New Issue
Block a user