open insets when selection is set there

to avoid crashs with cold coord cache


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10188 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2005-07-14 17:30:24 +00:00
parent 68043dbb60
commit 275f6172ac
7 changed files with 22 additions and 18 deletions

View File

@ -1,4 +1,9 @@
2005-05-07 André Pönitz <poenitz@gmx.net>
* cursor.C (setSelection): open insets when selection is set there
to avoid crashs with cold coord cache
2005-05-07 André Pönitz <poenitz@gmx.net>
* trans_mgr.C (insert): move cursor to the right after inserting

View File

@ -393,7 +393,7 @@ DocIterator LCursor::selectionEnd() const
void LCursor::setSelection()
{
selection() = true;
// a selection with no contents is not a selection
// A selection with no contents is not a selection
#ifdef WITH_WARNINGS
#warning doesnt look ok
#endif
@ -408,6 +408,9 @@ void LCursor::setSelection(DocIterator const & where, size_t n)
selection() = true;
anchor_ = where;
pos() += n;
// Open all collapsed insets
for (int i = depth() - 1; i >= 0; --i)
operator[](i).inset().setStatus(*this, InsetBase::Open);
}

View File

@ -338,10 +338,6 @@ public:
/// used to toggle insets
/// is the inset open?
virtual bool isOpen() const { return false; }
/// open the inset
virtual void open() {}
/// close the inset
virtual void close() {}
/// should this inset be handled like a normal charater
virtual bool isChar() const { return false; }
/// is this equivalent to a letter?
@ -399,6 +395,14 @@ public:
virtual int ascent() const { return 10; }
/// pretty arbitrary
virtual int descent() const { return 10; }
///
enum CollapseStatus {
Collapsed,
Inlined,
Open
};
///
virtual void setStatus(LCursor &, CollapseStatus) {}
protected:
InsetBase();
InsetBase(InsetBase const &);

View File

@ -257,7 +257,6 @@ void InsetCollapsable::edit(LCursor & cur, bool left)
//lyxerr << "InsetCollapsable: edit left/right" << endl;
cur.push(*this);
InsetText::edit(cur, left);
open();
}

View File

@ -35,12 +35,6 @@ public:
///
static int const TEXT_TO_BOTTOM_OFFSET = 2;
///
enum CollapseStatus {
Collapsed,
Inlined,
Open
};
///
InsetCollapsable(BufferParams const &, CollapseStatus status = Open);
///
void read(Buffer const &, LyXLex &);
@ -86,10 +80,11 @@ public:
bool allowSpellCheck() const { return true; }
///
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
protected:
///
void setStatus(LCursor & cur, CollapseStatus st);
protected:
///
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
///

View File

@ -1510,10 +1510,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
default: {
view()->cursor().dispatch(cmd);
update |= view()->cursor().result().update();
if (!view()->cursor().result().dispatched()) {
if (!view()->cursor().result().dispatched())
update |= view()->dispatch(cmd);
}
break;
}
}

View File

@ -181,7 +181,7 @@ void delEmptyLastRow(MathGridInset & grid)
if (!grid.cell(grid.index(row, col)).empty())
return;
}
grid.delRow(row + 1);
grid.delRow(row);
}