#include "support/debug.h"
#include "support/gettext.h"
#include "support/lassert.h"
+#include "support/lstrings.h"
#include "support/textutils.h"
#include <ostream>
#include <vector>
+using namespace lyx::support;
using namespace std;
namespace lyx {
MathMacro::MathMacro(Buffer * buf, docstring const & name)
: InsetMathNest(buf, 0), name_(name), displayMode_(DISPLAY_INIT),
expanded_(buf), attachedArgsNum_(0), optionals_(0), nextFoldMode_(true),
- macroBackup_(buf), macro_(0), needsUpdate_(false), appetite_(9)
+ macroBackup_(buf), macro_(0), needsUpdate_(false),
+ isUpdating_(false), appetite_(9)
{}
&& editing_[mi.base.bv]) {
// Macro will be edited in a old-style list mode here:
- LBUFERR(macro_, _("Text metrics error."));
+ LBUFERR(macro_);
Dimension fontDim;
FontInfo labelFont = sane_font;
math_font_max_dim(labelFont, fontDim.asc, fontDim.des);
dim.wid += 2;
metricsMarkers2(dim);
} else {
- LBUFERR(macro_, _("Text metrics error."));
+ LBUFERR(macro_);
// calculate metrics, hoping that all cells are seen
macro_->lock();
}
+class MathMacro::UpdateLocker
+{
+public:
+ explicit UpdateLocker(MathMacro & mm) : mac(mm)
+ {
+ mac.isUpdating_ = true;
+ }
+ ~UpdateLocker() { mac.isUpdating_ = false; }
+private:
+ MathMacro & mac;
+};
+
+
void MathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
UpdateType utype)
{
+ if (isUpdating_)
+ return;
+
+ UpdateLocker locker(*this);
+
// known macro?
if (macro_ == 0)
return;
// we should be ok to continue even if this fails.
LATTEST(macro_);
- // optional arguments make macros fragile
- if (optionals_ > 0 && os.fragile())
+ // Always protect macros in a fragile environment
+ if (os.fragile())
os << "\\protect";
os << "\\" << name();
void MathMacro::infoize(odocstream & os) const
{
- os << "Macro: " << name();
+ os << bformat(_("Macro: %1$s"), name());
}
void MathMacro::infoize2(odocstream & os) const
{
- os << "Macro: " << name();
-
+ os << bformat(_("Macro: %1$s"), name());
}