#include "FuncStatus.h"
#include "Lexer.h"
#include "LyXRC.h"
-#include "Undo.h"
#include "frontends/Painter.h"
#include "support/docstream.h"
#include "support/lstrings.h"
+#include <set>
#include <sstream>
using namespace std;
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);
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);
}
{
commitEditChanges(cur, old);
updateLook();
- cur.updateFlags(Update::Force);
+ cur.screenUpdateFlags(Update::Force);
return InsetMathNest::notifyCursorLeaves(old, cur);
}
{
// remove parameter which do not appear anymore in the definition
for (int i = numargs_; i > newNumArg; --i)
- removeParameter(cur, inset_pos, numargs_ - 1, false);
+ removeParameter(cur, inset_pos, numargs_ - 1, true);
// add missing parameter
for (int i = numargs_; i < newNumArg; ++i)
- insertParameter(cur, inset_pos, numargs_, false, false);
+ insertParameter(cur, inset_pos, numargs_, true, false);
}
///
AddRemoveMacroInstanceFix(int n, bool insert) : n_(n), insert_(insert) {}
///
- void operator()(MathMacro * macro) {
+ void operator()(MathMacro * macro)
+ {
if (macro->folded()) {
if (insert_)
macro->insertArgument(n_);
///
OptionalsMacroInstanceFix(int optionals) : optionals_(optionals) {}
///
- void operator()(MathMacro * macro) {
+ void operator()(MathMacro * macro)
+ {
macro->setOptionals(optionals_);
}
// remember hull to trigger preview reload
DocIterator hull(dit.buffer());
bool preview_reload_needed = false;
+ set<DocIterator> preview_hulls;
// iterate over all positions until macro is redefined
for (; dit; dit.forwardPos()) {
// left the outer hull?
if (!hull.empty() && dit.depth() == hull.depth()) {
- // reload the preview if necessary
+ // schedule reload of the preview if necessary
if (preview_reload_needed) {
- InsetMathHull * inset_hull =
- hull.nextInset()->asInsetMath()->asHullInset();
- LASSERT(inset_hull, /**/);
- inset_hull->reloadPreview(hull);
- cur.updateFlags(Update::Force);
+ preview_hulls.insert(hull);
preview_reload_needed = false;
}
hull.clear();
preview_reload_needed = true;
}
}
+
+ if (!preview_hulls.empty()) {
+ // reload the scheduled previews
+ set<DocIterator>::const_iterator sit = preview_hulls.begin();
+ set<DocIterator>::const_iterator end = preview_hulls.end();
+ for (; sit != end; ++sit) {
+ InsetMathHull * inset_hull =
+ sit->nextInset()->asInsetMath()->asHullInset();
+ LASSERT(inset_hull, /**/);
+ inset_hull->reloadPreview(*sit);
+ }
+ cur.screenUpdateFlags(Update::Force);
+ }
}
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) {
{
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)
flag.setEnabled(numargs_ < 9);
break;
+ case LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM:
case LFUN_MATH_MACRO_REMOVE_PARAM: {
int num = numargs_;
if (arg.size() != 0)
}
-docstring MathMacroTemplate::contextMenu(BufferView const &, int, int) const
+docstring MathMacroTemplate::contextMenuName() const
{
return from_ascii("context-math-macro-definition");
}