Merge branch 'main' into syntax
This commit is contained in:
+1
-1
@@ -955,4 +955,4 @@ class Config:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# End Class Config
|
# END Class Config
|
||||||
|
|||||||
+31
-8
@@ -756,8 +756,8 @@ class GuiDocEditor(QTextEdit):
|
|||||||
* The return and enter key redirects here even if the search
|
* The return and enter key redirects here even if the search
|
||||||
box has focus. Since we need these keys to continue search,
|
box has focus. Since we need these keys to continue search,
|
||||||
we block any further interaction here while it's in focus.
|
we block any further interaction here while it's in focus.
|
||||||
* The undo/redo sequences bypasses the doAction pathway from
|
* The undo/redo/select all sequences bypasses the docAction
|
||||||
the menu, so we redirect them back from here.
|
pathway from the menu, so we redirect them back from here.
|
||||||
"""
|
"""
|
||||||
isReturn = keyEvent.key() == Qt.Key_Return
|
isReturn = keyEvent.key() == Qt.Key_Return
|
||||||
isReturn |= keyEvent.key() == Qt.Key_Enter
|
isReturn |= keyEvent.key() == Qt.Key_Enter
|
||||||
@@ -767,6 +767,8 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.docAction(nwDocAction.REDO)
|
self.docAction(nwDocAction.REDO)
|
||||||
elif keyEvent == QKeySequence.Undo:
|
elif keyEvent == QKeySequence.Undo:
|
||||||
self.docAction(nwDocAction.UNDO)
|
self.docAction(nwDocAction.UNDO)
|
||||||
|
elif keyEvent == QKeySequence.SelectAll:
|
||||||
|
self.docAction(nwDocAction.SEL_ALL)
|
||||||
else:
|
else:
|
||||||
QTextEdit.keyPressEvent(self, keyEvent)
|
QTextEdit.keyPressEvent(self, keyEvent)
|
||||||
self.docFooter.updateLineCount()
|
self.docFooter.updateLineCount()
|
||||||
@@ -1235,6 +1237,11 @@ class GuiDocEditor(QTextEdit):
|
|||||||
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.clearSelection()
|
||||||
theCursor.beginEditBlock()
|
theCursor.beginEditBlock()
|
||||||
theCursor.setPosition(posE)
|
theCursor.setPosition(posE)
|
||||||
@@ -1243,8 +1250,8 @@ class GuiDocEditor(QTextEdit):
|
|||||||
theCursor.insertText(tBefore)
|
theCursor.insertText(tBefore)
|
||||||
theCursor.endEditBlock()
|
theCursor.endEditBlock()
|
||||||
|
|
||||||
theCursor.setPosition(posE + len(tBefore))
|
theCursor.setPosition(posE + len(tBefore), QTextCursor.MoveAnchor)
|
||||||
theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, posE-posS)
|
theCursor.setPosition(posS + len(tBefore), QTextCursor.KeepAnchor)
|
||||||
self.setTextCursor(theCursor)
|
self.setTextCursor(theCursor)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -1292,20 +1299,33 @@ class GuiDocEditor(QTextEdit):
|
|||||||
reSelect = True
|
reSelect = True
|
||||||
if reSelect:
|
if reSelect:
|
||||||
theCursor.clearSelection()
|
theCursor.clearSelection()
|
||||||
theCursor.setPosition(posE-1)
|
theCursor.setPosition(posS, QTextCursor.MoveAnchor)
|
||||||
theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, posE-posS-1)
|
theCursor.setPosition(posE-1, QTextCursor.KeepAnchor)
|
||||||
|
|
||||||
self.setTextCursor(theCursor)
|
self.setTextCursor(theCursor)
|
||||||
|
|
||||||
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:
|
||||||
@@ -1417,7 +1437,10 @@ class GuiDocEditor(QTextEdit):
|
|||||||
theCursor.clearSelection()
|
theCursor.clearSelection()
|
||||||
theCursor.select(selMode)
|
theCursor.select(selMode)
|
||||||
|
|
||||||
if selMode == QTextCursor.BlockUnderCursor:
|
if selMode == QTextCursor.WordUnderCursor:
|
||||||
|
theCursor = self._autoSelect()
|
||||||
|
|
||||||
|
elif selMode == QTextCursor.BlockUnderCursor:
|
||||||
# This selection mode also selects the preceding oaragraph
|
# This selection mode also selects the preceding oaragraph
|
||||||
# separator, which we want to avoid.
|
# separator, which we want to avoid.
|
||||||
posS = theCursor.selectionStart()
|
posS = theCursor.selectionStart()
|
||||||
|
|||||||
Reference in New Issue
Block a user