From 99ec268dd9db8e8c1c18dce498999ac6452f3aa8 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:36:21 +0200 Subject: [PATCH 1/7] Increase the icon size of outline toolbar --- novelwriter/gui/outline.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/novelwriter/gui/outline.py b/novelwriter/gui/outline.py index 4ed2679f..a4f92107 100644 --- a/novelwriter/gui/outline.py +++ b/novelwriter/gui/outline.py @@ -209,11 +209,8 @@ class GuiOutlineToolBar(QToolBar): logger.debug("Create: GuiOutlineToolBar") - iSz = SHARED.theme.baseIconSize - mPx = CONFIG.pxInt(12) - self.setMovable(False) - self.setIconSize(iSz) + self.setIconSize(1.4*SHARED.theme.baseIconSize) self.setContentsMargins(0, 0, 0, 0) stretch = QWidget(self) @@ -221,7 +218,7 @@ class GuiOutlineToolBar(QToolBar): # Novel Selector self.novelLabel = QLabel(self.tr("Outline of"), self) - self.novelLabel.setContentsMargins(0, 0, mPx, 0) + self.novelLabel.setContentsMargins(0, 0, CONFIG.pxInt(12), 0) self.novelValue = NovelSelector(self) self.novelValue.setIncludeAll(True) From 52b27b6e56eb11485b48579fe469ecb6a70455b4 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:42:46 +0200 Subject: [PATCH 2/7] Increase toolbar label font size in outline --- novelwriter/gui/outline.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/novelwriter/gui/outline.py b/novelwriter/gui/outline.py index a4f92107..0696472f 100644 --- a/novelwriter/gui/outline.py +++ b/novelwriter/gui/outline.py @@ -47,6 +47,7 @@ from novelwriter.enum import ( from novelwriter.error import logException from novelwriter.common import checkInt, formatFileFilter, makeFileNameSafe from novelwriter.constants import nwHeaders, trConst, nwKeyWords, nwLabels +from novelwriter.extensions.configlayout import NColourLabel from novelwriter.extensions.novelselector import NovelSelector from novelwriter.types import ( QtAlignLeftTop, QtAlignRight, QtAlignRightTop, QtDecoration, QtUserRole @@ -217,7 +218,9 @@ class GuiOutlineToolBar(QToolBar): stretch.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) # Novel Selector - self.novelLabel = QLabel(self.tr("Outline of"), self) + self.novelLabel = NColourLabel( + self.tr("Outline of"), parent=self, scale=NColourLabel.HEADER_SCALE, bold=True + ) self.novelLabel.setContentsMargins(0, 0, CONFIG.pxInt(12), 0) self.novelValue = NovelSelector(self) From f23164a17b21278589bb01df3c88b84445240277 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:39:52 +0200 Subject: [PATCH 3/7] Disable spell checking for shortcodes --- novelwriter/gui/dochighlight.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index c81291cf..3e184d72 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -44,6 +44,10 @@ logger = logging.getLogger(__name__) SPELLRX = QRegularExpression(r"\b[^\s\-\+\/–—\[\]:]+\b") SPELLRX.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption) +SPELLSC = QRegularExpression(nwRegEx.FMT_SC) +SPELLSC.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption) +SPELLSV = QRegularExpression(nwRegEx.FMT_SV) +SPELLSV.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption) BLOCK_NONE = 0 BLOCK_TEXT = 1 @@ -439,6 +443,17 @@ class TextBlockData(QTextBlockUserData): """Run the spell checker and cache the result, and return the list of spell check errors. """ + if "[" in text: + # Strip shortcodes + for rX in [SPELLSC, SPELLSV]: + rxItt = rX.globalMatch(text, 0) + while rxItt.hasNext(): + rxMatch = rxItt.next() + xPos = rxMatch.capturedStart(0) + xLen = rxMatch.capturedLength(0) + xEnd = rxMatch.capturedEnd(0) + text = text[:xPos] + " "*xLen + text[xEnd:] + self._spellErrors = [] rxSpell = SPELLRX.globalMatch(text.replace("_", " "), 0) while rxSpell.hasNext(): From 35563373a62b05f66c1872d90da58aab570764ab Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:40:19 +0200 Subject: [PATCH 4/7] Annotated regex rules in highlighting and add to slots --- novelwriter/gui/dochighlight.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index 3e184d72..d9919bb9 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -57,7 +57,8 @@ BLOCK_TITLE = 4 class GuiDocHighlighter(QSyntaxHighlighter): - __slots__ = ("_tItem", "_tHandle", "_spellCheck", "_spellErr", "_hRules", "_hStyles") + __slots__ = ("_tHandle", "_isInactive", "_spellCheck", "_spellErr", + "_hRules", "_hStyles", "_rxRules") def __init__(self, document: QTextDocument) -> None: super().__init__(document) @@ -71,6 +72,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): self._hRules: list[tuple[str, dict]] = [] self._hStyles: dict[str, QTextCharFormat] = {} + self._rxRules: list[tuple[QRegularExpression, dict[str, QTextCharFormat]]] = [] self.initHighlighter() @@ -222,11 +224,11 @@ class GuiDocHighlighter(QSyntaxHighlighter): )) # Build a QRegExp for each highlight pattern - self.rxRules = [] + self._rxRules = [] for regEx, regRules in self._hRules: hReg = QRegularExpression(regEx) hReg.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption) - self.rxRules.append((hReg, regRules)) + self._rxRules.append((hReg, regRules)) return @@ -362,7 +364,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): # Regular Text self.setCurrentBlockState(BLOCK_TEXT) - for rX, xFmt in self.rxRules: + for rX, xFmt in self._rxRules: rxItt = rX.globalMatch(text, 0) while rxItt.hasNext(): rxMatch = rxItt.next() From 8cfeb2ce7d013a8bc5ab4626d8d7b4ce3b9cf533 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:47:46 +0200 Subject: [PATCH 5/7] Add test coverage of shortcode spell checking --- tests/reference/guiEditor_Main_Final_0000000000011.nwd | 6 +++--- tests/reference/guiEditor_Main_Final_nwProject.nwx | 4 ++-- tests/test_gui/test_gui_guimain.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/reference/guiEditor_Main_Final_0000000000011.nwd b/tests/reference/guiEditor_Main_Final_0000000000011.nwd index ed7002ab..bd73dfd8 100644 --- a/tests/reference/guiEditor_Main_Final_0000000000011.nwd +++ b/tests/reference/guiEditor_Main_Final_0000000000011.nwd @@ -1,10 +1,10 @@ %%~name: New Note %%~path: 0000000000009/0000000000011 %%~kind: PLOT/NOTE -%%~hash: 8ff26f8a18ad6390c2ce725c441ab0c792a125cf -%%~date: 2023-08-25 18:15:35/2023-08-25 18:15:35 +%%~hash: 3d3697638a70fc86cc023df6d42202a262d93905 +%%~date: 2024-04-14 23:46:49/2024-04-14 23:46:49 # Main Plot @tag: MainPlot -This is a file detailing the main plot. +This is a file [i]detailing[/i] the main plot. diff --git a/tests/reference/guiEditor_Main_Final_nwProject.nwx b/tests/reference/guiEditor_Main_Final_nwProject.nwx index c3ee941f..75a5d460 100644 --- a/tests/reference/guiEditor_Main_Final_nwProject.nwx +++ b/tests/reference/guiEditor_Main_Final_nwProject.nwx @@ -1,5 +1,5 @@ - + New Project Jane Doe @@ -54,7 +54,7 @@ Plot - + New Note diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py index 4de04a95..dc6ffcfc 100644 --- a/tests/test_gui/test_gui_guimain.py +++ b/tests/test_gui/test_gui_guimain.py @@ -274,7 +274,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd): qtbot.keyClick(docEditor, c, delay=KEY_DELAY) qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY) qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY) - for c in "This is a file detailing the main plot.": + for c in "This is a file [i]detailing[/i] the main plot.": qtbot.keyClick(docEditor, c, delay=KEY_DELAY) qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY) From 466eb65a44a4e9be1c27a62ea79fe5deb80abbcc Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 16 Apr 2024 23:15:39 +0200 Subject: [PATCH 6/7] Add setup.cfg back for old Ubuntu LTSes --- pkgutils.py | 26 ++++++++++++++------- setup/launchpad_setup.cfg | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 setup/launchpad_setup.cfg diff --git a/pkgutils.py b/pkgutils.py index 9d51551d..cd262f2c 100755 --- a/pkgutils.py +++ b/pkgutils.py @@ -675,8 +675,10 @@ def makeMinimalPackage(targetOS: int) -> None: # Make Debian Package (build-deb) ## -def makeDebianPackage(signKey: str | None = None, sourceBuild: bool = False, - distName: str = "unstable", buildName: str = "") -> str: +def makeDebianPackage( + signKey: str | None = None, sourceBuild: bool = False, + distName: str = "unstable", buildName: str = "", oldSetuptools: bool = False +) -> str: """Build a Debian package.""" print("") print("Build Debian Package") @@ -784,6 +786,13 @@ def makeDebianPackage(signKey: str | None = None, sourceBuild: bool = False, writeFile(f"{outDir}/pyproject.toml", setupCfg) print("Wrote: pyproject.toml") + if oldSetuptools: + setupCfg = readFile("setup/launchpad_setup.cfg").replace( + "file: setup/description_pypi.md", "file: data/description_short.txt" + ) + writeFile(f"{outDir}/setup.cfg", setupCfg) + print("Wrote: setup.cfg") + # Copy/Write Debian Files # ======================= @@ -860,10 +869,10 @@ def makeForLaunchpad(doSign: bool = False, isFirst: bool = False) -> None: bldNum = "0" distLoop = [ - ("20.04", "focal"), - ("22.04", "jammy"), - ("23.10", "mantic"), - ("24.04", "noble"), + ("20.04", "focal", True), + ("22.04", "jammy", True), + ("23.10", "mantic", False), + ("24.04", "noble", False), ] print("Building Ubuntu packages for:") @@ -881,13 +890,14 @@ def makeForLaunchpad(doSign: bool = False, isFirst: bool = False) -> None: print("") dputCmd = [] - for distNum, codeName in distLoop: + for distNum, codeName, oldSetup in distLoop: buildName = f"ubuntu{distNum}.{bldNum}" dCmd = makeDebianPackage( signKey=signKey, sourceBuild=True, distName=codeName, - buildName=buildName + buildName=buildName, + oldSetuptools=oldSetup, ) dputCmd.append(dCmd) diff --git a/setup/launchpad_setup.cfg b/setup/launchpad_setup.cfg new file mode 100644 index 00000000..df0af65a --- /dev/null +++ b/setup/launchpad_setup.cfg @@ -0,0 +1,48 @@ +[metadata] +name = novelWriter +version = attr: novelwriter.__version__ +author = Veronica Berglyd Olsen +author_email = code@vkbo.net +description = A markdown-like text editor for planning and writing novels +url = https://novelwriter.io +long_description = file: setup/description_pypi.md +long_description_content_type = text/markdown +license_files = LICENSE.md +license = GNU General Public License v3 +classifiers = + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 + Programming Language :: Python :: Implementation :: CPython + License :: OSI Approved :: GNU General Public License v3 (GPLv3) + Development Status :: 5 - Production/Stable + Operating System :: OS Independent + Intended Audience :: End Users/Desktop + Natural Language :: English + Topic :: Text Editors +project_urls = + Bug Tracker = https://github.com/vkbo/novelWriter/issues + Documentation = https://docs.novelwriter.io + Source Code = https://github.com/vkbo/novelWriter + +[options] +zip_safe = False +python_requires = >=3.8 +include_package_data = True +packages = find_namespace: +install_requires = + pyqt5>=5.10 + pyenchant>=3.0.0 + +[options.packages.find] +include = novelwriter* + +[options.entry_points] +gui_scripts = + novelwriter = novelwriter:main + +[bdist_wheel] +universal = 0 From 175b6747ea0c2c110a49c3e3f9fba4aaf892471d Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 16 Apr 2024 23:33:13 +0200 Subject: [PATCH 7/7] Fix build errors --- pkgutils.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pkgutils.py b/pkgutils.py index cd262f2c..19152c41 100755 --- a/pkgutils.py +++ b/pkgutils.py @@ -780,19 +780,28 @@ def makeDebianPackage( )) print("Wrote: setup.py") - setupCfg = readFile("pyproject.toml").replace( - "setup/description_pypi.md", "data/description_short.txt" - ) - writeFile(f"{outDir}/pyproject.toml", setupCfg) - print("Wrote: pyproject.toml") - if oldSetuptools: + # This is needed for Ubuntu up to 22.04 setupCfg = readFile("setup/launchpad_setup.cfg").replace( "file: setup/description_pypi.md", "file: data/description_short.txt" ) writeFile(f"{outDir}/setup.cfg", setupCfg) print("Wrote: setup.cfg") + writeFile(f"{outDir}/pyproject.toml", ( + "[build-system]\n" + "requires = [\"setuptools\"]\n" + "build-backend = \"setuptools.build_meta\"\n" + )) + print("Wrote: pyproject.toml") + + else: + pyProject = readFile("pyproject.toml").replace( + "setup/description_pypi.md", "data/description_short.txt" + ) + writeFile(f"{outDir}/pyproject.toml", pyProject) + print("Wrote: pyproject.toml") + # Copy/Write Debian Files # ======================= @@ -877,7 +886,7 @@ def makeForLaunchpad(doSign: bool = False, isFirst: bool = False) -> None: print("Building Ubuntu packages for:") print("") - for distNum, codeName in distLoop: + for distNum, codeName, _ in distLoop: print(f" * Ubuntu {distNum} {codeName.title()}") print("")