[LyX/master] Add Inset::isEnvironment()

Juergen Spitzmueller spitz at lyx.org
Mon Apr 10 05:06:25 UTC 2023


commit 1dc666082eeac9430cc5f242e319374c58da373b
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Mon Apr 10 08:09:32 2023 +0200

    Add Inset::isEnvironment()
    
    This usually returns InsetLayout::isEnvironment(), but listings has
    specific conditions (depending on whether it is inline or not)
---
 src/insets/Inset.h         |    3 +++
 src/insets/InsetListings.h |    2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index fd55d69..fa9214d 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -15,6 +15,7 @@
 #ifndef INSETBASE_H
 #define INSETBASE_H
 
+#include "InsetLayout.h"
 #include "ColorCode.h"
 #include "InsetCode.h"
 #include "LayoutEnums.h"
@@ -601,6 +602,8 @@ public:
 	virtual void acceptChanges() {}
 	/// reject the changes within the inset
 	virtual void rejectChanges() {}
+	///
+	virtual bool isEnvironment() const { return getLayout().latextype() == InsetLaTeXType::ENVIRONMENT; }
 
 	///
 	virtual bool needsCProtection(bool const, bool const) const { return false; }
diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h
index 9d4eeb1..080b7b7 100644
--- a/src/insets/InsetListings.h
+++ b/src/insets/InsetListings.h
@@ -38,6 +38,8 @@ public:
 	static void string2params(std::string const &, InsetListingsParams &);
 	///
 	static std::string params2string(InsetListingsParams const &);
+	///
+	bool isEnvironment() const { return !params().isInline(); }
 private:
 	///
 	bool isLabeled() const override { return true; }


More information about the lyx-cvs mailing list