Improved the tab handling and added the same fix to the build tool
This commit is contained in:
+2
-2
@@ -48,7 +48,7 @@ class ToHtml(Tokenizer):
|
||||
"<" : "<",
|
||||
">" : ">",
|
||||
"&" : "&",
|
||||
"\t" : " "*2,
|
||||
# "\t" : "!!tab!!", # " "*2,
|
||||
nwUnicode.U_ENDASH : nwUnicode.H_ENDASH,
|
||||
nwUnicode.U_EMDASH : nwUnicode.H_EMDASH,
|
||||
nwUnicode.U_HELLIP : nwUnicode.H_HELLIP,
|
||||
@@ -77,7 +77,7 @@ class ToHtml(Tokenizer):
|
||||
self.doKeywords = True
|
||||
self.doComments = doComments
|
||||
self.doSynopsis = doSynopsis
|
||||
self.repDict["\t"] = r"!!tab!!" # The viewer replaces these
|
||||
# self.repDict["\t"] = r"!!tab!!" # The viewer replaces these
|
||||
self._buildRegEx()
|
||||
return
|
||||
|
||||
|
||||
+25
-2
@@ -551,7 +551,6 @@ class GuiBuildNovel(QDialog):
|
||||
isNone |= theItem.itemClass == nwItemClass.NO_CLASS
|
||||
isNone |= theItem.itemClass == nwItemClass.TRASH
|
||||
isNone |= theItem.parHandle == self.theProject.projTree.trashRoot()
|
||||
isNone |= theItem.parHandle == self.theProject.projTree.archiveRoot()
|
||||
isNone |= theItem.parHandle is None
|
||||
isNote = theItem.itemLayout == nwItemLayout.NOTE
|
||||
isNovel = not isNone and not isNote
|
||||
@@ -563,6 +562,10 @@ class GuiBuildNovel(QDialog):
|
||||
if isNovel and not novelFiles:
|
||||
return False
|
||||
|
||||
rootItem = self.theProject.projTree.getRootItem(theItem.itemHandle)
|
||||
if rootItem.itemClass == nwItemClass.ARCHIVE:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def _saveDocument(self, theFormat):
|
||||
@@ -1014,13 +1017,33 @@ class GuiBuildNovelDocView(QTextBrowser):
|
||||
theText = "".join(theText)
|
||||
|
||||
self.buildTime = timeStamp
|
||||
sPos = self.verticalScrollBar().value()
|
||||
|
||||
theText = theText.replace(" ", " "*4)
|
||||
# Refresh the tab stops
|
||||
if self.mainConf.verQtValue >= 51000:
|
||||
self.setTabStopDistance(self.mainConf.getTabWidth())
|
||||
else:
|
||||
self.setTabStopWidth(self.mainConf.getTabWidth())
|
||||
|
||||
theText = theText.replace("\t", "!!tab!!")
|
||||
theText = theText.replace("<del>", "<span style='text-decoration: line-through;'>")
|
||||
theText = theText.replace("</del>", "</span>")
|
||||
self.setHtml(theText)
|
||||
|
||||
while self.find("!!tab!!"):
|
||||
theCursor = self.textCursor()
|
||||
theCursor.insertText("\t")
|
||||
|
||||
self.verticalScrollBar().setValue(sPos)
|
||||
self._updateBuildAge()
|
||||
|
||||
# This forces a repaint of the text, It's a hack to fix an occational
|
||||
# issue where the find/replace above interfers with the rendering and
|
||||
# leaves parts of the document blank.
|
||||
textWidth = self.qDocument.textWidth()
|
||||
self.qDocument.setTextWidth(textWidth - 5)
|
||||
self.qDocument.setTextWidth(textWidth)
|
||||
|
||||
return
|
||||
|
||||
def setStyleSheet(self, theStyles=[]):
|
||||
|
||||
+20
-14
@@ -156,7 +156,20 @@ class GuiDocViewer(QTextBrowser):
|
||||
self.setText("An error occurred while generating the preview.")
|
||||
return False
|
||||
|
||||
self.setHtml(aDoc.theResult)
|
||||
# Refresh the tab stops
|
||||
if self.mainConf.verQtValue >= 51000:
|
||||
self.setTabStopDistance(self.mainConf.getTabWidth())
|
||||
else:
|
||||
self.setTabStopWidth(self.mainConf.getTabWidth())
|
||||
|
||||
self.setHtml(aDoc.theResult.replace("\t", "!!tab!!"))
|
||||
|
||||
# Loop through the text and put back in the tabs. Tabs are removed by
|
||||
# the setHtml function, so the ToHtml class puts in a placeholder.
|
||||
while self.find("!!tab!!"):
|
||||
theCursor = self.textCursor()
|
||||
theCursor.insertText("\t")
|
||||
|
||||
if self.theHandle == tHandle:
|
||||
self.verticalScrollBar().setValue(sPos)
|
||||
self.theHandle = tHandle
|
||||
@@ -167,17 +180,12 @@ class GuiDocViewer(QTextBrowser):
|
||||
# Make sure the main GUI knows we changed the content
|
||||
self.theParent.viewMeta.refreshReferences(tHandle)
|
||||
|
||||
# Loop through the text and put back in the tabs. Tabs are removed by
|
||||
# the setHtml function, so the ToHtml class puts in a placeholder.
|
||||
while self.find("!!tab!!"):
|
||||
theCursor = self.textCursor()
|
||||
theCursor.insertText("\t")
|
||||
|
||||
# Refresh the tab stops
|
||||
if self.mainConf.verQtValue >= 51000:
|
||||
self.setTabStopDistance(self.mainConf.getTabWidth())
|
||||
else:
|
||||
self.setTabStopWidth(self.mainConf.getTabWidth())
|
||||
# This forces a repaint of the text, It's a hack to fix an occational
|
||||
# issue where the find/replace above interfers with the rendering and
|
||||
# leaves parts of the document blank.
|
||||
textWidth = self.qDocument.textWidth()
|
||||
self.qDocument.setTextWidth(textWidth - 5)
|
||||
self.qDocument.setTextWidth(textWidth)
|
||||
|
||||
return True
|
||||
|
||||
@@ -369,8 +377,6 @@ class GuiDocViewer(QTextBrowser):
|
||||
"}}\n"
|
||||
".comment {{"
|
||||
" color: rgb({cColR},{cColG},{cColB});"
|
||||
" margin-left: 1em;"
|
||||
" margin-right: 1em;"
|
||||
"}}\n"
|
||||
".synopsis {{"
|
||||
" color: rgb({mColR},{mColG},{mColB});"
|
||||
|
||||
Reference in New Issue
Block a user