]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.cpp
Improve the list of equations
[lyx.git] / src / mathed / MathMacro.cpp
index da22747ed881c7dce3da916ba727140e2eb53672..1311bc9c2ce49d405f093622c72c0ded4cbdd94e 100644 (file)
@@ -140,6 +140,15 @@ public:
        void htmlize(HtmlStream & ms) const { ms << mathMacro_->cell(idx_); }
        ///
        void octave(OctaveStream & os) const { os << mathMacro_->cell(idx_); }
+       ///
+       MathClass mathClass() const
+       {
+               return MC_UNKNOWN;
+               // This can be refined once the pointer issues are fixed. I did not
+               // notice any immediate crash with the following code, but it is risky
+               // nevertheless:
+               //return mathMacro_->cell(idx_).mathClass();
+       }
 
 private:
        ///
@@ -821,6 +830,26 @@ size_t MathMacro::appetite() const
 }
 
 
+MathClass MathMacro::mathClass() const
+{
+       // This can be just a heuristic, since it is only considered for display
+       // when the macro is not linearised. Therefore it affects:
+       // * The spacing of the inset while being edited,
+       // * Intelligent splitting
+       // * Cursor word movement (Ctrl-Arrow).
+       if (MacroData const * m = macroBackup()) {
+               // If it is a global macro and is defined explicitly
+               if (m->symbol()) {
+                       MathClass mc = string_to_class(m->symbol()->extra);
+                       if (mc != MC_UNKNOWN)
+                               return mc;
+               }
+       }
+       // Otherwise guess from the expanded macro
+       return d->expanded_.mathClass();
+}
+
+
 InsetMath::mode_type MathMacro::currentMode() const
 {
        // There is no way to guess the mode of user defined macros, so they are