Am Sat, 05 Mar 2022 17:22:06 +0100 schrieb Jürgen Spitzmüller <sp...@lyx.org>:
> Am Samstag, dem 05.03.2022 um 16:42 +0100 schrieb Kornel Benko: > > I have no idea, how to get notes output in latex mode > > Adapt the conditions in InsetNote::latex() accordingly. > > > > and I > > > don't see where to opt-out (as I'd have expected). > > > > this could be done with the function 'search-ignore deactivated true' > > (not yet implemented > > though) > > Not happy about the naming ... > > search-ignore non-output-content false? > > Jürgen > Implemented your suggestion. Kornel -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
diff --git a/src/OutputParams.h b/src/OutputParams.h index a909ddd925..d00ec02d88 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -424,16 +424,17 @@ public: /// Are we generating this material for inclusion in a tooltip? bool for_tooltip = false; /// Are we generating this material for use by advanced search? enum Search { - NoSearch, - SearchWithDeleted, - SearchWithoutDeleted + NoSearch = 0, + SearchWithDeleted = 1, + SearchWithoutDeleted = 2, + SearchNonOutput = 8 }; - enum Search for_searchAdv = NoSearch; + int for_searchAdv = NoSearch; /// Are we generating this material for instant preview? bool for_preview = false; /// Include all children notwithstanding the use of \includeonly diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index b9ac139f77..be133b12c5 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -2641,11 +2641,11 @@ void Paragraph::latex(BufferParams const & bparams, // Check whether a display math inset follows bool output_changes; if (runparams.for_searchAdv == OutputParams::NoSearch) output_changes = bparams.output_changes; else - output_changes = (runparams.for_searchAdv == OutputParams::SearchWithDeleted); + output_changes = ((runparams.for_searchAdv & OutputParams::SearchWithDeleted) != 0); if (c == META_INSET && i >= start_pos && (end_pos == -1 || i < end_pos)) { if (isDeleted(i)) runparams.ctObject = getInset(i)->getCtObject(runparams); diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index be8e551747..2b60ca6f44 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -312,11 +312,11 @@ bool InsetBranch::producesOutput() const } void InsetBranch::latex(otexstream & os, OutputParams const & runparams) const { - if (producesOutput()) { + if (producesOutput() || ((runparams.for_searchAdv & OutputParams::SearchNonOutput) != 0)) { OutputParams rp = runparams; rp.inbranch = true; InsetText::latex(os, rp); // These need to be passed upstream runparams.need_maketitle = rp.need_maketitle; @@ -326,11 +326,11 @@ void InsetBranch::latex(otexstream & os, OutputParams const & runparams) const int InsetBranch::plaintext(odocstringstream & os, OutputParams const & runparams, size_t max_length) const { - if (!producesOutput()) + if (!producesOutput() && ((runparams.for_searchAdv & OutputParams::SearchNonOutput) == 0)) return 0; int len = InsetText::plaintext(os, runparams, max_length); return len; } diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index a3ce988778..54bceaaa0a 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -104,10 +104,12 @@ class IgnoreFormats { /// bool getDeleted() const { return ignoreDeleted_; } /// void setIgnoreDeleted(bool value); /// + bool getNonContent() const { return searchNonContent_; } + /// void setIgnoreFormat(string const & type, bool value, bool fromUser = true); private: /// bool ignoreFamily_ = false; @@ -130,10 +132,12 @@ private: /// bool ignoreLanguage_ = false; bool userSelectedIgnoreLanguage_ = false; /// bool ignoreDeleted_ = true; + /// + bool searchNonContent_ = true; }; void IgnoreFormats::setIgnoreFormat(string const & type, bool value, bool fromUser) { if (type == "color") { @@ -175,10 +179,13 @@ void IgnoreFormats::setIgnoreFormat(string const & type, bool value, bool fromUs ignoreStrikeOut_ = value; } else if (type == "deleted") { ignoreDeleted_ = value; } + else if (type == "non-output-content") { + searchNonContent_ = !value; + } } // The global variable that can be changed from outside IgnoreFormats ignoreFormats; @@ -1057,10 +1064,13 @@ static docstring buffer_to_latex(Buffer & buffer) runparams.dryrun = true; if (ignoreFormats.getDeleted()) runparams.for_searchAdv = OutputParams::SearchWithoutDeleted; else runparams.for_searchAdv = OutputParams::SearchWithDeleted; + if (ignoreFormats.getNonContent()) { + runparams.for_searchAdv |= OutputParams::SearchNonOutput; + } pit_type const endpit = buffer.paragraphs().size(); for (pit_type pit = 0; pit != endpit; ++pit) { TeXOnePar(buffer, buffer.text(), pit, os, runparams); LYXERR(Debug::FIND, "searchString up to here: " << ods.str()); } @@ -1086,10 +1096,13 @@ static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions co runparams.for_searchAdv = OutputParams::SearchWithoutDeleted; } else { runparams.for_searchAdv = OutputParams::SearchWithDeleted; } + if (ignoreFormats.getNonContent()) { + runparams.for_searchAdv |= OutputParams::SearchNonOutput; + } for (pos_type pit = pos_type(0); pit < (pos_type)buffer.paragraphs().size(); ++pit) { Paragraph const & par = buffer.paragraphs().at(pit); LYXERR(Debug::FIND, "Adding to search string: '" << par.asString(pos_type(0), par.size(), option, @@ -3827,10 +3840,13 @@ docstring stringifyFromCursor(DocIterator const & cur, int len) runparams.for_searchAdv = OutputParams::SearchWithoutDeleted; } else { runparams.for_searchAdv = OutputParams::SearchWithDeleted; } + if (ignoreFormats.getNonContent()) { + runparams.for_searchAdv |= OutputParams::SearchNonOutput; + } LYXERR(Debug::FIND, "Stringifying with cur: " << cur << ", from pos: " << cur.pos() << ", end: " << end); return par.asString(cur.pos(), end, option, &runparams); @@ -3851,11 +3867,10 @@ docstring stringifyFromCursor(DocIterator const & cur, int len) } LYXERR(Debug::FIND, "Don't know how to stringify from here: " << cur); return docstring(); } - /** Computes the LaTeX export of buf starting from cur and ending len positions * after cur, if len is positive, or at the paragraph or innermost inset end * if len is -1. */ docstring latexifyFromCursor(DocIterator const & cur, int len) @@ -3880,10 +3895,13 @@ docstring latexifyFromCursor(DocIterator const & cur, int len) runparams.for_searchAdv = OutputParams::SearchWithoutDeleted; } else { runparams.for_searchAdv = OutputParams::SearchWithDeleted; } + if (ignoreFormats.getNonContent()) { + runparams.for_searchAdv |= OutputParams::SearchNonOutput; + } if (cur.inTexted()) { // @TODO what about searching beyond/across paragraph breaks ? pos_type endpos = cur.paragraph().size(); if (len != -1 && endpos > cur.pos() + len) diff --git a/src/output_latex.cpp b/src/output_latex.cpp index bf841fea3f..61537c827f 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -463,11 +463,11 @@ void TeXEnvironment(Buffer const & buf, Text const & text, // been deleted with ct and changes are not output. bool output_changes; if (runparams.for_searchAdv == OutputParams::NoSearch) output_changes = buf.params().output_changes; else - output_changes = (runparams.for_searchAdv == OutputParams::SearchWithDeleted); + output_changes = ((runparams.for_searchAdv & OutputParams::SearchWithDeleted) != 0); if (size_t(pit + 1) < paragraphs.size()) { ParagraphList::const_iterator nextpar = paragraphs.iterator_at(pit + 1); Paragraph const & cpar = paragraphs.at(pit); if ((par->layout() != nextpar->layout() || par->params().depth() == nextpar->params().depth() @@ -794,11 +794,11 @@ void TeXOnePar(Buffer const & buf, if (style.inpreamble && !force) return; // Do not output empty commands if the whole paragraph has // been deleted with ct and changes are not output. - if ((runparams_in.for_searchAdv != OutputParams::SearchWithDeleted) && style.latextype != LATEX_ENVIRONMENT + if (((runparams_in.for_searchAdv & OutputParams::SearchWithDeleted) == 0) && style.latextype != LATEX_ENVIRONMENT && !par.empty() && par.isDeleted(0, par.size()) && !bparams.output_changes) return; LYXERR(Debug::OUTFILE, "TeXOnePar for paragraph " << pit << " ptr " << &par << " '" << everypar << "'"); @@ -1709,11 +1709,11 @@ void latexParagraphs(Buffer const & buf, // been deleted with ct and changes are not output. bool output_changes; if (runparams.for_searchAdv == OutputParams::NoSearch) output_changes = bparams.output_changes; else - output_changes = (runparams.for_searchAdv == OutputParams::SearchWithDeleted); + output_changes = ((runparams.for_searchAdv & OutputParams::SearchWithDeleted) != 0); bool const lastpar = size_t(pit + 1) >= paragraphs.size(); if (!lastpar) { ParagraphList::const_iterator nextpar = paragraphs.iterator_at(pit + 1); Paragraph const & cpar = paragraphs.at(pit); if ((par->layout() != nextpar->layout()
pgpJWlX1zUyi8.pgp
Description: Digitale Signatur von OpenPGP
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel