void metrics(MetricsInfo & mi, Dimension & dim) const {
mathMacro_.macro()->unlock();
mathMacro_.cell(idx_).metrics(mi, dim);
- if (!mathMacro_.editing() && !def_.empty())
+ if (!mathMacro_.editing(mi.base.bv) && !def_.empty())
def_.metrics(mi, dim);
mathMacro_.macro()->lock();
}
///
void draw(PainterInfo & pi, int x, int y) const {
- if (mathMacro_.editing()) {
+ if (mathMacro_.editing(pi.base.bv)) {
// The only way a ArgumentProxy can appear is in a cell of the
// MathMacro. Moreover the cells are only drawn in the DISPLAY_FOLDED
// mode and then, in the case of "editing_ == true" the monochrome
MathMacro::MathMacro(docstring const & name)
: InsetMathNest(0), name_(name), displayMode_(DISPLAY_INIT),
- attachedArgsNum_(0), previousCurIdx_(-1),
- optionals_(0), nextFoldMode_(true),
- macro_(0), editing_(false), needsUpdate_(false)
+ attachedArgsNum_(0), optionals_(0), nextFoldMode_(true),
+ macro_(0), needsUpdate_(false)
{}
macro_->unlock();
// calculate dimension with label while editing
- if (editing_) {
+ if (editing_[mi.base.bv]) {
FontInfo font = mi.base.font;
augmentFont(font, from_ascii("lyxtex"));
Dimension namedim;
int MathMacro::kerning() const {
- if (displayMode_ == DISPLAY_NORMAL && !editing_)
+ if (displayMode_ == DISPLAY_NORMAL)
return expanded_.kerning();
else
return 0;
{
// index of child where the cursor is (or -1 if none is edited)
int curIdx = -1;
- if (bvCur)
+ if (bvCur) {
curIdx = cursorIdx(*bvCur);
- previousCurIdx_ = curIdx;
+ previousCurIdx_[&bvCur->bv()] = curIdx;
+ }
// known macro?
if (macro_ == 0)
return;
// set edit mode to draw box around if needed
- bool prevEditing = editing_;
- editing_ = false;
- if (bvCur)
- editing_ = editMode(*bvCur);
+ bool prevEditing = false;
+ bool editing = false;
+ if (bvCur) {
+ prevEditing = editing_[&bvCur->bv()];
+ editing = editMode(*bvCur);
+ editing_[&bvCur->bv()] = editing;
+ }
// editMode changed and we have to switch default value and hole of optional?
if (optionals_ > 0 && nargs() > 0 &&
- prevEditing != editing_)
+ prevEditing != editing)
needsUpdate_ = true;
// macro changed?
for (size_t i = 0; i < nargs(); ++i)
cell(i).setXY(*pi.base.bv, x, y);
- if (editing_) {
+ if (editing_[pi.base.bv]) {
// draw header and rectangle around
FontInfo font = pi.base.font;
augmentFont(font, from_ascii("lyxtex"));
expanded_.cell(0).draw(pi, expx, expy);
// draw frame while editing
- if (editing_)
+ if (editing_[pi.base.bv])
pi.pain.rectangle(x, y - dim.asc, dim.wid, dim.height(), Color_mathmacroframe);
}
// another argument selected?
idx_type curIdx = cursorIdx(pi.base.bv->cursor());
- if (previousCurIdx_ != curIdx || editing_ != editMode(pi.base.bv->cursor()))
+ if (previousCurIdx_[pi.base.bv] != curIdx
+ || editing_[pi.base.bv] != editMode(pi.base.bv->cursor()))
pi.base.bv->cursor().updateFlags(Update::Force);
}
#include "MacroTable.h"
#include "MathData.h"
-namespace lyx {
+#include <map>
+namespace lyx {
/// This class contains the data for a macro.
class MathMacro : public InsetMathNest {
///
bool extraBraces() const { return displayMode_ == DISPLAY_NORMAL && arity() > 0; }
-
///
docstring name() const;
///
/// including the optional ones (even if it can be empty here)
void attachArguments(std::vector<MathData> const & args, size_t arity, int optionals);
///
- bool editing() { return editing_; }
+ bool editing(BufferView * bv) { return editing_[bv]; }
///
MacroData const * macro() { return macro_; }
/// number of arguments that were really attached
size_t attachedArgsNum_;
/// cursor position during last draw
- idx_type previousCurIdx_;
+ mutable std::map<BufferView const *, idx_type> previousCurIdx_;
/// optional argument attached? (only in DISPLAY_NORMAL mode)
size_t optionals_;
/// fold mode to be set in next metrics call?
/// this might invalidate after metrics was called
MacroData const * macro_;
///
- bool editing_;
+ mutable std::map<BufferView const *, bool> editing_;
///
std::string requires_;
/// update macro representation