+
+2003-02-13 Bo Peng <bpeng@rice.edu>
+
+ * math_cursor.h:
+ * math_cursor.C (backspace, erase): return false for empty mathboxes.
+
+ * formulabase.C: When LFUN_DELETE, LFUN_BACKSPACE return false, delete
+ the empty mathbox. Fix Bug 686.
+
2003-01-12 Michael Schmitt <michael.schmitt@teststep.org>
* formula.C (draw, width): Fix spacing around previewed formula.
// << " y: '" << cmd.y
// << "' button: " << cmd.button() << endl;
+ // delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
+ bool remove_inset;
+
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
return lfunMousePress(cmd);
case LFUN_DELETE_WORD_BACKWARD:
case LFUN_BACKSPACE:
bv->lockedInsetStoreUndo(Undo::EDIT);
- mathcursor->backspace();
+ if (mathcursor->backspace()) {
+ result = DISPATCHED;
+ } else {
+ result = FINISHED;
+ remove_inset = true;
+ }
updateLocal(bv, true);
break;
case LFUN_DELETE_WORD_FORWARD:
case LFUN_DELETE:
bv->lockedInsetStoreUndo(Undo::EDIT);
- mathcursor->erase();
- bv->updateInset(this, true);
+ if (mathcursor->erase()) {
+ result = DISPATCHED;
+ } else {
+ result = FINISHED;
+ remove_inset = true;
+ }
+ updateLocal(bv, true);
break;
// case LFUN_GETXY:
} else {
releaseMathCursor(bv);
bv->unlockInset(this);
+ if (remove_inset)
+ bv->owner()->dispatch(FuncRequest(LFUN_DELETE));
}
return result; // original version
}
-void MathCursor::backspace()
+bool MathCursor::backspace()
{
autocorrect_ = false;
if (selection_) {
selDel();
- return;
+ return true;
}
if (pos() == 0) {
- pullArg();
- return;
+ if (par()->ncols() == 1 && par()->nrows() == 1 && depth() == 1 && size() == 0)
+ return false;
+ else{
+ pullArg();
+ return true;
+ }
}
if (inMacroMode()) {
MathUnknownInset * p = activeMacro();
if (p->name().size() > 1) {
p->setName(p->name().substr(0, p->name().size() - 1));
- return;
+ return true;
}
}
--pos();
plainErase();
+ return true;
}
-void MathCursor::erase()
+bool MathCursor::erase()
{
autocorrect_ = false;
if (inMacroMode())
- return;
+ return true;
if (selection_) {
selDel();
- return;
+ return true;
}
// delete empty cells if possible
if (array().empty())
if (par()->idxDelete(idx()))
- return;
+ return true;
// old behaviour when in last position of cell
if (pos() == size()) {
- par()->idxGlue(idx());
- return;
+ if (par()->ncols() == 1 && par()->nrows() == 1 && depth() == 1 && size() == 0)
+ return false;
+ else{
+ par()->idxGlue(idx());
+ return true;
+ }
}
plainErase();
+ return true;
}
void insert(MathArray const &);
///
void paste(string const & data);
- ///
- void erase();
- ///
- void backspace();
+ /// return false for empty math insets
+ bool erase();
+ /// return false for empty math insets
+ bool backspace();
/// called for LFUN_HOME etc
bool home(bool sel = false);
/// called for LFUN_END etc