X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FMathMacroTemplate.cpp;h=3eadf6d2ef2242e04a6700b7808b7f611fa946b7;hb=573500dd04f154f27318ac5ec469a337f97fe9f0;hp=2d74457040e46ef01a314252f614402144a80585;hpb=f19b6178a9505e4dfe17f1836096f4ce1040a200;p=lyx.git diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index 2d74457040..3eadf6d2ef 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -35,7 +35,6 @@ #include "FuncStatus.h" #include "Lexer.h" #include "LyXRC.h" -#include "Undo.h" #include "frontends/Painter.h" @@ -592,6 +591,7 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const { + ColorChanger dummy0(pi.base.font, Color_math); FontSetChanger dummy1(pi.base, from_ascii("mathnormal")); StyleChanger dummy2(pi.base, LM_ST_TEXT); @@ -616,7 +616,7 @@ void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const void MathMacroTemplate::edit(Cursor & cur, bool front, EntryDirection entry_from) { updateLook(); - cur.updateFlags(Update::SinglePar); + cur.screenUpdateFlags(Update::SinglePar); InsetMathNest::edit(cur, front, entry_from); } @@ -625,15 +625,16 @@ bool MathMacroTemplate::notifyCursorLeaves(Cursor const & old, Cursor & cur) { commitEditChanges(cur, old); updateLook(); - cur.updateFlags(Update::Force); + cur.screenUpdateFlags(Update::Force); return InsetMathNest::notifyCursorLeaves(old, cur); } void MathMacroTemplate::removeArguments(Cursor & cur, - DocIterator const & /*insetPos*/, int from, int to) + DocIterator const & /*inset_pos*/, int from, int to) { - for (DocIterator it = doc_iterator_begin(&buffer(), this); it; it.forwardChar()) { + DocIterator it = doc_iterator_begin(&buffer(), this); + for (; it; it.forwardChar()) { if (!it.nextInset()) continue; if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) @@ -672,7 +673,7 @@ void MathMacroTemplate::shiftArguments(size_t from, int by) int MathMacroTemplate::maxArgumentInDefinition() const { // We don't have a buffer when pasting from the clipboard (bug 6014). - Buffer const * macro_buffer = this->isBufferValid() ? &buffer() : 0; + Buffer const * macro_buffer = isBufferLoaded() ? &buffer() : 0; int maxArg = 0; DocIterator it = doc_iterator_begin(macro_buffer, this); it.idx() = defIdx(); @@ -716,15 +717,15 @@ void MathMacroTemplate::insertMissingArguments(int maxArg) void MathMacroTemplate::changeArity(Cursor & cur, - DocIterator const & insetPos, int newNumArg) + DocIterator const & inset_pos, int newNumArg) { // remove parameter which do not appear anymore in the definition for (int i = numargs_; i > newNumArg; --i) - removeParameter(cur, insetPos, numargs_ - 1, false); + removeParameter(cur, inset_pos, numargs_ - 1, false); // add missing parameter for (int i = numargs_; i < newNumArg; ++i) - insertParameter(cur, insetPos, numargs_, false, false); + insertParameter(cur, inset_pos, numargs_, false, false); } @@ -774,7 +775,7 @@ class NullMacroInstanceFix { public: /// - void operator()(MathMacro * macro) {} + void operator()(MathMacro * ) {} }; @@ -801,7 +802,7 @@ void fixMacroInstances(Cursor & cur, DocIterator const & inset_pos, hull.nextInset()->asInsetMath()->asHullInset(); LASSERT(inset_hull, /**/); inset_hull->reloadPreview(hull); - cur.updateFlags(Update::Force); + cur.screenUpdateFlags(Update::Force); preview_reload_needed = false; } hull.clear(); @@ -973,7 +974,7 @@ void MathMacroTemplate::makeNonOptional(Cursor & cur, void MathMacroTemplate::doDispatch(Cursor & cur, FuncRequest & cmd) { string const arg = to_utf8(cmd.argument()); - switch (cmd.action) { + switch (cmd.action()) { case LFUN_MATH_MACRO_ADD_PARAM: if (numargs_ < 9) { @@ -1063,7 +1064,7 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd, { bool ret = true; string const arg = to_utf8(cmd.argument()); - switch (cmd.action) { + switch (cmd.action()) { case LFUN_MATH_MACRO_ADD_PARAM: { int num = numargs_ + 1; if (arg.size() != 0) @@ -1153,8 +1154,10 @@ void MathMacroTemplate::write(WriteStream & os) const } -void MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) const +int MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) const { + int num_lines = 0; + if (os.latex()) { if (optionals_ > 0) { // macros with optionals use the xargs package, e.g.: @@ -1217,14 +1220,24 @@ void MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) cons if (os.latex()) { // writing .tex. done. os << "\n"; + ++num_lines; } else { // writing .lyx, write special .tex export only if necessary - if (!cell(displayIdx()).empty()) + if (!cell(displayIdx()).empty()) { os << "\n{" << cell(displayIdx()) << '}'; + ++num_lines; + } } + + return num_lines; } +docstring MathMacroTemplate::xhtml(XHTMLStream &, OutputParams const &) const +{ + return docstring(); +} + int MathMacroTemplate::plaintext(odocstream & os, OutputParams const &) const {