[Request/idea] Preamble generalization

Richard Kimberly Heck rikiheck at lyx.org
Mon Sep 21 19:54:24 UTC 2020


On 9/21/20 2:22 PM, Lorenzo Bertini wrote:
> I managed to get the thing to work through your guidance and shameless
> copy-paste: 

I would have done it the same way: Find all the preambleTE stuff and
duplicate it!


> let me know if you find any problems. I generalized the
> findText method decently, but the rest of the patch is still
> hardcoded. Also, I don't fully understand why <writeLatex>> is in
> <BufferParams> but write <LyXHTMLSource> is in <Buffer>, and how the
> whole outputting is done. 

There's a method Buffer::writeLaTeXSource, as well, that is parallel to
Buffer::writeLyXHTMLSource.  The former calls BufferParams::writeLaTeX
along the way. There's not (yet) a BufferParams::writeLyXHTML because
there just weren't enough params to justify it---though probably it
would have been best practice to put it there anyway.

I haven't tested yet, but here are a couple comments:

@@ -512,13 +517,14 @@ void PreambleModule::checkFindButton()
 
 void PreambleModule::findText()
 {
-    bool const found = preambleTE->find(findLE->text());
+    QTextEdit *currentTE =
tabWidget->currentWidget()->findChild<QTextEdit *>();

Probably can be const. We also put space around the *.

+    bool const found = currentTE->find(findLE->text());

Probably worth a paranoid check that currentTE is not null. (Coverity
would probably complain anyway.) So:

+    bool const found = currentTE && currentTE->find(findLE->text());

Riki





More information about the lyx-devel mailing list