Add a display name filed to index, and improve handling of it
This commit is contained in:
@@ -1842,7 +1842,7 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
return nwTrinary.NEUTRAL
|
||||
|
||||
tag = ""
|
||||
exist = False
|
||||
exist = 0
|
||||
cPos = cursor.selectionStart() - block.position()
|
||||
tExist = SHARED.project.index.checkThese(tBits, self._nwItem)
|
||||
for sTag, sPos, sExist in zip(reversed(tBits), reversed(tPos), reversed(tExist)):
|
||||
@@ -1854,14 +1854,14 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
exist = sExist
|
||||
break
|
||||
|
||||
if not tag or tag.startswith("@"):
|
||||
# The keyword cannot be looked up, so we ignore that
|
||||
if exist in (1, 3) or not tag:
|
||||
# Ignore keywords, optionals and empty tags
|
||||
return nwTrinary.NEUTRAL
|
||||
|
||||
if follow and exist:
|
||||
if follow and exist == 2:
|
||||
logger.debug("Attempting to follow tag '%s'", tag)
|
||||
self.loadDocumentTagRequest.emit(tag, nwDocMode.VIEW)
|
||||
elif create and not exist:
|
||||
elif create and exist == 0:
|
||||
if SHARED.question(self.tr(
|
||||
"Do you want to create a new project note for the tag '{0}'?"
|
||||
).format(tag)):
|
||||
@@ -1874,7 +1874,7 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
"If one doesn't exist, you must create one first."
|
||||
).format(trConst(nwLabels.CLASS_NAME[itemClass])))
|
||||
|
||||
return nwTrinary.POSITIVE if exist else nwTrinary.NEGATIVE
|
||||
return nwTrinary.POSITIVE if exist == 2 else nwTrinary.NEGATIVE
|
||||
|
||||
return nwTrinary.NEUTRAL
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ from PyQt5.QtGui import (
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwComment
|
||||
from novelwriter.common import checkInt
|
||||
from novelwriter.constants import nwRegEx, nwUnicode
|
||||
from novelwriter.core.index import processComment
|
||||
from novelwriter.enum import nwComment
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -107,7 +107,8 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
"code": self._makeFormat(SHARED.theme.colCode),
|
||||
"keyword": self._makeFormat(SHARED.theme.colKey),
|
||||
"modifier": self._makeFormat(SHARED.theme.colMod),
|
||||
"value": self._makeFormat(SHARED.theme.colVal, "underline"),
|
||||
"value": self._makeFormat(SHARED.theme.colVal),
|
||||
"optional": self._makeFormat(SHARED.theme.colOpt),
|
||||
"codevalue": self._makeFormat(SHARED.theme.colVal),
|
||||
"codeinval": self._makeFormat(None, "errline"),
|
||||
}
|
||||
@@ -286,15 +287,14 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
for n, bit in enumerate(bits):
|
||||
xPos = pos[n]
|
||||
xLen = len(bit)
|
||||
if isGood[n]:
|
||||
if n == 0:
|
||||
self.setFormat(xPos, xLen, self._hStyles["keyword"])
|
||||
else:
|
||||
self.setFormat(xPos, xLen, self._hStyles["value"])
|
||||
if isGood[n] == 1:
|
||||
self.setFormat(xPos, xLen, self._hStyles["keyword"])
|
||||
elif isGood[n] == 2:
|
||||
self.setFormat(xPos, xLen, self._hStyles["value"])
|
||||
elif isGood[n] == 3:
|
||||
self.setFormat(xPos, xLen, self._hStyles["optional"])
|
||||
else:
|
||||
kwFmt = self.format(xPos)
|
||||
kwFmt.merge(self._hStyles["codeinval"])
|
||||
self.setFormat(xPos, xLen, kwFmt)
|
||||
self.setFormat(xPos, xLen, self._hStyles["codeinval"])
|
||||
|
||||
# We never want to run the spell checker on keyword/values,
|
||||
# so we force a return here
|
||||
@@ -406,8 +406,6 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
if "errline" in styles:
|
||||
charFormat.setUnderlineColor(SHARED.theme.colError)
|
||||
charFormat.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)
|
||||
if "underline" in styles:
|
||||
charFormat.setFontUnderline(True)
|
||||
if "background" in styles and color is not None:
|
||||
charFormat.setBackground(QBrush(color, Qt.SolidPattern))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user