2003-09-17 16:44:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file cursor.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "cursor.h"
|
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-09-17 16:44:51 +00:00
|
|
|
|
#include "iterators.h"
|
|
|
|
|
#include "lyxtext.h"
|
|
|
|
|
#include "paragraph.h"
|
|
|
|
|
|
|
|
|
|
#include "insets/updatableinset.h"
|
|
|
|
|
|
|
|
|
|
using std::vector;
|
2003-10-29 12:18:08 +00:00
|
|
|
|
using std::endl;
|
2003-09-17 16:44:51 +00:00
|
|
|
|
|
|
|
|
|
|
2003-10-29 12:18:08 +00:00
|
|
|
|
DispatchResult Cursor::dispatch(FuncRequest const & cmd)
|
2003-09-17 16:44:51 +00:00
|
|
|
|
{
|
|
|
|
|
for (int i = data_.size() - 1; i >= 0; --i) {
|
2003-10-29 12:18:08 +00:00
|
|
|
|
lyxerr << "trying to dispatch to inset" << data_[i].inset_ << endl;
|
|
|
|
|
DispatchResult res = data_[i].inset_->dispatch(cmd);
|
2003-10-29 13:24:57 +00:00
|
|
|
|
lyxerr << " result: " << res.val() << endl;
|
2003-10-29 12:18:08 +00:00
|
|
|
|
|
|
|
|
|
if (res == DISPATCHED) {
|
2003-10-29 12:58:26 +00:00
|
|
|
|
//update();
|
2003-10-29 12:18:08 +00:00
|
|
|
|
return DISPATCHED;
|
|
|
|
|
}
|
2003-10-29 13:24:57 +00:00
|
|
|
|
|
2003-10-29 12:18:08 +00:00
|
|
|
|
if (res == DISPATCHED_NOUPDATE)
|
|
|
|
|
return DISPATCHED;
|
|
|
|
|
|
2003-10-29 13:24:57 +00:00
|
|
|
|
lyxerr << "# unhandled result: " << res.val() << endl;
|
2003-09-17 16:44:51 +00:00
|
|
|
|
}
|
|
|
|
|
return UNDISPATCHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void buildCursor(Cursor & cursor, BufferView & bv)
|
|
|
|
|
{
|
|
|
|
|
UpdatableInset * inset = bv.theLockingInset();
|
2003-10-29 12:18:08 +00:00
|
|
|
|
lyxerr << "\nbuildCursor: " << inset << endl;
|
2003-09-17 16:44:51 +00:00
|
|
|
|
if (!inset)
|
|
|
|
|
return;
|
2003-09-21 23:00:47 +00:00
|
|
|
|
|
2003-09-17 16:44:51 +00:00
|
|
|
|
inset = inset->getLockingInset();
|
|
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
|
ParIterator pit = bv.buffer()->par_iterator_begin();
|
|
|
|
|
ParIterator end = bv.buffer()->par_iterator_end();
|
|
|
|
|
for ( ; pit != end && !ok; ++pit) {
|
|
|
|
|
InsetList::iterator it = pit->insetlist.begin();
|
|
|
|
|
InsetList::iterator iend = pit->insetlist.end();
|
2003-09-21 23:00:47 +00:00
|
|
|
|
for ( ; it != iend && !ok; ++it)
|
2003-09-17 16:44:51 +00:00
|
|
|
|
if (it->inset == inset || it->inset == inset->owner())
|
|
|
|
|
ok = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ok) {
|
2003-10-29 12:18:08 +00:00
|
|
|
|
lyxerr << " tli not found! inset: " << inset << endl;
|
2003-09-17 16:44:51 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-29 12:18:08 +00:00
|
|
|
|
pit.asCursor(cursor);
|
|
|
|
|
for (size_t i = 0, n = cursor.data_.size(); i != n; ++i) {
|
|
|
|
|
lyxerr << " inset: " << cursor.data_[i].inset_
|
|
|
|
|
<< " idx: " << cursor.data_[i].idx_
|
|
|
|
|
<< " text: " << cursor.data_[i].text_
|
|
|
|
|
<< " par: " << cursor.data_[i].par_
|
2003-09-17 16:44:51 +00:00
|
|
|
|
<< " pos: " << cursor.data_[i].pos_
|
2003-10-29 12:18:08 +00:00
|
|
|
|
<< endl;
|
2003-09-17 16:44:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|