Add block format that completely ignores a line of text in the tokenizer
This commit is contained in:
@@ -107,6 +107,7 @@ Text Formatting Shortcuts
|
||||
":kbd:`Ctrl+D`", "Strike through selected text, or word under cursor"
|
||||
":kbd:`Ctrl+I`", "Format selected text, or word under cursor, with emphasis (italic)"
|
||||
":kbd:`Ctrl+Shift+/`", "Remove block formatting for block under cursor"
|
||||
":kbd:`Ctrl+Shift+D`", "Toggle block format as ignored text"
|
||||
|
||||
|
||||
Other Editor Shortcuts
|
||||
|
||||
@@ -467,6 +467,10 @@ class Tokenizer(ABC):
|
||||
continue
|
||||
|
||||
if aLine[0] == "%":
|
||||
if aLine[1] == "~":
|
||||
# Completely ignore the paragraph
|
||||
continue
|
||||
|
||||
cStyle, cText, _ = processComment(aLine)
|
||||
if cStyle == nwComment.SYNOPSIS:
|
||||
self._tokens.append((
|
||||
|
||||
+18
-17
@@ -108,23 +108,24 @@ class nwDocAction(Enum):
|
||||
BLOCK_H3 = 15
|
||||
BLOCK_H4 = 16
|
||||
BLOCK_COM = 17
|
||||
BLOCK_TXT = 18
|
||||
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
|
||||
SC_ITALIC = 29
|
||||
SC_BOLD = 30
|
||||
SC_STRIKE = 31
|
||||
SC_ULINE = 32
|
||||
SC_SUP = 33
|
||||
SC_SUB = 34
|
||||
BLOCK_IGN = 18
|
||||
BLOCK_TXT = 19
|
||||
BLOCK_TTL = 20
|
||||
BLOCK_UNN = 21
|
||||
REPL_SNG = 22
|
||||
REPL_DBL = 23
|
||||
RM_BREAKS = 24
|
||||
ALIGN_L = 25
|
||||
ALIGN_C = 26
|
||||
ALIGN_R = 27
|
||||
INDENT_L = 28
|
||||
INDENT_R = 29
|
||||
SC_ITALIC = 30
|
||||
SC_BOLD = 31
|
||||
SC_STRIKE = 32
|
||||
SC_ULINE = 33
|
||||
SC_SUP = 34
|
||||
SC_SUB = 35
|
||||
|
||||
# END Enum nwDocAction
|
||||
|
||||
|
||||
@@ -737,6 +737,8 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
self._formatBlock(nwDocAction.BLOCK_H4)
|
||||
elif action == nwDocAction.BLOCK_COM:
|
||||
self._formatBlock(nwDocAction.BLOCK_COM)
|
||||
elif action == nwDocAction.BLOCK_IGN:
|
||||
self._formatBlock(nwDocAction.BLOCK_IGN)
|
||||
elif action == nwDocAction.BLOCK_TXT:
|
||||
self._formatBlock(nwDocAction.BLOCK_TXT)
|
||||
elif action == nwDocAction.BLOCK_TTL:
|
||||
@@ -1648,14 +1650,14 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
if setText.startswith("@"):
|
||||
logger.error("Cannot apply block format to keyword/value line")
|
||||
return False
|
||||
elif setText.startswith("% "):
|
||||
newText = setText[2:]
|
||||
cOffset = 2
|
||||
if action == nwDocAction.BLOCK_COM:
|
||||
elif setText.startswith("%~"):
|
||||
newText = setText[2:].lstrip()
|
||||
cOffset = len(setText) - len(newText)
|
||||
if action == nwDocAction.BLOCK_IGN:
|
||||
action = nwDocAction.BLOCK_TXT
|
||||
elif setText.startswith("%"):
|
||||
newText = setText[1:]
|
||||
cOffset = 1
|
||||
newText = setText[1:].lstrip()
|
||||
cOffset = len(setText) - len(newText)
|
||||
if action == nwDocAction.BLOCK_COM:
|
||||
action = nwDocAction.BLOCK_TXT
|
||||
elif setText.startswith("# "):
|
||||
@@ -1706,6 +1708,9 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
if action == nwDocAction.BLOCK_COM:
|
||||
setText = "% "+newText
|
||||
cOffset -= 2
|
||||
elif action == nwDocAction.BLOCK_IGN:
|
||||
setText = "%~ "+newText
|
||||
cOffset -= 3
|
||||
elif action == nwDocAction.BLOCK_H1:
|
||||
setText = "# "+newText
|
||||
cOffset -= 2
|
||||
|
||||
@@ -781,6 +781,13 @@ class GuiMainMenu(QMenuBar):
|
||||
lambda: self.requestDocAction.emit(nwDocAction.BLOCK_COM)
|
||||
)
|
||||
|
||||
# Format > Ignore Text
|
||||
self.aFmtComment = self.fmtMenu.addAction(self.tr("Toggle Ignore Text"))
|
||||
self.aFmtComment.setShortcut("Ctrl+Shift+D")
|
||||
self.aFmtComment.triggered.connect(
|
||||
lambda: self.requestDocAction.emit(nwDocAction.BLOCK_IGN)
|
||||
)
|
||||
|
||||
# Format > Remove Block Format
|
||||
self.aFmtNoFormat = self.fmtMenu.addAction(self.tr("Remove Block Format"))
|
||||
self.aFmtNoFormat.setShortcuts(["Ctrl+0", "Ctrl+Shift+/"])
|
||||
|
||||
Reference in New Issue
Block a user