Added the menu entry and handling of block formats

This commit is contained in:
Veronica K. B. Olsen
2019-11-21 14:00:55 +01:00
parent 8396e237c0
commit 20e1c2f6f2
3 changed files with 70 additions and 5 deletions
+22
View File
@@ -440,6 +440,16 @@ class GuiDocEditor(QTextEdit):
self._findPrev()
elif theAction == nwDocAction.REPL_NEXT:
self._replaceNext()
elif theAction == nwDocAction.BLOCK_H1:
self._formatBlock(nwDocAction.BLOCK_H1)
elif theAction == nwDocAction.BLOCK_H2:
self._formatBlock(nwDocAction.BLOCK_H2)
elif theAction == nwDocAction.BLOCK_H3:
self._formatBlock(nwDocAction.BLOCK_H3)
elif theAction == nwDocAction.BLOCK_H4:
self._formatBlock(nwDocAction.BLOCK_H4)
elif theAction == nwDocAction.BLOCK_COM:
self._formatBlock(nwDocAction.BLOCK_COM)
else:
logger.debug("Unknown or unsupported document action %s" % str(theAction))
return False
@@ -768,6 +778,18 @@ class GuiDocEditor(QTextEdit):
logger.warning("No selection made, nothing to do")
return
def _formatBlock(self, docAction):
"""Changes the block format of the block under the cursor.
"""
theCursor = self.textCursor()
theBlock = theCursor.block()
if theBlock.isValid():
theText = theBlock.text()
print(theText)
return
def _makeSelection(self, selMode):
theCursor = self.textCursor()
theCursor.clearSelection()