+ /// fold the macro in the next metrics call
+ void fold(Cursor & cur);
+ /// unfold the macro in the next metrics call
+ void unfold(Cursor & cur);
+ /// will it be folded or unfolded in the next metric call?
+ bool folded() const;
+
+ enum DisplayMode {
+ DISPLAY_INIT,
+ DISPLAY_INTERACTIVE_INIT,
+ DISPLAY_UNFOLDED,
+ DISPLAY_NORMAL
+ };
+
+ ///
+ DisplayMode displayMode() const { return displayMode_; }
+
+ ///
+ bool extraBraces() const { return displayMode_ == DISPLAY_NORMAL && arity() > 0; }
+
+ ///
+ docstring name() const;
+ ///
+ bool validName() const;
+ ///
+ size_t arity() const {
+ if (displayMode_ == DISPLAY_NORMAL )
+ return cells_.size();
+ else
+ return 0;
+ }
+
+ ///
+ size_t optionals() const { return optionals_; }
+ ///
+ void setOptionals(int n) {
+ if (n <= int(nargs()))
+ optionals_ = n;
+ }
+ /// Return the maximal number of arguments the macro is greedy for.
+ size_t appetite() const { return appetite_; }
+ ///
+ InsetCode lyxCode() const { return MATH_MACRO_CODE; }
+
+protected:
+ friend class MathData;
+ friend class ArgumentProxy;
+ friend class Cursor;
+
+ /// update the display mode (should only be called after detaching arguments)
+ void setDisplayMode(DisplayMode mode, int appetite = -1);
+ /// compute the next display mode
+ DisplayMode computeDisplayMode() const;
+ /// update macro definition
+ void updateMacro(MacroContext const & mc);
+ /// check if macro definition changed, argument changed etc. and adapt
+ void updateRepresentation(Cursor * cur, MacroContext const & mc, UpdateType);
+ /// empty macro, put arguments into args, possibly strip arity-attachedArgsNum_ empty ones.
+ /// Includes the optional arguments.
+ void detachArguments(std::vector<MathData> & args, bool strip);
+ /// attach arguments (maybe less than arity at the end of an MathData),
+ /// including the optional ones (even if it can be empty here)
+ void attachArguments(std::vector<MathData> const & args, size_t arity, int optionals);
+ ///
+ MacroData const * macro() { return macro_; }
+ ///
+ bool editMetrics(BufferView const * bv) const;
+