}
-
-auto_ptr<InsetBase> MathScriptInset::clone() const
+auto_ptr<InsetBase> MathScriptInset::doClone() const
{
return auto_ptr<InsetBase>(new MathScriptInset(*this));
}
MathArray const & MathScriptInset::down() const
{
-#if 1
if (nargs() == 3)
return cell(2);
BOOST_ASSERT(nargs() > 1);
return cell(1);
-#else
- return nargs() == 3 ? cell(2) : cell(1);
-#endif
}
MathArray & MathScriptInset::down()
{
-#if 1
if (nargs() == 3)
return cell(2);
BOOST_ASSERT(nargs() > 1);
return cell(1);
-#else
- return nargs() == 3 ? cell(2) : cell(1);
-#endif
}
void MathScriptInset::removeScript(bool up)
{
+ lyxerr << "MathScriptInset::removeScript: 1 up: " << up << endl;
if (nargs() == 2) {
+ lyxerr << "MathScriptInset::removeScript: a up: " << up << endl;
if (up == cell_1_is_up_)
cells_.pop_back();
+ lyxerr << "MathScriptInset::removeScript: b up: " << up << endl;
} else if (nargs() == 3) {
if (up == true) {
swap(cells_[1], cells_[2]);
} else {
cell_1_is_up_ = true;
}
+ cells_.pop_back();
}
+ lyxerr << "MathScriptInset::removeScript: 2 up: " << up << endl;
}
bool MathScriptInset::hasUp() const
{
- //lyxerr << "hasUp: " << bool(idxOfScript(true)) << endl;
//lyxerr << "1up: " << bool(cell_1_is_up_) << endl;
+ //lyxerr << "hasUp: " << bool(idxOfScript(true)) << endl;
return idxOfScript(true);
}
bool MathScriptInset::hasDown() const
{
- //lyxerr << "hasDown: " << bool(idxOfScript(false)) << endl;
//lyxerr << "1up: " << bool(cell_1_is_up_) << endl;
+ //lyxerr << "hasDown: " << bool(idxOfScript(false)) << endl;
return idxOfScript(false);
}
if (nargs() == 1)
return 0;
if (nargs() == 2)
- return cell_1_is_up_ == up ? 1 : 0;
+ return (cell_1_is_up_ == up) ? 1 : 0;
if (nargs() == 3)
return up ? 1 : 2;
BOOST_ASSERT(false);
}
// Are we 'up'?
- if (cur.idx() == idxOfScript(true)) {
+ if (has(up) && cur.idx() == idxOfScript(true)) {
// can't go further up
if (up)
return false;
}
// Are we 'down'?
- if (cur.idx() == idxOfScript(false)) {
+ if (has(up) && cur.idx() == idxOfScript(false)) {
// can't go further down
if (!up)
return false;
}
-void MathScriptInset::notifyCursorLeaves(idx_type idx)
+void MathScriptInset::notifyCursorLeaves(LCursor & cur)
{
- MathNestInset::notifyCursorLeaves(idx);
+ MathNestInset::notifyCursorLeaves(cur);
+
+ lyxerr << "MathScriptInset::notifyCursorLeaves: 1 " << cur << endl;
// remove empty scripts if possible
- if (idx == 2 && nargs() > 2 && cell(2).empty()) {
- removeScript(false); // must be a subscript...
- } else if (idx == 1 && nargs() > 1 && cell(1).empty()) {
- if (nargs() == 2) {
- cell_1_is_up_ = false;
- cell(1) = cell(2);
- cells_.pop_back();
- } else if (nargs() == 1) {
- cells_.pop_back();
- }
+if (1) {
+ if (nargs() > 2 && cur.idx() == 2 && cell(2).empty()) {
+ // must be a subscript...
+ removeScript(false);
+ } else if (nargs() > 1 && cur.idx() == 1 && cell(1).empty()) {
+ // could be either subscript or super script
+ removeScript(cell_1_is_up_);
}
}
+ lyxerr << "MathScriptInset::notifyCursorLeaves: 2 " << cur << endl;
+}
+
-void MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
+void MathScriptInset::doDispatch(LCursor & cur, FuncRequest & cmd)
{
//lyxerr << "MathScriptInset: request: " << cmd << std::endl;
return;
}
- MathNestInset::priv_dispatch(cur, cmd);
+ MathNestInset::doDispatch(cur, cmd);
}