7777 QtAlignCenterTop , QtAlignJustify , QtAlignLeft , QtAlignLeftTop ,
7878 QtAlignRight , QtImCursorRectangle , QtKeepAnchor , QtModCtrl , QtModNone ,
7979 QtModShift , QtMouseLeft , QtMoveAnchor , QtMoveLeft , QtMoveRight ,
80- QtScrollAlwaysOff , QtScrollAsNeeded , QtTransparent
80+ QtScrollAlwaysOff , QtScrollAsNeeded , QtSelectBlock , QtSelectDocument ,
81+ QtSelectWord , QtTransparent
8182)
8283
8384logger = logging .getLogger (__name__ )
@@ -672,7 +673,7 @@ def toggleSpellCheck(self, state: bool | None) -> None:
672673 self .spellCheckStateChanged .emit (state )
673674 self .spellCheckDocument ()
674675
675- logger .debug ("Spell check is set to '%s'" , str ( state ) )
676+ logger .debug ("Spell check is set to '%s'" , state )
676677
677678 def spellCheckDocument (self ) -> None :
678679 """Rerun the highlighter to update spell checking status of the
@@ -731,9 +732,9 @@ def docAction(self, action: nwDocAction) -> bool:
731732 elif action == nwDocAction .D_QUOTE :
732733 self ._wrapSelection (CONFIG .fmtDQuoteOpen , CONFIG .fmtDQuoteClose )
733734 elif action == nwDocAction .SEL_ALL :
734- self ._makeSelection (QTextCursor . SelectionType . Document )
735+ self ._makeSelection (QtSelectDocument )
735736 elif action == nwDocAction .SEL_PARA :
736- self ._makeSelection (QTextCursor . SelectionType . BlockUnderCursor )
737+ self ._makeSelection (QtSelectBlock )
737738 elif action == nwDocAction .BLOCK_H1 :
738739 self ._formatBlock (nwDocAction .BLOCK_H1 )
739740 elif action == nwDocAction .BLOCK_H2 :
@@ -785,7 +786,7 @@ def docAction(self, action: nwDocAction) -> bool:
785786 elif action == nwDocAction .SC_SUB :
786787 self ._wrapSelection (nwShortcode .SUB_O , nwShortcode .SUB_C )
787788 else :
788- logger .debug ("Unknown or unsupported document action '%s'" , str ( action ) )
789+ logger .debug ("Unknown or unsupported document action '%s'" , action )
789790 self ._allowAutoReplace (True )
790791 return False
791792
@@ -1174,13 +1175,9 @@ def _openContextMenu(self, pos: QPoint) -> None:
11741175 action = qtAddAction (ctxMenu , self .tr ("Select All" ))
11751176 action .triggered .connect (qtLambda (self .docAction , nwDocAction .SEL_ALL ))
11761177 action = qtAddAction (ctxMenu , self .tr ("Select Word" ))
1177- action .triggered .connect (qtLambda (
1178- self ._makePosSelection , QTextCursor .SelectionType .WordUnderCursor , pos ,
1179- ))
1178+ action .triggered .connect (qtLambda (self ._makePosSelection , QtSelectWord , pos ))
11801179 action = qtAddAction (ctxMenu , self .tr ("Select Paragraph" ))
1181- action .triggered .connect (qtLambda (
1182- self ._makePosSelection , QTextCursor .SelectionType .BlockUnderCursor , pos
1183- ))
1180+ action .triggered .connect (qtLambda (self ._makePosSelection , QtSelectBlock , pos ))
11841181
11851182 # Spell Checking
11861183 if SHARED .project .data .spellCheck :
@@ -1750,7 +1747,7 @@ def _processBlockFormat(
17501747 elif action == nwDocAction .BLOCK_TXT :
17511748 text = temp
17521749 else :
1753- logger .error ("Unknown or unsupported block format requested: '%s'" , str ( action ) )
1750+ logger .error ("Unknown or unsupported block format requested: '%s'" , action )
17541751 return nwDocAction .NO_ACTION , "" , 0
17551752
17561753 return action , text , offset
@@ -1760,7 +1757,7 @@ def _formatBlock(self, action: nwDocAction) -> bool:
17601757 cursor = self .textCursor ()
17611758 block = cursor .block ()
17621759 if not block .isValid ():
1763- logger .debug ("Invalid block selected for action '%s'" , str ( action ) )
1760+ logger .debug ("Invalid block selected for action '%s'" , action )
17641761 return False
17651762
17661763 action , text , offset = self ._processBlockFormat (action , block .text ())
@@ -1770,7 +1767,7 @@ def _formatBlock(self, action: nwDocAction) -> bool:
17701767 pos = cursor .position ()
17711768
17721769 cursor .beginEditBlock ()
1773- self ._makeSelection (QTextCursor . SelectionType . BlockUnderCursor , cursor )
1770+ self ._makeSelection (QtSelectBlock , cursor )
17741771 cursor .insertText (text )
17751772 cursor .endEditBlock ()
17761773
@@ -1798,7 +1795,7 @@ def _iterFormatBlocks(self, action: nwDocAction) -> bool:
17981795 if pAction != nwDocAction .NO_ACTION and blockText .strip ():
17991796 action = pAction # First block decides further actions
18001797 cursor .setPosition (block .position ())
1801- self ._makeSelection (QTextCursor . SelectionType . BlockUnderCursor , cursor )
1798+ self ._makeSelection (QtSelectBlock , cursor )
18021799 cursor .insertText (text )
18031800 toggle = False
18041801
@@ -1818,7 +1815,7 @@ def _removeInParLineBreaks(self) -> None:
18181815 """Strip line breaks within paragraphs in the selected text."""
18191816 cursor = self .textCursor ()
18201817 if not cursor .hasSelection ():
1821- cursor .select (QTextCursor . SelectionType . Document )
1818+ cursor .select (QtSelectDocument )
18221819
18231820 rS = 0
18241821 rE = self ._qDocument .characterCount ()
@@ -2035,10 +2032,10 @@ def _makeSelection(
20352032 cursor .clearSelection ()
20362033 cursor .select (mode )
20372034
2038- if mode == QTextCursor . SelectionType . WordUnderCursor :
2035+ if mode == QtSelectWord :
20392036 cursor = self ._autoSelect ()
20402037
2041- elif mode == QTextCursor . SelectionType . BlockUnderCursor :
2038+ elif mode == QtSelectBlock :
20422039 # This selection mode also selects the preceding paragraph
20432040 # separator, which we want to avoid.
20442041 posS = cursor .selectionStart ()
0 commit comments