#include "frontends/Painter.h"
+#include "support/lassert.h"
#include "support/convert.h"
#include "support/debug.h"
#include "support/gettext.h"
// find this in cursor old
Cursor insetCur = old;
int scriptSlice = insetCur.find(this);
- BOOST_ASSERT(scriptSlice != -1);
+ LASSERT(scriptSlice != -1, /**/);
insetCur.cutOff(scriptSlice);
commitEditChanges(insetCur);
if (it.nextInset()->lyxCode() != MATHMACROARG_CODE)
continue;
MathMacroArgument * arg = static_cast<MathMacroArgument*>(it.nextInset());
- if (arg->number() >= from + 1)
+ if (arg->number() >= int(from) + 1)
arg->setNumber(arg->number() + by);
}
num = convert<int>(arg);
bool on = (num >= optionals_
&& numargs_ < 9 && num <= numargs_ + 1);
- flag.enabled(on);
+ flag.setEnabled(on);
break;
}
case LFUN_MATH_MACRO_APPEND_GREEDY_PARAM:
- flag.enabled(numargs_ < 9);
+ flag.setEnabled(numargs_ < 9);
break;
case LFUN_MATH_MACRO_REMOVE_PARAM: {
int num = numargs_;
if (arg.size() != 0)
num = convert<int>(arg);
- flag.enabled(num >= 1 && num <= numargs_);
+ flag.setEnabled(num >= 1 && num <= numargs_);
break;
}
case LFUN_MATH_MACRO_MAKE_OPTIONAL:
- flag.enabled(numargs_ > 0
+ flag.setEnabled(numargs_ > 0
&& optionals_ < numargs_
&& type_ != MacroTypeDef);
break;
case LFUN_MATH_MACRO_MAKE_NONOPTIONAL:
- flag.enabled(optionals_ > 0
+ flag.setEnabled(optionals_ > 0
&& type_ != MacroTypeDef);
break;
case LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM:
- flag.enabled(numargs_ < 9);
+ flag.setEnabled(numargs_ < 9);
break;
case LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM:
- flag.enabled(optionals_ > 0);
+ flag.setEnabled(optionals_ > 0);
break;
case LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM:
- flag.enabled(numargs_ == 0
+ flag.setEnabled(numargs_ == 0
&& type_ != MacroTypeDef);
break;
case LFUN_IN_MATHMACROTEMPLATE:
- flag.enabled();
+ flag.setEnabled(true);
break;
default:
void MathMacroTemplate::write(ostream & os) const
{
odocstringstream oss;
- WriteStream wi(oss, false, false);
+ WriteStream wi(oss, false, false, false);
oss << "FormulaMacro\n";
write(wi);
os << to_utf8(oss.str());
else
os << "\\newcommandx";
- os << "\\" << name().c_str()
+ os << "\\" << name()
<< "[" << numargs_ << "]"
<< "[usedefault, addprefix=\\global";
for (int i = 0; i < optionals_; ++i) {
} else {
// macros without optionals use standard _global_ \def macros:
// \global\def\foo#1#2{#1,#2}
- os << "\\global\\def\\" << name().c_str();
+ os << "\\global\\def\\" << name();
docstring param = from_ascii("#0");
for (int i = 1; i <= numargs_; ++i) {
param[1] = '0' + i;
os << "\\renewcommand";
else
os << "\\newcommand";
- os << "{\\" << name().c_str() << '}';
+ os << "{\\" << name() << '}';
if (numargs_ > 0)
os << '[' << numargs_ << ']';
void MathMacroTemplate::validate(LaTeXFeatures & features) const
{
- if (optionals_ > 0) {
- //features.require("newlyxcommand");
+ // we need global optional macro arguments. They are not available
+ // with \def, and \newcommand does not support global macros. So we
+ // are bound to xargs also for the single-optional-parameter case.
+ if (optionals_ > 0)
features.require("xargs");
- }
}
void MathMacroTemplate::getDefaults(vector<docstring> & defaults) const
os << "Math Macro: \\" << name();
}
+
+docstring MathMacroTemplate::contextMenu(BufferView const &, int, int) const
+{
+ return from_ascii("context-math-macro-definition");
+}
+
} // namespace lyx