Add dialogue highlighting to the viewer
This commit is contained in:
@@ -45,16 +45,18 @@ T_TextStyle = tuple[QTextBlockFormat, QTextCharFormat]
|
|||||||
|
|
||||||
|
|
||||||
class TextDocumentTheme:
|
class TextDocumentTheme:
|
||||||
text: QColor = QtBlack
|
text: QColor = QtBlack
|
||||||
highlight: QColor = QtTransparent
|
highlight: QColor = QtTransparent
|
||||||
head: QColor = QtBlack
|
head: QColor = QtBlack
|
||||||
comment: QColor = QtBlack
|
comment: QColor = QtBlack
|
||||||
note: QColor = QtBlack
|
note: QColor = QtBlack
|
||||||
code: QColor = QtBlack
|
code: QColor = QtBlack
|
||||||
modifier: QColor = QtBlack
|
modifier: QColor = QtBlack
|
||||||
keyword: QColor = QtBlack
|
keyword: QColor = QtBlack
|
||||||
tag: QColor = QtBlack
|
tag: QColor = QtBlack
|
||||||
optional: QColor = QtBlack
|
optional: QColor = QtBlack
|
||||||
|
dialog: QColor = QtBlack
|
||||||
|
altdialog: QColor = QtBlack
|
||||||
|
|
||||||
|
|
||||||
def newBlock(cursor: QTextCursor, bFmt: QTextBlockFormat) -> None:
|
def newBlock(cursor: QTextCursor, bFmt: QTextBlockFormat) -> None:
|
||||||
@@ -340,6 +342,14 @@ class ToQTextDocument(Tokenizer):
|
|||||||
cFmt.setVerticalAlignment(QtVAlignSub)
|
cFmt.setVerticalAlignment(QtVAlignSub)
|
||||||
elif fmt == self.FMT_SUB_E:
|
elif fmt == self.FMT_SUB_E:
|
||||||
cFmt.setVerticalAlignment(QtVAlignNormal)
|
cFmt.setVerticalAlignment(QtVAlignNormal)
|
||||||
|
elif fmt == self.FMT_DL_B:
|
||||||
|
cFmt.setForeground(self._theme.dialog)
|
||||||
|
elif fmt == self.FMT_DL_E:
|
||||||
|
cFmt.setForeground(self._theme.text)
|
||||||
|
elif fmt == self.FMT_ADL_B:
|
||||||
|
cFmt.setForeground(self._theme.altdialog)
|
||||||
|
elif fmt == self.FMT_ADL_E:
|
||||||
|
cFmt.setForeground(self._theme.text)
|
||||||
elif fmt == self.FMT_FNOTE:
|
elif fmt == self.FMT_FNOTE:
|
||||||
xFmt = QTextCharFormat(self._cCode)
|
xFmt = QTextCharFormat(self._cCode)
|
||||||
xFmt.setVerticalAlignment(QtVAlignSuper)
|
xFmt.setVerticalAlignment(QtVAlignSuper)
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
self._docTheme.keyword = SHARED.theme.colKey
|
self._docTheme.keyword = SHARED.theme.colKey
|
||||||
self._docTheme.tag = SHARED.theme.colTag
|
self._docTheme.tag = SHARED.theme.colTag
|
||||||
self._docTheme.optional = SHARED.theme.colOpt
|
self._docTheme.optional = SHARED.theme.colOpt
|
||||||
|
self._docTheme.dialog = SHARED.theme.colDialN
|
||||||
|
self._docTheme.altdialog = SHARED.theme.colDialA
|
||||||
|
|
||||||
# Set default text margins
|
# Set default text margins
|
||||||
self.document().setDocumentMargin(0)
|
self.document().setDocumentMargin(0)
|
||||||
@@ -201,6 +203,7 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
sPos = self.verticalScrollBar().value()
|
sPos = self.verticalScrollBar().value()
|
||||||
qDoc = ToQTextDocument(SHARED.project)
|
qDoc = ToQTextDocument(SHARED.project)
|
||||||
qDoc.setJustify(CONFIG.doJustify)
|
qDoc.setJustify(CONFIG.doJustify)
|
||||||
|
qDoc.setDialogueHighlight(True)
|
||||||
qDoc.initDocument(CONFIG.textFont, self._docTheme)
|
qDoc.initDocument(CONFIG.textFont, self._docTheme)
|
||||||
qDoc.setKeywords(True)
|
qDoc.setKeywords(True)
|
||||||
qDoc.setComments(CONFIG.viewComments)
|
qDoc.setComments(CONFIG.viewComments)
|
||||||
|
|||||||
Reference in New Issue
Block a user