[LyX/master] Support option snippets in the LaTeXHighlighter
Juergen Spitzmueller
spitz at lyx.org
Tue Jul 18 12:00:48 UTC 2023
commit 6603ae22421479618cf0f752bf05a0795d9f7b3d
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Tue Jul 18 15:12:54 2023 +0200
Support option snippets in the LaTeXHighlighter
---
src/frontends/qt/GuiDocument.cpp | 4 ++--
src/frontends/qt/LaTeXHighlighter.cpp | 7 ++++---
src/frontends/qt/LaTeXHighlighter.h | 5 ++++-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index e8c8c19..3d71761 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -1774,8 +1774,8 @@ GuiDocument::GuiDocument(GuiView & lv)
pdfSupportModule->subjectLE));
pdfSupportModule->keywordsLE->setValidator(new NoNewLineValidator(
pdfSupportModule->keywordsLE));
- (void) new LaTeXHighlighter(pdfSupportModule->optionsTE->document(), true, true);
- (void) new LaTeXHighlighter(pdfSupportModule->metadataTE->document(), true, true);
+ (void) new LaTeXHighlighter(pdfSupportModule->optionsTE->document(), true, true, true);
+ (void) new LaTeXHighlighter(pdfSupportModule->metadataTE->document(), true, true, true);
for (int i = 0; backref_opts[i][0]; ++i)
pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i]));
diff --git a/src/frontends/qt/LaTeXHighlighter.cpp b/src/frontends/qt/LaTeXHighlighter.cpp
index 8336f7a..9e24c72 100644
--- a/src/frontends/qt/LaTeXHighlighter.cpp
+++ b/src/frontends/qt/LaTeXHighlighter.cpp
@@ -20,8 +20,8 @@ namespace lyx {
namespace frontend {
-LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter, bool keyval)
- : QSyntaxHighlighter(parent), at_letter_(at_letter), keyval_(keyval)
+LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter, bool keyval, bool optsnippet)
+ : QSyntaxHighlighter(parent), at_letter_(at_letter), keyval_(keyval), optsnippet_(optsnippet)
{
auto blend = [](QColor color1, QColor color2) {
int r = 0.5 * (color1.red() + color2.red());
@@ -44,8 +44,9 @@ LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter, bool
}
-void LaTeXHighlighter::highlightBlock(QString const & text)
+void LaTeXHighlighter::highlightBlock(QString const & text_in)
{
+ QString const text = (optsnippet_) ? '[' + text_in + ']' : text_in;
// keyval
if (keyval_) {
// Highlight key-val options. Used in some option widgets.
diff --git a/src/frontends/qt/LaTeXHighlighter.h b/src/frontends/qt/LaTeXHighlighter.h
index 7a80d1f..5f7108b 100644
--- a/src/frontends/qt/LaTeXHighlighter.h
+++ b/src/frontends/qt/LaTeXHighlighter.h
@@ -27,7 +27,8 @@ class LaTeXHighlighter : public QSyntaxHighlighter
public:
explicit LaTeXHighlighter(QTextDocument * parent,
bool at_letter = false,
- bool keyval = false);
+ bool keyval = false,
+ bool optsnippet = false);
protected:
void highlightBlock(QString const & text) override;
@@ -43,6 +44,8 @@ private:
bool const at_letter_;
// highlight keyval options?
bool const keyval_;
+ // option snippet?
+ bool const optsnippet_;
};
} // namespace frontend
More information about the lyx-cvs
mailing list