From 53aa9704277b964945e5a7c189694bd6b3c35014 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 25 Nov 2023 23:42:05 +0100 Subject: [PATCH 1/3] Rename "brief" to "summary" --- novelwriter/assets/i18n/project_en_GB.json | 2 +- novelwriter/core/coretools.py | 2 +- novelwriter/core/index.py | 4 ++-- novelwriter/core/tohtml.py | 4 ++-- novelwriter/core/tokenizer.py | 6 +++--- novelwriter/core/tomd.py | 4 ++-- novelwriter/core/toodt.py | 4 ++-- novelwriter/enum.py | 2 +- novelwriter/gui/docviewerpanel.py | 18 +++++++++--------- sample/content/14298de4d9524.nwd | 4 ++-- sample/content/bb2c23b3c42cc.nwd | 4 ++-- tests/test_core/test_core_index.py | 18 ++++++++++-------- tests/test_core/test_core_tohtml.py | 14 +++++++------- tests/test_core/test_core_tokenizer.py | 8 ++++---- tests/test_core/test_core_tomd.py | 6 +++--- tests/test_core/test_core_toodt.py | 10 +++++----- 16 files changed, 56 insertions(+), 54 deletions(-) diff --git a/novelwriter/assets/i18n/project_en_GB.json b/novelwriter/assets/i18n/project_en_GB.json index f630e22f..d1e27ea9 100644 --- a/novelwriter/assets/i18n/project_en_GB.json +++ b/novelwriter/assets/i18n/project_en_GB.json @@ -1,7 +1,7 @@ { "Synopsis": "Synopsis", + "Summary": "Summary", "Comment": "Comment", - "Brief": "Brief", "Notes": "Notes", "Tag": "Tag", "Point of View": "Point of View", diff --git a/novelwriter/core/coretools.py b/novelwriter/core/coretools.py index fe0b1ba7..d870bb0b 100644 --- a/novelwriter/core/coretools.py +++ b/novelwriter/core/coretools.py @@ -450,7 +450,7 @@ class ProjectBuilder: aDoc.writeDocument( f"# {noteTitles[newRoot]}\n\n" f"@tag: {ntTag}\n\n" - f"% Brief: {bfNote}\n\n" + f"% Summary: {bfNote}\n\n" ) # Also add the archive and trash folders diff --git a/novelwriter/core/index.py b/novelwriter/core/index.py index 1f47256b..4795b30d 100644 --- a/novelwriter/core/index.py +++ b/novelwriter/core/index.py @@ -339,7 +339,7 @@ class NWIndex: elif line.startswith("%"): if cTitle != TT_NONE: cStyle, cText, _ = processComment(line) - if cStyle in (nwComment.BRIEF, nwComment.SYNOPSIS): + if cStyle in (nwComment.SYNOPSIS, nwComment.SUMMARY): self._itemIndex.setHeadingSynopsis(tHandle, cTitle, cText) # Count words for remaining text after last heading @@ -1268,7 +1268,7 @@ class IndexHeading: # =============================================================================================== # CLASSIFIERS = { - "brief": nwComment.BRIEF, + "summary": nwComment.SUMMARY, "synopsis": nwComment.SYNOPSIS, } diff --git a/novelwriter/core/tohtml.py b/novelwriter/core/tohtml.py index 219f6032..762c61c4 100644 --- a/novelwriter/core/tohtml.py +++ b/novelwriter/core/tohtml.py @@ -289,7 +289,7 @@ class ToHtml(Tokenizer): elif tType == self.T_SYNOPSIS and self._doSynopsis: lines.append(self._formatSynopsis(tText, True)) - elif tType == self.T_BRIEF and self._doSynopsis: + elif tType == self.T_SUMMARY and self._doSynopsis: lines.append(self._formatSynopsis(tText, False)) elif tType == self.T_COMMENT and self._doComments: @@ -459,7 +459,7 @@ class ToHtml(Tokenizer): def _formatSynopsis(self, text: str, synopsis: bool) -> str: """Apply HTML formatting to synopsis.""" - sSynop = self._localLookup("Synopsis") if synopsis else self._localLookup("Brief") + sSynop = self._localLookup("Synopsis") if synopsis else self._localLookup("Summary") if self._genMode == self.M_PREVIEW: return f"

{sSynop}: {text}

\n" else: diff --git a/novelwriter/core/tokenizer.py b/novelwriter/core/tokenizer.py index b5d0fd18..70b6d246 100644 --- a/novelwriter/core/tokenizer.py +++ b/novelwriter/core/tokenizer.py @@ -80,7 +80,7 @@ class Tokenizer(ABC): # Block Type T_EMPTY = 1 # Empty line (new paragraph) T_SYNOPSIS = 2 # Synopsis comment - T_BRIEF = 3 # Brief comment + T_SUMMARY = 3 # Summary comment T_COMMENT = 4 # Comment line T_KEYWORD = 5 # Command line T_TITLE = 6 # Title @@ -470,9 +470,9 @@ class Tokenizer(ABC): )) if self._doSynopsis and self._keepMarkdown: tmpMarkdown.append("%s\n" % aLine) - elif cStyle == nwComment.BRIEF: + elif cStyle == nwComment.SUMMARY: self._tokens.append(( - self.T_BRIEF, nHead, cText, None, sAlign + self.T_SUMMARY, nHead, cText, None, sAlign )) if self._doSynopsis and self._keepMarkdown: tmpMarkdown.append("%s\n" % aLine) diff --git a/novelwriter/core/tomd.py b/novelwriter/core/tomd.py index 3187258a..e73e142b 100644 --- a/novelwriter/core/tomd.py +++ b/novelwriter/core/tomd.py @@ -170,8 +170,8 @@ class ToMarkdown(Tokenizer): label = self._localLookup("Synopsis") lines.append(f"**{label}:** {tText}\n\n") - elif tType == self.T_BRIEF and self._doSynopsis: - label = self._localLookup("Brief") + elif tType == self.T_SUMMARY and self._doSynopsis: + label = self._localLookup("Summary") lines.append(f"**{label}:** {tText}\n\n") elif tType == self.T_COMMENT and self._doComments: diff --git a/novelwriter/core/toodt.py b/novelwriter/core/toodt.py index 26cc76b2..ddae70f6 100644 --- a/novelwriter/core/toodt.py +++ b/novelwriter/core/toodt.py @@ -484,7 +484,7 @@ class ToOdt(Tokenizer): tTemp, fTemp = self._formatSynopsis(tText, True) self._addTextPar("Text_20_Meta", oStyle, tTemp, tFmt=fTemp) - elif tType == self.T_BRIEF and self._doSynopsis: + elif tType == self.T_SUMMARY and self._doSynopsis: tTemp, fTemp = self._formatSynopsis(tText, False) self._addTextPar("Text_20_Meta", oStyle, tTemp, tFmt=fTemp) @@ -558,7 +558,7 @@ class ToOdt(Tokenizer): def _formatSynopsis(self, text: str, synopsis: bool) -> tuple[str, list[tuple[int, int]]]: """Apply formatting to synopsis lines.""" - name = self._localLookup("Synopsis") if synopsis else self._localLookup("Brief") + name = self._localLookup("Synopsis") if synopsis else self._localLookup("Summary") rTxt = f"{name}: {text}" rFmt = [(0, self.FMT_B_B), (len(name) + 1, self.FMT_B_E)] return rTxt, rFmt diff --git a/novelwriter/enum.py b/novelwriter/enum.py index 1258e5e2..26d873e8 100644 --- a/novelwriter/enum.py +++ b/novelwriter/enum.py @@ -65,7 +65,7 @@ class nwComment(Enum): PLAIN = 0 SYNOPSIS = 1 - BRIEF = 2 + SUMMARY = 2 # END Enum nwComment diff --git a/novelwriter/gui/docviewerpanel.py b/novelwriter/gui/docviewerpanel.py index 3d6bdfdd..f12a9aac 100644 --- a/novelwriter/gui/docviewerpanel.py +++ b/novelwriter/gui/docviewerpanel.py @@ -316,13 +316,13 @@ class _ViewPanelBackRefs(QTreeWidget): class _ViewPanelKeyWords(QTreeWidget): - C_DATA = 0 - C_NAME = 0 - C_EDIT = 1 - C_VIEW = 2 - C_DOC = 3 - C_TITLE = 4 - C_BRIEF = 5 + C_DATA = 0 + C_NAME = 0 + C_EDIT = 1 + C_VIEW = 2 + C_DOC = 3 + C_TITLE = 4 + C_SUMMARY = 5 D_TAG = Qt.ItemDataRole.UserRole @@ -337,7 +337,7 @@ class _ViewPanelKeyWords(QTreeWidget): self.setHeaderLabels([ self.tr("Tag"), "", "", self.tr("Document"), - self.tr("Heading"), self.tr("Brief") + self.tr("Heading"), self.tr("Summary") ]) self.setIndentation(0) self.setIconSize(QSize(iPx, iPx)) @@ -401,7 +401,7 @@ class _ViewPanelKeyWords(QTreeWidget): trItem.setText(self.C_DOC, nwItem.itemName) trItem.setText(self.C_TITLE, hItem.title) trItem.setData(self.C_TITLE, Qt.ItemDataRole.DecorationRole, hDec) - trItem.setText(self.C_BRIEF, hItem.synopsis) + trItem.setText(self.C_SUMMARY, hItem.synopsis) trItem.setData(self.C_DATA, self.D_TAG, tag) if tag not in self._treeMap: diff --git a/sample/content/14298de4d9524.nwd b/sample/content/14298de4d9524.nwd index 6150d624..9431806c 100644 --- a/sample/content/14298de4d9524.nwd +++ b/sample/content/14298de4d9524.nwd @@ -7,6 +7,6 @@ @tag: John -% Brief: The sidekick +% Summary: The sidekick -He’s pretty cool. Not Brad Pitt though. \ No newline at end of file +He’s pretty cool. Not Brad Pitt though. diff --git a/sample/content/bb2c23b3c42cc.nwd b/sample/content/bb2c23b3c42cc.nwd index d028a12c..ddb0ad5e 100644 --- a/sample/content/bb2c23b3c42cc.nwd +++ b/sample/content/bb2c23b3c42cc.nwd @@ -7,6 +7,6 @@ @tag: Jane -% Brief: The heroine +% Summary: The heroine -She’s pretty cool. Not Angelina Jolie though. \ No newline at end of file +She’s pretty cool. Not Angelina Jolie though. diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index d12ab318..fd07ed70 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -1269,7 +1269,7 @@ def testCoreIndex_processComment(): # Regular comment assert processComment("%Hi") == (nwComment.PLAIN, "Hi", 0) assert processComment("% Hi") == (nwComment.PLAIN, "Hi", 0) - assert processComment("% Hi:you") == (nwComment.PLAIN, "Hi:you", 0) + assert processComment("% Hi:You") == (nwComment.PLAIN, "Hi:You", 0) # Synopsis assert processComment("%synopsis:") == (nwComment.PLAIN, "synopsis:", 0) @@ -1278,14 +1278,16 @@ def testCoreIndex_processComment(): assert processComment("% synopsis : Hi") == (nwComment.SYNOPSIS, "Hi", 13) assert processComment("% Synopsis : Hi") == (nwComment.SYNOPSIS, "Hi", 15) assert processComment("% \t SYNOPSIS : Hi") == (nwComment.SYNOPSIS, "Hi", 16) + assert processComment("% \t SYNOPSIS : Hi:You") == (nwComment.SYNOPSIS, "Hi:You", 16) - # Brief - assert processComment("%brief:") == (nwComment.PLAIN, "brief:", 0) - assert processComment("%brief: Hi") == (nwComment.BRIEF, "Hi", 7) - assert processComment("% brief: Hi") == (nwComment.BRIEF, "Hi", 8) - assert processComment("% brief : Hi") == (nwComment.BRIEF, "Hi", 10) - assert processComment("% Brief : Hi") == (nwComment.BRIEF, "Hi", 12) - assert processComment("% \t BRIEF : Hi") == (nwComment.BRIEF, "Hi", 13) + # Summary + assert processComment("%summary:") == (nwComment.PLAIN, "summary:", 0) + assert processComment("%summary: Hi") == (nwComment.SUMMARY, "Hi", 9) + assert processComment("% summary: Hi") == (nwComment.SUMMARY, "Hi", 10) + assert processComment("% summary : Hi") == (nwComment.SUMMARY, "Hi", 12) + assert processComment("% Summary : Hi") == (nwComment.SUMMARY, "Hi", 14) + assert processComment("% \t SUMMARY : Hi") == (nwComment.SUMMARY, "Hi", 15) + assert processComment("% \t SUMMARY : Hi:You") == (nwComment.SUMMARY, "Hi:You", 15) # END Test testCoreIndex_processComment diff --git a/tests/test_core/test_core_tohtml.py b/tests/test_core/test_core_tohtml.py index 7f616155..47ea7dd0 100644 --- a/tests/test_core/test_core_tohtml.py +++ b/tests/test_core/test_core_tohtml.py @@ -149,7 +149,7 @@ def testCoreToHtml_ConvertFormat(mockGUI): "

Line one
Line two
Line three

\n" ) - # Synopsis, Brief + # Synopsis, Summary html._text = "%synopsis: The synopsis ...\n" html.tokenizeText() html.doConvert() @@ -164,11 +164,11 @@ def testCoreToHtml_ConvertFormat(mockGUI): ) html.setSynopsis(True) - html._text = "%brief: A description ...\n" + html._text = "%summary: A description ...\n" html.tokenizeText() html.doConvert() assert html.theResult == ( - "

Brief: A description ...

\n" + "

Summary: A description ...

\n" ) # Comment @@ -621,8 +621,8 @@ def testCoreToHtml_Format(mockGUI): assert html._formatSynopsis("synopsis text", True) == ( "

Synopsis: synopsis text

\n" ) - assert html._formatSynopsis("brief text", False) == ( - "

Brief: brief text

\n" + assert html._formatSynopsis("summary text", False) == ( + "

Summary: summary text

\n" ) assert html._formatComments("comment text") == ( "

Comment: comment text

\n" @@ -646,8 +646,8 @@ def testCoreToHtml_Format(mockGUI): assert html._formatSynopsis("synopsis text", True) == ( "

Synopsis: synopsis text

\n" ) - assert html._formatSynopsis("brief text", False) == ( - "

Brief: brief text

\n" + assert html._formatSynopsis("summary text", False) == ( + "

Summary: summary text

\n" ) assert html._formatComments("comment text") == ( "

comment text

\n" diff --git a/tests/test_core/test_core_tokenizer.py b/tests/test_core/test_core_tokenizer.py index 3dc513ce..29532d77 100644 --- a/tests/test_core/test_core_tokenizer.py +++ b/tests/test_core/test_core_tokenizer.py @@ -471,19 +471,19 @@ def testCoreToken_MetaFormat(mockGUI): tokens.tokenizeText() assert tokens.theMarkdown[-1] == "% synopsis: The synopsis\n\n" - # Brief + # Summary tokens.setSynopsis(False) - tokens._text = "% brief: A description\n" + tokens._text = "% summary: A description\n" tokens.tokenizeText() assert tokens._tokens == [ - (Tokenizer.T_BRIEF, 0, "A description", None, Tokenizer.A_NONE), + (Tokenizer.T_SUMMARY, 0, "A description", None, Tokenizer.A_NONE), (Tokenizer.T_EMPTY, 0, "", None, Tokenizer.A_NONE), ] assert tokens.theMarkdown[-1] == "\n" tokens.setSynopsis(True) tokens.tokenizeText() - assert tokens.theMarkdown[-1] == "% brief: A description\n\n" + assert tokens.theMarkdown[-1] == "% summary: A description\n\n" # Keyword tokens._text = "@char: Bod\n" diff --git a/tests/test_core/test_core_tomd.py b/tests/test_core/test_core_tomd.py index 78e94230..385af38a 100644 --- a/tests/test_core/test_core_tomd.py +++ b/tests/test_core/test_core_tomd.py @@ -106,7 +106,7 @@ def testCoreToMarkdown_ConvertFormat(mockGUI): theMD.doConvert() assert theMD.theResult == "Line one \nLine two \nLine three\n\n" - # Synopsis, Brief + # Synopsis, Summary theMD._text = "%synopsis: The synopsis ...\n" theMD.tokenizeText() theMD.doConvert() @@ -119,10 +119,10 @@ def testCoreToMarkdown_ConvertFormat(mockGUI): assert theMD.theResult == "**Synopsis:** The synopsis ...\n\n" theMD.setSynopsis(True) - theMD._text = "%brief: A description ...\n" + theMD._text = "%summary: A description ...\n" theMD.tokenizeText() theMD.doConvert() - assert theMD.theResult == "**Brief:** A description ...\n\n" + assert theMD.theResult == "**Summary:** A description ...\n\n" # Comment theMD._text = "% A comment ...\n" diff --git a/tests/test_core/test_core_toodt.py b/tests/test_core/test_core_toodt.py index 04d5180b..3622b4bb 100644 --- a/tests/test_core/test_core_toodt.py +++ b/tests/test_core/test_core_toodt.py @@ -447,12 +447,12 @@ def testCoreToOdt_Convert(mockGUI): '' ) - # Synopsis, Brief, Comment, Keywords + # Synopsis, Summary, Comment, Keywords odt._text = ( "### Scene\n\n" "@pov: Jane\n\n" "% synopsis: So it begins\n\n" - "% brief: Then what\n\n" + "% summary: Then what\n\n" "% A plain comment\n\n" ) odt.setSynopsis(True) @@ -471,7 +471,7 @@ def testCoreToOdt_Convert(mockGUI): '' 'Synopsis: So it begins' '' - 'Brief: Then what' + 'Summary: Then what' '' 'Comment: A plain comment' '' @@ -810,8 +810,8 @@ def testCoreToOdt_Format(mockGUI): assert odt._formatSynopsis("synopsis text", True) == ( "Synopsis: synopsis text", [(0, ToOdt.FMT_B_B), (9, ToOdt.FMT_B_E)] ) - assert odt._formatSynopsis("brief text", False) == ( - "Brief: brief text", [(0, ToOdt.FMT_B_B), (6, ToOdt.FMT_B_E)] + assert odt._formatSynopsis("summary text", False) == ( + "Summary: summary text", [(0, ToOdt.FMT_B_B), (8, ToOdt.FMT_B_E)] ) assert odt._formatComments("comment text") == ( "Comment: comment text", [(0, ToOdt.FMT_B_B), (8, ToOdt.FMT_B_E)] From bedd71b105d5156dc63b0909cea17481bcee8b51 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 25 Nov 2023 23:51:30 +0100 Subject: [PATCH 2/3] Add a summary entry to the insert menu (#1619) --- docs/source/usage_shortcuts.rst | 53 +++++++++++++++++---------------- novelwriter/enum.py | 7 +++-- novelwriter/gui/doceditor.py | 4 +++ novelwriter/gui/mainmenu.py | 7 +++++ 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/docs/source/usage_shortcuts.rst b/docs/source/usage_shortcuts.rst index 0eea9175..6e25ca36 100644 --- a/docs/source/usage_shortcuts.rst +++ b/docs/source/usage_shortcuts.rst @@ -90,6 +90,8 @@ Text Formatting Shortcuts .. csv-table:: :header: "Shortcut", "Description" + ":kbd:`Ctrl+'`", "Wrap selected text, or word under cursor, in single quotes" + ":kbd:`Ctrl+""`", "Wrap selected text, or word under cursor, in double quotes" ":kbd:`Ctrl+/`", "Toggle block format as comment" ":kbd:`Ctrl+0`", "Remove block formatting for block under cursor" ":kbd:`Ctrl+1`", "Change block format to header level 1" @@ -104,8 +106,6 @@ Text Formatting Shortcuts ":kbd:`Ctrl+B`", "Format selected text, or word under cursor, with strong emphasis (bold)" ":kbd:`Ctrl+D`", "Strikethrough selected text, or word under cursor" ":kbd:`Ctrl+I`", "Format selected text, or word under cursor, with emphasis (italic)" - ":kbd:`Ctrl+'`", "Wrap selected text, or word under cursor, in single quotes" - ":kbd:`Ctrl+""`", "Wrap selected text, or word under cursor, in double quotes" ":kbd:`Ctrl+Shift+/`", "Remove block formatting for block under cursor" @@ -127,10 +127,10 @@ Other Editor Shortcuts ":kbd:`Ctrl+X`", "Cut selected text to clipboard" ":kbd:`Ctrl+Y`", "Redo latest undo" ":kbd:`Ctrl+Z`", "Undo latest changes" - ":kbd:`Ctrl+Del`", "Delete the word after the cursor" ":kbd:`Ctrl+Backspace`", "Delete the word before the cursor" - ":kbd:`Ctrl+Return`", "Open the tag or reference under the cursor in the viewer" + ":kbd:`Ctrl+Del`", "Delete the word after the cursor" ":kbd:`Ctrl+F7`", "Toggle spell checking" + ":kbd:`Ctrl+Return`", "Open the tag or reference under the cursor in the viewer" ":kbd:`Ctrl+Shift+A`", "Select all text in the current paragraph" ":kbd:`Ctrl+Shift+I`", "Import text to the current document from a text file" @@ -147,39 +147,40 @@ a key or key combination for the inserted content. .. csv-table:: :header: "Shortcut", "Description" - ":kbd:`Ctrl+K`, :kbd:`−`", "Insert a short dash (en dash)" + ":kbd:`Ctrl+K`, :kbd:`Space`", "Insert a non-breaking space" ":kbd:`Ctrl+K`, :kbd:`_`", "Insert a long dash (em dash)" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+_`", "Insert a horizontal bar (quotation dash)" + ":kbd:`Ctrl+K`, :kbd:`.`", "Insert an ellipsis" + ":kbd:`Ctrl+K`, :kbd:`'`", "Insert a modifier apostrophe" + ":kbd:`Ctrl+K`, :kbd:`*`", "Insert a list bullet" + ":kbd:`Ctrl+K`, :kbd:`%`", "Insert a per mille symbol" ":kbd:`Ctrl+K`, :kbd:`~`", "Insert a figure dash (same width as a number)" + ":kbd:`Ctrl+K`, :kbd:`−`", "Insert a short dash (en dash)" ":kbd:`Ctrl+K`, :kbd:`1`", "Insert a left single quote" ":kbd:`Ctrl+K`, :kbd:`2`", "Insert a right single quote" ":kbd:`Ctrl+K`, :kbd:`3`", "Insert a left double quote" ":kbd:`Ctrl+K`, :kbd:`4`", "Insert a right double quote" - ":kbd:`Ctrl+K`, :kbd:`'`", "Insert a modifier apostrophe" - ":kbd:`Ctrl+K`, :kbd:`.`", "Insert an ellipsis" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+'`", "Insert a prime" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+""`", "Insert a double prime" - ":kbd:`Ctrl+K`, :kbd:`Space`", "Insert a non-breaking space" - ":kbd:`Ctrl+K`, :kbd:`Shift+Space`", "Insert a thin space" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+Space`", "Insert a thin non-breaking space" - ":kbd:`Ctrl+K`, :kbd:`*`", "Insert a list bullet" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+−`", "Insert a hyphen bullet (alternative bullet)" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+*`", "Insert a flower mark (alternative bullet)" - ":kbd:`Ctrl+K`, :kbd:`%`", "Insert a per mille symbol" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+O`", "Insert a degree symbol" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+X`", "Insert a times sign" - ":kbd:`Ctrl+K`, :kbd:`Ctrl+D`", "Insert a division sign" - ":kbd:`Ctrl+K`, :kbd:`G`", "Insert a ``@tag`` keyword" - ":kbd:`Ctrl+K`, :kbd:`V`", "Insert a ``@pov`` keyword" - ":kbd:`Ctrl+K`, :kbd:`F`", "Insert a ``@focus`` keyword" ":kbd:`Ctrl+K`, :kbd:`C`", "Insert a ``@char`` keyword" + ":kbd:`Ctrl+K`, :kbd:`E`", "Insert an ``@entity`` keyword" + ":kbd:`Ctrl+K`, :kbd:`F`", "Insert a ``@focus`` keyword" + ":kbd:`Ctrl+K`, :kbd:`G`", "Insert a ``@tag`` keyword" + ":kbd:`Ctrl+K`, :kbd:`L`", "Insert a ``@location`` keyword" + ":kbd:`Ctrl+K`, :kbd:`O`", "Insert an ``@object`` keyword" ":kbd:`Ctrl+K`, :kbd:`P`", "Insert a ``@plot`` keyword" ":kbd:`Ctrl+K`, :kbd:`S`", "Insert a synopsis comment" ":kbd:`Ctrl+K`, :kbd:`T`", "Insert a ``@time`` keyword" - ":kbd:`Ctrl+K`, :kbd:`L`", "Insert a ``@location`` keyword" - ":kbd:`Ctrl+K`, :kbd:`O`", "Insert an ``@object`` keyword" - ":kbd:`Ctrl+K`, :kbd:`E`", "Insert an ``@entity`` keyword" + ":kbd:`Ctrl+K`, :kbd:`U`", "Insert a summary comment" + ":kbd:`Ctrl+K`, :kbd:`V`", "Insert a ``@pov`` keyword" ":kbd:`Ctrl+K`, :kbd:`X`", "Insert a ``@custom`` keyword" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+Space`", "Insert a thin non-breaking space" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+_`", "Insert a horizontal bar (quotation dash)" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+'`", "Insert a prime" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+""`", "Insert a double prime" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+*`", "Insert a flower mark (alternative bullet)" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+−`", "Insert a hyphen bullet (alternative bullet)" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+D`", "Insert a division sign" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+O`", "Insert a degree symbol" + ":kbd:`Ctrl+K`, :kbd:`Ctrl+X`", "Insert a times sign" + ":kbd:`Ctrl+K`, :kbd:`Shift+Space`", "Insert a thin space" .. _a_kb_viewer: diff --git a/novelwriter/enum.py b/novelwriter/enum.py index 26d873e8..7280dc36 100644 --- a/novelwriter/enum.py +++ b/novelwriter/enum.py @@ -136,9 +136,10 @@ class nwDocInsert(Enum): QUOTE_LD = 3 QUOTE_RD = 4 SYNOPSIS = 5 - NEW_PAGE = 6 - VSPACE_S = 7 - VSPACE_M = 8 + SUMMARY = 6 + NEW_PAGE = 7 + VSPACE_S = 8 + VSPACE_M = 9 # END Enum nwDocInsert diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index fc513485..ec2aeea3 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -834,6 +834,10 @@ class GuiDocEditor(QPlainTextEdit): text = "% Synopsis: " newBlock = True goAfter = True + elif insert == nwDocInsert.SUMMARY: + text = "% Summary: " + newBlock = True + goAfter = True elif insert == nwDocInsert.NEW_PAGE: text = "[newpage]" newBlock = True diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index 1fee411f..40772c5a 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -564,6 +564,13 @@ class GuiMainMenu(QMenuBar): lambda: self.requestDocInsert.emit(nwDocInsert.SYNOPSIS) ) + # Insert > Summary Comment + self.aInsSynopsis = self.mInsComments.addAction(self.tr("Summary Comment")) + self.aInsSynopsis.setShortcut("Ctrl+K, U") + self.aInsSynopsis.triggered.connect( + lambda: self.requestDocInsert.emit(nwDocInsert.SUMMARY) + ) + # Insert > Symbols self.mInsBreaks = self.insMenu.addMenu(self.tr("Page Break and Space")) From 6fd4417350c44316d9f66053cb38d0f745c47b42 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 25 Nov 2023 23:57:12 +0100 Subject: [PATCH 3/3] Fix variable name and test --- novelwriter/gui/mainmenu.py | 6 +++--- novelwriter/guimain.py | 1 + tests/test_gui/test_gui_mainmenu.py | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index 40772c5a..f6fde5c7 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -565,9 +565,9 @@ class GuiMainMenu(QMenuBar): ) # Insert > Summary Comment - self.aInsSynopsis = self.mInsComments.addAction(self.tr("Summary Comment")) - self.aInsSynopsis.setShortcut("Ctrl+K, U") - self.aInsSynopsis.triggered.connect( + self.aInsSummary = self.mInsComments.addAction(self.tr("Summary Comment")) + self.aInsSummary.setShortcut("Ctrl+K, U") + self.aInsSummary.triggered.connect( lambda: self.requestDocInsert.emit(nwDocInsert.SUMMARY) ) diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index 54857de8..65589ed6 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -1461,6 +1461,7 @@ class GuiMain(QMainWindow): self.addAction(self.mainMenu.aInsTimes) self.addAction(self.mainMenu.aInsDivide) self.addAction(self.mainMenu.aInsSynopsis) + self.addAction(self.mainMenu.aInsSummary) for mAction, _ in self.mainMenu.mInsKWItems.values(): self.addAction(mAction) diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py index 5bf25674..b7d8aa0a 100644 --- a/tests/test_gui/test_gui_mainmenu.py +++ b/tests/test_gui/test_gui_mainmenu.py @@ -593,6 +593,10 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd): nwGUI.mainMenu.aInsSynopsis.activate(QAction.Trigger) assert nwGUI.docEditor.getText() == "Stuff\n% Synopsis: \n" + nwGUI.docEditor.setPlainText("Stuff\n") + nwGUI.mainMenu.aInsSummary.activate(QAction.Trigger) + assert nwGUI.docEditor.getText() == "Stuff\n% Summary: \n" + # Insert Break or Space # =====================