]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.cpp
mathed: bformat infoize messages
[lyx.git] / src / mathed / MathMacro.cpp
index 2f0241b5ac50b5bf6cc07a8252a0a1f5641e4f8c..f4150f30f84250533ff313105aa5ebfda07605cb 100644 (file)
 #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 {
@@ -126,7 +128,8 @@ private:
 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)
 {}
 
 
@@ -312,9 +315,27 @@ void MathMacro::updateMacro(MacroContext const & mc)
 }
 
 
+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;
@@ -787,14 +808,13 @@ void MathMacro::octave(OctaveStream & os) const
 
 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());
 }