Update docs and add menu entries for special titles (#850)
* Update Introduction chapter * Update User Interface chapter * Update Novel Projects chapter * Update Novel Structure chapter * Update Exporting Projects chapter * Drop the asterisk notation for unnumbered chapters * Add menu entries and tests for Novel Title and Unnumbered Chapter block formats
This commit is contained in:
committed by
GitHub
parent
669f013c96
commit
460b350d85
@@ -631,9 +631,7 @@ class Tokenizer():
|
||||
# Chapter
|
||||
|
||||
# Numbered or Unnumbered
|
||||
if tToken[2].startswith("*"):
|
||||
tTemp = self._formatHeading(self.fmtUnNum, tToken[2][1:].lstrip())
|
||||
elif tToken[0] == self.T_UNNUM:
|
||||
if tToken[0] == self.T_UNNUM:
|
||||
tTemp = self._formatHeading(self.fmtUnNum, tToken[2])
|
||||
else:
|
||||
self.numChapter += 1
|
||||
|
||||
+10
-8
@@ -84,14 +84,16 @@ class nwDocAction(Enum):
|
||||
BLOCK_H4 = 16
|
||||
BLOCK_COM = 17
|
||||
BLOCK_TXT = 18
|
||||
REPL_SNG = 19
|
||||
REPL_DBL = 20
|
||||
RM_BREAKS = 21
|
||||
ALIGN_L = 22
|
||||
ALIGN_C = 23
|
||||
ALIGN_R = 24
|
||||
INDENT_L = 25
|
||||
INDENT_R = 26
|
||||
BLOCK_TTL = 19
|
||||
BLOCK_UNN = 20
|
||||
REPL_SNG = 21
|
||||
REPL_DBL = 22
|
||||
RM_BREAKS = 23
|
||||
ALIGN_L = 24
|
||||
ALIGN_C = 25
|
||||
ALIGN_R = 26
|
||||
INDENT_L = 27
|
||||
INDENT_R = 28
|
||||
|
||||
# END Enum nwDocAction
|
||||
|
||||
|
||||
@@ -785,6 +785,10 @@ class GuiDocEditor(QTextEdit):
|
||||
self._formatBlock(nwDocAction.BLOCK_COM)
|
||||
elif theAction == nwDocAction.BLOCK_TXT:
|
||||
self._formatBlock(nwDocAction.BLOCK_TXT)
|
||||
elif theAction == nwDocAction.BLOCK_TTL:
|
||||
self._formatBlock(nwDocAction.BLOCK_TTL)
|
||||
elif theAction == nwDocAction.BLOCK_UNN:
|
||||
self._formatBlock(nwDocAction.BLOCK_UNN)
|
||||
elif theAction == nwDocAction.REPL_SNG:
|
||||
self._replaceQuotes("'", self._typSQOpen, self._typSQClose)
|
||||
elif theAction == nwDocAction.REPL_DBL:
|
||||
@@ -1593,6 +1597,12 @@ class GuiDocEditor(QTextEdit):
|
||||
elif theText.startswith("#### "):
|
||||
newText = theText[5:]
|
||||
cOffset = 5
|
||||
elif theText.startswith("#! "):
|
||||
newText = theText[3:]
|
||||
cOffset = 3
|
||||
elif theText.startswith("##! "):
|
||||
newText = theText[4:]
|
||||
cOffset = 4
|
||||
elif theText.startswith(">> "):
|
||||
newText = theText[3:]
|
||||
cOffset = 3
|
||||
@@ -1635,6 +1645,12 @@ class GuiDocEditor(QTextEdit):
|
||||
elif docAction == nwDocAction.BLOCK_H4:
|
||||
theText = "#### "+newText
|
||||
cOffset -= 5
|
||||
elif docAction == nwDocAction.BLOCK_TTL:
|
||||
theText = "#! "+newText
|
||||
cOffset -= 3
|
||||
elif docAction == nwDocAction.BLOCK_UNN:
|
||||
theText = "##! "+newText
|
||||
cOffset -= 4
|
||||
elif docAction == nwDocAction.ALIGN_L:
|
||||
theText = newText+" <<"
|
||||
elif docAction == nwDocAction.ALIGN_C:
|
||||
|
||||
@@ -849,6 +849,21 @@ class GuiMainMenu(QMenuBar):
|
||||
# Format > Separator
|
||||
self.fmtMenu.addSeparator()
|
||||
|
||||
# Format > Novel Title
|
||||
self.aFmtTitle = QAction(self.tr("Novel Title"), self)
|
||||
self.aFmtTitle.setStatusTip(self.tr("Change the block format to Novel Title"))
|
||||
self.aFmtTitle.triggered.connect(lambda: self._docAction(nwDocAction.BLOCK_TTL))
|
||||
self.fmtMenu.addAction(self.aFmtTitle)
|
||||
|
||||
# Format > Unnumbered Chapter
|
||||
self.aFmtUnNum = QAction(self.tr("Unnumbered Chapter"), self)
|
||||
self.aFmtUnNum.setStatusTip(self.tr("Change the block format to Unnumbered Chapter"))
|
||||
self.aFmtUnNum.triggered.connect(lambda: self._docAction(nwDocAction.BLOCK_UNN))
|
||||
self.fmtMenu.addAction(self.aFmtUnNum)
|
||||
|
||||
# Format > Separator
|
||||
self.fmtMenu.addSeparator()
|
||||
|
||||
# Format > Align Left
|
||||
self.aFmtAlignLeft = QAction(self.tr("Align Left"), self)
|
||||
self.aFmtAlignLeft.setStatusTip(self.tr("Change the block alignment to left"))
|
||||
|
||||
Reference in New Issue
Block a user