X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FMathMacroTemplate.h;h=b0c301897761a0caeb9124c91270386b960875a9;hb=cdc847fd304019a19425a0d5d9d42a556a937097;hp=dea1acf28ed406992056c2ed3e2cbc236ebda39b;hpb=4c9fe33c833fb7239a790acc847f45393983da2b;p=lyx.git diff --git a/src/mathed/MathMacroTemplate.h b/src/mathed/MathMacroTemplate.h index dea1acf28e..b0c3018977 100644 --- a/src/mathed/MathMacroTemplate.h +++ b/src/mathed/MathMacroTemplate.h @@ -17,24 +17,25 @@ #include "MacroTable.h" #include "MathData.h" -#include "support/types.h" - namespace lyx { +class OutputParams; +class XHTMLStream; + /// This class contains the macro definition. class MathMacroTemplate : public InsetMathNest { public: /// - MathMacroTemplate(); + MathMacroTemplate(Buffer * buf); /// - MathMacroTemplate(docstring const & name, int nargs, int optional, - MacroType type, + MathMacroTemplate(Buffer * buf, docstring const & name, int nargs, + int optional, MacroType type, std::vector const & optionalValues = std::vector(), MathData const & def = MathData(), MathData const & display = MathData()); - /// - explicit MathMacroTemplate(const docstring & str); + /// parses from string, returns false if failed + bool fromString (const docstring & str); /// bool editable() const { return true; } /// @@ -49,11 +50,13 @@ public: void write(WriteStream & os) const; /// Output LaTeX code, but assume that the macro is not definied yet /// if overwriteRedefinition is true - void write(WriteStream & os, bool overwriteRedefinition) const; + int write(WriteStream & os, bool overwriteRedefinition) const; + /// Nothing happens. This is simply to suppress the default output. + docstring xhtml(XHTMLStream &, OutputParams const &) const; /// - int plaintext(odocstream &, OutputParams const &) const; + int plaintext(odocstringstream &, OutputParams const &, size_t) const; /// - bool noFontChange() const { return true; } + bool inheritFont() const { return false; } /// docstring name() const; @@ -84,7 +87,7 @@ public: virtual void validate(LaTeXFeatures &) const; /// decide whether its a redefinition - void updateToContext(MacroContext const & mc) const; + void updateToContext(MacroContext const & mc); /// void draw(PainterInfo & pi, int x, int y) const; @@ -99,8 +102,10 @@ public: /// void infoize(odocstream & os) const; /// - docstring contextMenu(BufferView const &, int, int) const; - + std::string contextMenuName() const; + /// + void addToToc(DocIterator const & di, bool output_active, + UpdateType utype) const; protected: /// virtual void doDispatch(Cursor & cur, FuncRequest & cmd); @@ -116,17 +121,20 @@ private: virtual Inset * clone() const; /// remove #n with from<=n<=to - void removeArguments(Cursor & cur, int from, int to); + void removeArguments(Cursor & cur, DocIterator const & inset_pos, + int from, int to); /// shift every #n with from<=n, i.e. #n -> #(n-by) void shiftArguments(size_t from, int by); /// - void insertParameter(Cursor & cur, int pos, bool greedy = false, bool addarg = true); + void insertParameter(Cursor & cur, DocIterator const & inset_pos, + int pos, bool greedy = false, bool addarg = true); /// - void removeParameter(Cursor & cur, int pos, bool greedy = false); + void removeParameter(Cursor & cur, DocIterator const & inset_pos, + int pos, bool greedy = false); /// - void makeOptional(Cursor & cur); + void makeOptional(Cursor & cur, DocIterator const & inset_pos); /// - void makeNonOptional(Cursor & cur); + void makeNonOptional(Cursor & cur, DocIterator const & inset_pos); /// idx_type defIdx() const { return optionals_ + 1; } /// index of default value cell of optional parameter (#1 -> n=0) @@ -140,9 +148,10 @@ private: /// add missing #n arguments up to \c maxArg void insertMissingArguments(int maxArg); /// change the arity - void changeArity(Cursor & cur, int newNumArg); + void changeArity(Cursor & cur, DocIterator const & inset_pos, + int newNumArg); /// find arguments in definition and adapt the arity accordingly - void commitEditChanges(Cursor & cur); + void commitEditChanges(Cursor & cur, DocIterator const & inset_pos); /// The representation of the macro template, with some holes to edit mutable MathData look_; /// @@ -158,7 +167,7 @@ private: /// (re)newcommand or def mutable MacroType type_; /// defined before already? - mutable bool redefinition_; + bool redefinition_; /// void createLook(int args) const; ///