Date: Tue, 25 Oct 2022 16:19:25 +0200
Subject: [PATCH 05/36] Add checkmark for current active status or iumportance
value (#1202)
---
novelwriter/gui/projtree.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py
index bd77a57a..e34419d1 100644
--- a/novelwriter/gui/projtree.py
+++ b/novelwriter/gui/projtree.py
@@ -42,7 +42,7 @@ from PyQt5.QtWidgets import (
from novelwriter.core import DocMerger, DocSplitter
from novelwriter.enum import nwDocMode, nwItemType, nwItemClass, nwItemLayout, nwAlert
from novelwriter.dialogs import GuiDocMerge, GuiDocSplit, GuiEditLabel, GuiProjectSettings
-from novelwriter.constants import nwHeaders, trConst, nwLabels
+from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels
logger = logging.getLogger(__name__)
@@ -1121,10 +1121,12 @@ class GuiProjectTree(QTreeWidget):
open a context menu in-place.
"""
tItem = None
+ hasChild = False
selItem = self.itemAt(clickPos)
if isinstance(selItem, QTreeWidgetItem):
tHandle = selItem.data(self.C_NAME, Qt.UserRole)
tItem = self.theProject.tree[tHandle]
+ hasChild = selItem.childCount() > 0
if tItem is None:
logger.debug("No item found")
@@ -1149,7 +1151,6 @@ class GuiProjectTree(QTreeWidget):
isRoot = tItem.isRootType()
isFolder = tItem.isFolderType()
isFile = tItem.isFileType()
- hasChild = selItem.childCount() > 0
if isFile:
aOpenDoc = ctxMenu.addAction(self.tr("Open Document"))
@@ -1172,10 +1173,12 @@ class GuiProjectTree(QTreeWidget):
aActive = ctxMenu.addAction(self.tr("Toggle Active"))
aActive.triggered.connect(lambda: self._toggleItemActive(tHandle))
+ checkMark = f" ({nwUnicode.U_CHECK})"
if tItem.isNovelLike():
mStatus = ctxMenu.addMenu(self.tr("Set Status to ..."))
for n, (key, entry) in enumerate(self.theProject.statusItems.items()):
- aStatus = mStatus.addAction(entry["icon"], entry["name"])
+ entryName = entry["name"] + (checkMark if tItem.itemStatus == key else "")
+ aStatus = mStatus.addAction(entry["icon"], entryName)
aStatus.triggered.connect(
lambda n, key=key: self._changeItemStatus(tHandle, key)
)
@@ -1187,7 +1190,8 @@ class GuiProjectTree(QTreeWidget):
else:
mImport = ctxMenu.addMenu(self.tr("Set Importance to ..."))
for n, (key, entry) in enumerate(self.theProject.importItems.items()):
- aImport = mImport.addAction(entry["icon"], entry["name"])
+ entryName = entry["name"] + (checkMark if tItem.itemImport == key else "")
+ aImport = mImport.addAction(entry["icon"], entryName)
aImport.triggered.connect(
lambda n, key=key: self._changeItemImport(tHandle, key)
)
From a5cbaa7f8cd136f28a7ad1bab42324a9c42f3db1 Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Tue, 25 Oct 2022 16:58:46 +0200
Subject: [PATCH 06/36] Update requirements and add Python 3.11 to CI
---
.github/workflows/test_linux.yml | 2 +-
requirements.txt | 2 +-
setup.cfg | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/test_linux.yml b/.github/workflows/test_linux.yml
index 5cac8e23..6dcf160f 100644
--- a/.github/workflows/test_linux.yml
+++ b/.github/workflows/test_linux.yml
@@ -14,7 +14,7 @@ jobs:
testLinux:
strategy:
matrix:
- python-version: ["3.7", "3.8", "3.9", "3.10"]
+ python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
runs-on: ubuntu-latest
steps:
- name: Python Setup
diff --git a/requirements.txt b/requirements.txt
index 4c10636b..b47e1e91 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,3 @@
-pyqt5>=5.3
+pyqt5>=5.10
lxml>=4.2.0
pyenchant>=3.0.0
diff --git a/setup.cfg b/setup.cfg
index b88b656b..fc808a1e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -15,6 +15,7 @@ classifiers =
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
+ Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Development Status :: 5 - Production/Stable
@@ -32,7 +33,7 @@ python_requires = >=3.7
include_package_data = True
packages = find:
install_requires =
- pyqt5>=5.3
+ pyqt5>=5.10
lxml>=4.2.0
pyenchant>=3.0.0
From dc0f9abdbc19cb4c9293c171b12ed466ca0dbf2d Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Tue, 25 Oct 2022 18:12:29 +0200
Subject: [PATCH 07/36] Fix lookup of tags with spaces (#1195)
---
novelwriter/gui/doceditor.py | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py
index 83d971d5..e1ed9816 100644
--- a/novelwriter/gui/doceditor.py
+++ b/novelwriter/gui/doceditor.py
@@ -1871,10 +1871,10 @@ class GuiDocEditor(QTextEdit):
def _followTag(self, theCursor=None, loadTag=True):
"""Activated by Ctrl+Enter. Checks that we're in a block
- starting with '@'. We then find the word under the cursor and
- check that it is after the ':'. If all this is fine, we have a
- tag and can tell the document viewer to try and find and load
- the file where the tag is defined.
+ starting with '@'. We then find the tag under the cursor and
+ check that it is not the tag itself. If all this is fine, we
+ have a tag and can tell the document viewer to try and find and
+ load the file where the tag is defined.
"""
if theCursor is None:
theCursor = self.textCursor()
@@ -1887,18 +1887,29 @@ class GuiDocEditor(QTextEdit):
if theText.startswith("@"):
- theCursor.select(QTextCursor.WordUnderCursor)
- theWord = theCursor.selectedText()
- cPos = theText.find(":")
- wPos = theCursor.selectionStart() - theBlock.position()
- if wPos <= cPos:
+ isGood, tBits, tPos = self.theParent.theIndex.scanThis(theText)
+ if not isGood:
+ return False
+
+ theTag = ""
+ cPos = theCursor.selectionStart() - theBlock.position()
+ for sTag, sPos in zip(reversed(tBits), reversed(tPos)):
+ if cPos >= sPos:
+ # The cursor is between the start of two tags
+ if cPos <= sPos + len(sTag):
+ # The cursor is inside or at the edge of the tag
+ theTag = sTag
+ break
+
+ if not theTag or theTag.startswith("@"):
+ # The keyword cannot be looked up, so we ignore that
return False
if loadTag:
- logger.verbose("Attempting to follow tag '%s'", theWord)
- self.theParent.docViewer.loadFromTag(theWord)
+ logger.verbose("Attempting to follow tag '%s'", theTag)
+ self.theParent.docViewer.loadFromTag(theTag)
else:
- logger.verbose("Potential tag '%s'", theWord)
+ logger.verbose("Potential tag '%s'", theTag)
return True
From 4862ac385761bf84c6532751284d00bd4810977a Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Tue, 25 Oct 2022 18:26:37 +0200
Subject: [PATCH 08/36] Bump the version number and update the changelog
---
CHANGELOG.md | 19 ++++++++++++++++++-
novelwriter/__init__.py | 6 +++---
novelwriter/assets/text/release_notes.htm | 7 ++++++-
sample/nwProject.nwx | 8 ++++----
4 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 300f82fd..e27e65af 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,27 @@
# novelWriter Changelog
+## Version 1.6.6 [2022-10-25]
+
+### Release Notes
+
+This is a bugfix release that fixes a minor issues with following tags in the editor. It is now
+possible to also follow tags that contain spaces.
+
+### Detailed Changelog
+
+**Bugfixes**
+
+* Fix a bug where only the word under the cursor would be looked up when the user tried to follow a
+ tag in the editor. The lookup function now uses the same parser for the `@`-line as the syntax
+ highlighter does, so they should behave consistently. Issue #1195. PR #1209.
+
+----
+
## Version 1.6.5 [2022-10-13]
### Release Notes
-This is a bugfix release that fixes a a few minor issues. The idle time for new projects would be
+This is a bugfix release that fixes a few minor issues. The idle time for new projects would be
artificially inflated as the clock was not reset when the project was first created. This only
affects the first entry in the writing statistics. A scaling issue for the Preferences dialog has
also been fixed. It only affected screens with UI scaling enabled. Lastly, typing `Shift+Enter` in
diff --git a/novelwriter/__init__.py b/novelwriter/__init__.py
index 2b40a55f..b76e94ec 100644
--- a/novelwriter/__init__.py
+++ b/novelwriter/__init__.py
@@ -60,9 +60,9 @@ __license__ = "GPLv3"
__author__ = "Veronica Berglyd Olsen"
__maintainer__ = "Veronica Berglyd Olsen"
__email__ = "code@vkbo.net"
-__version__ = "1.6.5"
-__hexversion__ = "0x010605f0"
-__date__ = "2022-10-13"
+__version__ = "1.6.6"
+__hexversion__ = "0x010606f0"
+__date__ = "2022-10-25"
__status__ = "Stable"
__domain__ = "novelwriter.io"
__url__ = "https://novelwriter.io"
diff --git a/novelwriter/assets/text/release_notes.htm b/novelwriter/assets/text/release_notes.htm
index 34c423a8..1db03b01 100644
--- a/novelwriter/assets/text/release_notes.htm
+++ b/novelwriter/assets/text/release_notes.htm
@@ -72,7 +72,7 @@ text cursor sometimes disappears when reaching the right-hand edge of the text e
Patch 1.6.5 – 13 October 2022
-This is a bugfix release that fixes a a few minor issues. The idle time for new projects would
+
This is a bugfix release that fixes a few minor issues. The idle time for new projects would
be artificially inflated as the clock was not reset when the project was first created. This only
affects the first entry in the writing statistics. A scaling issue for the Preferences dialog has
also been fixed. It only affected screens with UI scaling enabled. Lastly, typing Shift+Enter in
@@ -80,5 +80,10 @@ the text editor now creates a regular line break instead of a special line separ
separator serves no purpose in plain text, and was producing inconsistencies in how text is
processed and displayed.
+Patch 1.6.6 – 25 October 2022
+
+This is a bugfix release that fixes a minor issues with following tags in the editor. It is now
+possible to also follow tags that contain spaces.
+