Try to fix the move to references label bug.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8920 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2004-08-14 00:27:15 +00:00
parent 0786aa3247
commit a13a346b0e
3 changed files with 24 additions and 22 deletions

View File

@ -111,6 +111,20 @@ boost::signals::connection selectioncon;
boost::signals::connection lostcon;
/// Get next inset of this class from current cursor position
template <class T>
T * getInsetByCode(LCursor & cur, InsetBase::Code code)
{
T * inset = 0;
DocIterator it = cur;
if (it.nextInset() &&
it.nextInset()->lyxCode() == code) {
inset = static_cast<T*>(it.nextInset());
}
return inset;
}
} // anon namespace
@ -730,24 +744,6 @@ void BufferView::Pimpl::stuffClipboard(string const & stuff) const
}
InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code)
{
#ifdef WITH_WARNINGS
#warning Does not work for mathed. (Still true?)
#endif
// Ok, this is a little bit too brute force but it
// should work for now. Better infrastructure is coming. (Lgb)
LCursor & cur = bv_->cursor();
DocIterator it = cur;
for (it.forwardInset(); it; it.forwardInset()) {
BOOST_ASSERT(it.nextInset());
if (it.nextInset()->lyxCode() == code)
return it.nextInset();
}
return 0;
}
void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm)
{
string filename = filenm;
@ -1038,7 +1034,8 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
string label = cmd.argument;
if (label.empty()) {
InsetRef * inset =
static_cast<InsetRef*>(getInsetByCode(InsetBase::REF_CODE));
getInsetByCode<InsetRef>(bv_->cursor(),
InsetBase::REF_CODE);
if (inset) {
label = inset->getContents();
savePosition(0);

View File

@ -173,8 +173,6 @@ private:
};
///
std::vector<Position> saved_positions;
/// Get next inset of this class from current cursor position
InsetBase * getInsetByCode(InsetBase::Code code);
///
void MenuInsertLyXFile(std::string const & filen);
/// our workarea

View File

@ -1,3 +1,10 @@
2004-08-14 Lars Gullik Bjonnes <larsbj@lyx.org>
bug 1096
* BufferView_pimpl.C (getInsetByCode): move function out of class
and change in to a template in anon namespace. Also fix to do what
suits us better.
2004-08-13 Lars Gullik Bjonnes <larsbj@lyx.org>
bug 1305
@ -26,7 +33,7 @@
optional argument, enclose the argument with curly brackets (in
case it contains a closing square bracket)
* text2.C (editXY):
* text2.C (editXY):
* text2.C (editXY):
* text3.C (checkInsetHit): constify