commit 2db682b97eff2362bb7865c7637881906bf0f2cf
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Mon Jul 25 22:02:59 2022 +0200

    Rename eolString() to eol() ans pass a MathTeXStream parameter
    
    This is completely equivalent, but will allow in eol() to determine
    whether one is preparing a preview.
    
    Related to bug #11535.
---
 src/mathed/InsetMathEnsureMath.h |    3 +--
 src/mathed/InsetMathGrid.cpp     |   15 +++++++--------
 src/mathed/InsetMathGrid.h       |    4 ++--
 src/mathed/InsetMathHull.cpp     |   13 ++++++-------
 src/mathed/InsetMathHull.h       |    4 ++--
 5 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/src/mathed/InsetMathEnsureMath.h b/src/mathed/InsetMathEnsureMath.h
index d0a60d0..40efe73 100644
--- a/src/mathed/InsetMathEnsureMath.h
+++ b/src/mathed/InsetMathEnsureMath.h
@@ -44,8 +44,7 @@ public:
        ///
        void delCol(col_type) override {}
        ///
-       docstring eolString(row_type, bool, bool, bool) const override
-       { return docstring(); }
+       void eol(TeXMathStream &, row_type, bool, bool, bool) const override {}
        ///
        docstring eocString(col_type, col_type) const override
        { return docstring(); }
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 96ec13b..85511e6 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -750,7 +750,7 @@ void InsetMathGrid::updateBuffer(ParIterator const & it, 
UpdateType utype, bool
 }
 
 
-docstring InsetMathGrid::eolString(row_type row, bool fragile,
+void InsetMathGrid::eol(TeXMathStream & os, row_type row, bool fragile,
                bool /*latex*/, bool last_eoln) const
 {
        docstring eol;
@@ -770,9 +770,9 @@ docstring InsetMathGrid::eolString(row_type row, bool 
fragile,
 
        // only add \\ if necessary
        if (eol.empty() && row + 1 == nrows() && (nrows() == 1 || !last_eoln))
-               return docstring();
+               return;
 
-       return (fragile ? "\\protect\\\\" : "\\\\") + eol;
+       os << (fragile ? "\\protect\\\\" : "\\\\") << eol;
 }
 
 
@@ -1247,7 +1247,7 @@ void InsetMathGrid::write(TeXMathStream & os,
                           row_type end_row, col_type end_col) const
 {
        MathEnsurer ensurer(os, false);
-       docstring eol;
+       docstring eolstr;
        // As of 2018 (with amendment in LaTeX 2021/06),
        // \\ is a robust command and its protection
        // is no longer necessary
@@ -1299,18 +1299,17 @@ void InsetMathGrid::write(TeXMathStream & os,
                        os << eocString(col + nccols - 1, lastcol);
                        col += nccols;
                }
-               eol = eolString(row, fragile, os.latex(), last_eoln);
-               os << eol;
+               eol(os, row, fragile, os.latex(), last_eoln);
                // append newline only if line wasn't completely empty
                // and the formula is not written on a single line
-               bool const empty = emptyline && eol.empty();
+               bool const empty = emptyline && eolstr.empty();
                if (!empty && nrows() > 1)
                        os << "\n";
        }
        // @TODO use end_row instead of nrows() ?
        docstring const s = verboseHLine(rowinfo_[nrows()].lines);
        if (!s.empty()) {
-               if (eol.empty()) {
+               if (eolstr.empty()) {
                        if (fragile)
                                os << "\\protect";
                        os << "\\\\";
diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h
index ce8a852..ae95eaf 100644
--- a/src/mathed/InsetMathGrid.h
+++ b/src/mathed/InsetMathGrid.h
@@ -246,8 +246,8 @@ protected:
        virtual int rightMargin() const { return 0; }
 
        /// returns proper 'end of line' code for LaTeX
-       virtual docstring eolString(row_type row, bool fragile, bool latex,
-                       bool last_eoln) const;
+       virtual void eol(TeXMathStream & os, row_type row, bool fragile, bool 
latex,
+                        bool last_eoln) const;
        /// returns proper 'end of column' code for LaTeX
        virtual docstring eocString(col_type col, col_type lastcol) const;
        /// splits cells and shifts right part to the next cell
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 689950d..8ede260 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -1680,27 +1680,26 @@ void InsetMathHull::mutate(HullType newtype)
 }
 
 
-docstring InsetMathHull::eolString(row_type row, bool fragile, bool latex,
-               bool last_eoln) const
+void InsetMathHull::eol(TeXMathStream & os, row_type row, bool fragile, bool 
latex,
+                        bool last_eoln) const
 {
-       docstring res;
        if (numberedType()) {
                if (label_[row]) {
                        docstring const name =
                                latex ? escape(label_[row]->getParam("name"))
                                      : label_[row]->getParam("name");
-                       res += "\\label{" + name + '}';
+                       os << "\\label{" + name + '}';
                }
                if (type_ != hullMultline) {
                        if (numbered_[row]  == NONUMBER)
-                               res += "\\nonumber ";
+                               os << "\\nonumber ";
                        else if (numbered_[row]  == NOTAG)
-                               res += "\\notag ";
+                               os<< "\\notag ";
                }
        }
        // Never add \\ on the last empty line of eqnarray and friends
        last_eoln = false;
-       return res + InsetMathGrid::eolString(row, fragile, latex, last_eoln);
+       InsetMathGrid::eol(os, row, fragile, latex, last_eoln);
 }
 
 void InsetMathHull::write(TeXMathStream & os) const
diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h
index b019188..52e8177 100644
--- a/src/mathed/InsetMathHull.h
+++ b/src/mathed/InsetMathHull.h
@@ -202,8 +202,8 @@ protected:
        /// override to set to 0 for inline equation
        int border() const override;
        ///
-       docstring eolString(row_type row, bool fragile, bool latex,
-                       bool last_eoln) const override;
+       void eol(TeXMathStream & os, row_type row, bool fragile, bool latex,
+                bool last_eoln) const override;
 
 private:
        Inset * clone() const override;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to