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;
}
}
-void InsetMathNest::updateLabels(ParIterator const & it, UpdateType utype)
+void InsetMathNest::updateBuffer(ParIterator const & it, UpdateType utype)
{
for (idx_type i = 0, n = nargs(); i != n; ++i)
- cell(i).updateLabels(it, utype);
+ cell(i).updateBuffer(it, utype);
}
}
-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;
}
Parse::flags parseflg = Parse::QUIET | Parse::USETEXT;
- switch (cmd.action) {
+ FuncCode const act = cmd.action();
+ switch (act) {
case LFUN_CLIPBOARD_PASTE:
parseflg |= Parse::VERBATIM;
}
cur.niceInsert(topaste, parseflg, false);
cur.clearSelection(); // bug 393
- // FIXME audit setBuffer/updateLabels calls
- cur.buffer()->updateLabels();
+ 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/updateLabels calls
- cur.buffer()->updateLabels();
+ 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_CHAR_FORWARD_SELECT: {
// are we in a selection?
- bool select = (cmd.action == LFUN_CHAR_RIGHT_SELECT
- || cmd.action == LFUN_CHAR_LEFT_SELECT
- || cmd.action == LFUN_CHAR_BACKWARD_SELECT
- || cmd.action == LFUN_CHAR_FORWARD_SELECT);
+ bool select = (act == LFUN_CHAR_RIGHT_SELECT
+ || act == LFUN_CHAR_LEFT_SELECT
+ || act == LFUN_CHAR_BACKWARD_SELECT
+ || act == LFUN_CHAR_FORWARD_SELECT);
// are we moving forward or backwards?
// If the command was RIGHT or LEFT, then whether we're moving forward
// or backwards depends on the cursor movement mode (logical or visual):
bool forward;
FuncCode finish_lfun;
- if (cmd.action == LFUN_CHAR_FORWARD
- || cmd.action == LFUN_CHAR_FORWARD_SELECT) {
+ if (act == LFUN_CHAR_FORWARD
+ || act == LFUN_CHAR_FORWARD_SELECT) {
forward = true;
finish_lfun = LFUN_FINISHED_FORWARD;
}
- else if (cmd.action == LFUN_CHAR_BACKWARD
- || cmd.action == LFUN_CHAR_BACKWARD_SELECT) {
+ else if (act == LFUN_CHAR_BACKWARD
+ || act == LFUN_CHAR_BACKWARD_SELECT) {
forward = false;
finish_lfun = LFUN_FINISHED_BACKWARD;
}
else {
- bool right = (cmd.action == LFUN_CHAR_RIGHT_SELECT
- || cmd.action == LFUN_CHAR_RIGHT);
+ bool right = (act == LFUN_CHAR_RIGHT_SELECT
+ || act == LFUN_CHAR_RIGHT);
if (lyxrc.visual_cursor || !reverseDirectionNeeded(cur))
forward = right;
else
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
}
// stop/start the selection
- bool select = cmd.action == LFUN_DOWN_SELECT ||
- cmd.action == LFUN_UP_SELECT;
+ bool select = act == LFUN_DOWN_SELECT ||
+ act == LFUN_UP_SELECT;
cur.selHandle(select);
// go up/down
- bool up = cmd.action == LFUN_UP || cmd.action == LFUN_UP_SELECT;
+ bool up = act == LFUN_UP || act == LFUN_UP_SELECT;
bool successful = cur.upDownInMath(up);
if (successful)
break;
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:
- cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT ||
- cmd.action == LFUN_WORD_LEFT_SELECT ||
- cmd.action == LFUN_LINE_BEGIN_SELECT);
+ cur.selHandle(act == LFUN_WORD_BACKWARD_SELECT ||
+ act == LFUN_WORD_LEFT_SELECT ||
+ act == LFUN_LINE_BEGIN_SELECT);
cur.macroModeClose();
if (cur.pos() != 0) {
cur.pos() = 0;
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:
- cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT ||
- cmd.action == LFUN_WORD_RIGHT_SELECT ||
- cmd.action == LFUN_LINE_END_SELECT);
+ cur.selHandle(act == LFUN_WORD_FORWARD_SELECT ||
+ act == LFUN_WORD_RIGHT_SELECT ||
+ act == LFUN_LINE_END_SELECT);
cur.macroModeClose();
cur.clearTargetX();
if (cur.pos() != cur.lastpos()) {
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/updateLabels calls
- cur.buffer()->updateLabels();
+ 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().
case LFUN_MATH_MACRO_FOLD:
case LFUN_MATH_MACRO_UNFOLD: {
Cursor it = cur;
- bool fold = cmd.action == LFUN_MATH_MACRO_FOLD;
+ bool fold = act == LFUN_MATH_MACRO_FOLD;
bool found = findMacroToFoldUnfold(it, fold);
if (found) {
MathMacro * macro = it.nextInset()->asInsetMath()->asMacro();
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));
- } else if (name == "mathspace") {
- InsetMathSpace tmp;
data = tmp.createDialogStr();
+ cur.bv().showDialog(to_utf8(name), data);
+ } else if (name == "mathspace") {
+ cur.bv().showDialog(to_utf8(name));
}
- cur.bv().showDialog(to_utf8(name), data);
break;
}
if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
cur.recordUndoSelection();
cur.insert(ar);
- // FIXME audit setBuffer/updateLabels calls
- cur.buffer()->updateLabels();
+ cur.forceBufferUpdate();
} else
cur.undispatched();
break;
//string tc = "mathnormal";
bool ret = true;
string const arg = to_utf8(cmd.argument());
- switch (cmd.action) {
+ switch (cmd.action()) {
case LFUN_INSET_MODIFY:
flag.setEnabled(false);
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_MATH_MACRO_FOLD:
case LFUN_MATH_MACRO_UNFOLD: {
Cursor it = cur;
- bool found = findMacroToFoldUnfold(it, cmd.action == LFUN_MATH_MACRO_FOLD);
+ bool found = findMacroToFoldUnfold(it, cmd.action() == LFUN_MATH_MACRO_FOLD);
flag.setEnabled(found);
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;
}
dim.asc += 3;
// and position
- Point xy
- = cur.bv().coordCache().insets().xy(inset);
+ Point xy = cur.bv().coordCache().insets().xy(inset);
x = xy.x_;
y = xy.y_;
}
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"));