InsetMathNest::InsetMathNest(Buffer * buf, idx_type nargs)
- : InsetMath(buf), cells_(nargs), lock_(false), mouse_hover_(false)
+ : InsetMath(buf), cells_(nargs), lock_(false)
{
setBuffer(*buf);
}
InsetMathNest::InsetMathNest(InsetMathNest const & inset)
- : InsetMath(inset), cells_(inset.cells_), lock_(inset.lock_),
- mouse_hover_(false)
+ : InsetMath(inset), cells_(inset.cells_), lock_(inset.lock_)
{}
+InsetMathNest::~InsetMathNest()
+{
+ map<BufferView const *, bool>::iterator it = mouse_hover_.begin();
+ map<BufferView const *, bool>::iterator end = mouse_hover_.end();
+ for (; it != end; ++it)
+ if (it->second)
+ it->first->clearLastInset(this);
+}
+
+
InsetMathNest & InsetMathNest::operator=(InsetMathNest const & inset)
{
cells_ = inset.cells_;
lock_ = inset.lock_;
- mouse_hover_ = false;
+ mouse_hover_.clear();
InsetMath::operator=(inset);
return *this;
}
}
-int InsetMathNest::latex(odocstream & os, OutputParams const & runparams) const
+int InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
{
- WriteStream wi(os, runparams.moving_arg, true,
+ WriteStream wi(os.os(), runparams.moving_arg, true,
runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
runparams.encoding);
+ wi.canBreakLine(os.canBreakLine());
write(wi);
+ os.canBreakLine(wi.canBreakLine());
return wi.line();
}
-bool InsetMathNest::setMouseHover(bool mouse_hover)
+bool InsetMathNest::setMouseHover(BufferView const * bv, bool mouse_hover)
{
- mouse_hover_ = mouse_hover;
+ mouse_hover_[bv] = mouse_hover;
return true;
}
}
cur.niceInsert(topaste, parseflg, false);
cur.clearSelection(); // bug 393
- // FIXME audit setBuffer/updateBuffer calls
- cur.buffer()->updateBuffer();
+ cur.forceBufferUpdate();
cur.finishUndo();
break;
}
// Prevent stale position >= size crash
// Probably not necessary anymore, see eraseSelection (gb 2005-10-09)
cur.normalize();
- // FIXME audit setBuffer/updateBuffer calls
- cur.buffer()->updateBuffer();
+ cur.forceBufferUpdate();
break;
case LFUN_COPY:
case LFUN_CHAR_LEFT:
case LFUN_CHAR_BACKWARD:
case LFUN_CHAR_FORWARD:
- cur.updateFlags(Update::Decoration | Update::FitCursor);
+ cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
case LFUN_CHAR_RIGHT_SELECT:
case LFUN_CHAR_LEFT_SELECT:
case LFUN_CHAR_BACKWARD_SELECT:
case LFUN_DOWN:
case LFUN_UP:
- cur.updateFlags(Update::Decoration | Update::FitCursor);
+ cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
case LFUN_DOWN_SELECT:
case LFUN_UP_SELECT: {
// close active macro
case LFUN_PARAGRAPH_UP:
case LFUN_PARAGRAPH_DOWN:
- cur.updateFlags(Update::Decoration | Update::FitCursor);
+ cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
case LFUN_PARAGRAPH_UP_SELECT:
case LFUN_PARAGRAPH_DOWN_SELECT:
break;
case LFUN_LINE_BEGIN:
case LFUN_WORD_BACKWARD:
case LFUN_WORD_LEFT:
- cur.updateFlags(Update::Decoration | Update::FitCursor);
+ cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
case LFUN_LINE_BEGIN_SELECT:
case LFUN_WORD_BACKWARD_SELECT:
case LFUN_WORD_LEFT_SELECT:
case LFUN_WORD_FORWARD:
case LFUN_WORD_RIGHT:
case LFUN_LINE_END:
- cur.updateFlags(Update::Decoration | Update::FitCursor);
+ cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
case LFUN_WORD_FORWARD_SELECT:
case LFUN_WORD_RIGHT_SELECT:
case LFUN_LINE_END_SELECT:
break;
case LFUN_CELL_FORWARD:
- cur.updateFlags(Update::Decoration | Update::FitCursor);
+ cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
cur.inset().idxNext(cur);
break;
case LFUN_CELL_BACKWARD:
- cur.updateFlags(Update::Decoration | Update::FitCursor);
+ cur.screenUpdateFlags(Update::Decoration | Update::FitCursor);
cur.inset().idxPrev(cur);
break;
cur.posBackward();
cur.pushBackward(*cur.nextInset());
cur.niceInsert(save_selection);
- // FIXME audit setBuffer/updateBuffer calls
- cur.buffer()->updateBuffer();
+ cur.forceBufferUpdate();
#else
if (currentMode() == Inset::TEXT_MODE) {
cur.recordUndoSelection();
}
case LFUN_REGEXP_MODE: {
- InsetMathHull * i = dynamic_cast<InsetMathHull *>(cur.inset().asInsetMath());
- if (i && i->getType() == hullRegexp) {
- cur.message(_("Already in regular expression mode"));
- break;
+ InsetMath * im = cur.inset().asInsetMath();
+ if (im) {
+ InsetMathHull * i = im->asHullInset();
+ if (i && i->getType() == hullRegexp) {
+ cur.message(_("Already in regular expression mode"));
+ break;
+ }
}
cur.macroModeClose();
docstring const save_selection = grabAndEraseSelection(cur);
if (have_l)
cur.insert(MathAtom(new InsetMathBig(lname,
ldelim)));
- cur.niceInsert(selection);
- if (have_r)
+ // first insert the right delimiter and then go back
+ // and re-insert the selection (bug 7088)
+ if (have_r) {
cur.insert(MathAtom(new InsetMathBig(rname,
rdelim)));
+ cur.posBackward();
+ }
+ cur.niceInsert(selection);
}
// Don't call cur.undispatched() if we did nothing, this would
// lead to infinite recursion via Text::dispatch().
cur.niceInsert(cmd.argument());
}
break;
+ }
+
+ case LFUN_UNICODE_INSERT: {
+ if (cmd.argument().empty())
+ break;
+ docstring hexstring = cmd.argument();
+ if (isHex(hexstring)) {
+ char_type c = hexToInt(hexstring);
+ if (c >= 32 && c < 0x10ffff) {
+ docstring s = docstring(1, c);
+ FuncCode code = currentMode() == MATH_MODE ?
+ LFUN_MATH_INSERT : LFUN_SELF_INSERT;
+ lyx::dispatch(FuncRequest(code, s));
+ }
}
+ break;
+ }
case LFUN_DIALOG_SHOW_NEW_INSET: {
docstring const & name = cmd.argument();
string data;
if (name == "ref") {
InsetMathRef tmp(buffer_, name);
- data = tmp.createDialogStr(to_utf8(name));
+ data = tmp.createDialogStr();
cur.bv().showDialog(to_utf8(name), data);
} else if (name == "mathspace") {
cur.bv().showDialog(to_utf8(name));
if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
cur.recordUndoSelection();
cur.insert(ar);
- // FIXME audit setBuffer/updateBuffer calls
- cur.buffer()->updateBuffer();
+ cur.forceBufferUpdate();
} else
cur.undispatched();
break;
break;
}
+ case LFUN_MATH_MODE:
+ // forbid "math-mode on" in math mode to prevent irritating
+ // behaviour of menu entries (bug 6709)
+ flag.setEnabled(currentMode() == TEXT_MODE || arg != "on");
+ break;
+
case LFUN_MATH_INSERT:
flag.setEnabled(currentMode() != TEXT_MODE);
break;
}
case LFUN_SPECIALCHAR_INSERT:
+ case LFUN_SCRIPT_INSERT:
// FIXME: These would probably make sense in math-text mode
flag.setEnabled(false);
break;
// Update::FitCursor: adjust the screen to the cursor
// position if needed
// cur.result().update(): don't overwrite previously set flags.
- cur.updateFlags(Update::Decoration | Update::FitCursor
- | cur.result().update());
+ cur.screenUpdateFlags(Update::Decoration | Update::FitCursor
+ | cur.result().screenUpdate());
} else if (cmd.button() == mouse_button::button2) {
if (cap::selection()) {
// See comment in Text::dispatch why we do this
// only select with button 1
if (cmd.button() == mouse_button::button1) {
Cursor & bvcur = cur.bv().cursor();
- if (bvcur.anchor_.hasPart(cur)) {
+ if (bvcur.realAnchor().hasPart(cur)) {
//lyxerr << "## lfunMouseMotion: cursor: " << cur << endl;
bvcur.setCursor(cur);
bvcur.setSelection(true);
if (cmd.button() == mouse_button::button1) {
if (!cur.selection())
- cur.noUpdate();
+ cur.noScreenUpdate();
else {
Cursor & bvcur = cur.bv().cursor();
bvcur.setSelection(true);
// visual box corners that define the inset. If we know for
// sure that we stay within the same cell we can optimize for
// that using:
- //cur.updateFlags(Update::SinglePar | Update::FitCursor);
+ //cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
}
return true;
}
// visual box corners that define the inset. If we know for
// sure that we stay within the same cell we can optimize for
// that using:
- //cur.updateFlags(Update::SinglePar | Update::FitCursor);
+ //cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
return true;
}
// visual box corners that define the inset. If we know for
// sure that we stay within the same cell we can optimize for
// that using:
- //cur.updateFlags(Update::FitCursor);
+ //cur.screenUpdateFlags(Update::FitCursor);
return true;
}
globals.push_back(from_ascii("\\cases"));
globals.push_back(from_ascii("\\substack"));
globals.push_back(from_ascii("\\xymatrix"));
+ globals.push_back(from_ascii("\\Diagram"));
globals.push_back(from_ascii("\\subarray"));
globals.push_back(from_ascii("\\array"));
globals.push_back(from_ascii("\\sqrt"));