commit 3bd2b52df4f43400c1f021070362955c333c22d9
Author: Koji Yokota <yok...@lyx.org>
Date:   Fri May 2 11:53:25 2025 +0900

    Add main new files
---
 src/mathed/InsetMathIntertext.cpp | 96 +++++++++++++++++++++++++++++++++++++++
 src/mathed/InsetMathIntertext.h   | 55 ++++++++++++++++++++++
 2 files changed, 151 insertions(+)

diff --git a/src/mathed/InsetMathIntertext.cpp 
b/src/mathed/InsetMathIntertext.cpp
new file mode 100644
index 0000000000..b992c643b2
--- /dev/null
+++ b/src/mathed/InsetMathIntertext.cpp
@@ -0,0 +1,96 @@
+/**
+ * \file InsetMathIntertext.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Koji Yokota
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "InsetMathIntertext.h"
+
+#include "Buffer.h"
+#include "BufferView.h"
+#include "Dimension.h"
+#include "LaTeXFeatures.h"
+#include "MathData.h"
+#include "MathFactory.h"
+#include "MathStream.h"
+#include "MathSupport.h"
+#include "MetricsInfo.h"
+#include "support/docstream.h"
+#include "support/lstrings.h"
+
+using lyx::support::escape;
+
+
+namespace lyx {
+
+InsetMathIntertext::InsetMathIntertext(Buffer * buf, docstring const & name)
+       : InsetMathNest(buf, 1), name_(name)
+{}
+
+
+void InsetMathIntertext::write(TeXMathStream & os) const
+{
+       ModeSpecifier specifier(os, TEXT_MODE);
+       os << '\\' << name_ << '{' << cell(0) << '}';
+}
+
+
+Inset * InsetMathIntertext::clone() const
+{
+       return new InsetMathIntertext(*this);
+}
+
+
+void InsetMathIntertext::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       Changer dummy = mi.base.changeFontSet("text");
+       cell(0).metrics(mi, dim);
+       dim.wid = 4;
+       if (name_ == "shortintertext")
+               dim.asc += dim.asc + dim.des + spacer_;
+       else
+               dim.asc += 2 * (dim.asc + dim.des + spacer_);
+       dim.des += 2;
+}
+
+
+void InsetMathIntertext::draw(PainterInfo & pi, int x, int y) const
+{
+       Changer dummy = pi.base.changeFontSet("text");
+       // in sync with InsetMathHull::draw
+       Dimension const dim = dimension(*pi.base.bv);
+       int texty;
+       if (name_ == "shortintertext")
+               texty = y - (dim.asc - dim.des - spacer_) + spacer_;
+       else
+               texty = y - (dim.asc - 2*dim.des - 2*spacer_) + 2*spacer_;
+       cell(0).draw(pi, (pi.leftx + x)/2, texty);
+}
+
+
+docstring InsetMathIntertext::name() const
+{
+       return name_;
+}
+
+
+void InsetMathIntertext::infoize(odocstream & os) const
+{
+       os << "Intertext ";
+}
+
+
+void InsetMathIntertext::validate(LaTeXFeatures & features) const
+{
+       if (name_ == "shortintertext" && features.runparams().isLaTeX())
+               features.require("mathtools");
+       InsetMathNest::validate(features);
+}
+
+} // namespace lyx
diff --git a/src/mathed/InsetMathIntertext.h b/src/mathed/InsetMathIntertext.h
new file mode 100644
index 0000000000..032babd93b
--- /dev/null
+++ b/src/mathed/InsetMathIntertext.h
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+/**
+ * \file InsetMathIntertext.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Koji Yokota
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef MATH_INTERTEXTINSET_H
+#define MATH_INTERTEXTINSET_H
+
+#include "InsetMathNest.h"
+
+#include "support/docstring.h"
+
+
+namespace lyx {
+
+
+/// Support for LaTeX's \\intertext command
+
+class InsetMathIntertext : public InsetMathNest {
+public:
+       ///
+       explicit InsetMathIntertext(Buffer * buf, docstring const & name);
+       ///
+       mode_type currentMode() const override { return TEXT_MODE; }
+       ///
+       docstring name() const override;
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const override;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const override;
+       ///
+       void write(TeXMathStream & os) const override;
+       ///
+       void infoize(odocstream & os) const override;
+       ///
+       // InsetCode lyxCode() const override { return MATH_INTERTEXT_CODE; }
+       ///
+       void validate(LaTeXFeatures &) const override;
+
+private:
+       Inset * clone() const override;
+       /// the string
+       docstring name_;
+       int spacer_ = 2;
+};
+
+
+} // namespace lyx
+#endif
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to