3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
14 #include "BufferView.h"
17 #include "dispatchresult.h"
18 #include "iterators.h"
20 #include "paragraph.h"
22 #include "insets/updatableinset.h"
23 #include "insets/insettext.h"
25 #include <boost/assert.hpp>
31 std::ostream & operator<<(std::ostream & os, CursorItem const & item)
33 os << " inset: " << item.inset_
34 << " idx: " << item.idx_
35 << " text: " << item.text_
36 << " par: " << item.par_
37 << " pos: " << item.pos_;
42 std::ostream & operator<<(std::ostream & os, LCursor const & cursor)
45 for (size_t i = 0, n = cursor.data_.size(); i != n; ++i)
46 os << " " << cursor.data_[i] << "\n";
51 DispatchResult LCursor::dispatch(FuncRequest const & cmd)
53 for (int i = data_.size() - 1; i >= 0; --i) {
54 CursorItem const & citem = data_[i];
55 lyxerr << "trying to dispatch to inset" << citem.inset_ << endl;
56 DispatchResult res = citem.inset_->dispatch(cmd);
57 if (handleResult(res))
58 return DispatchResult(true, true);
60 lyxerr << "trying to dispatch to main text " << bv_->text << endl;
61 DispatchResult res = bv_->text->dispatch(cmd);
62 lyxerr << " result: " << res.val() << endl;
67 bool LCursor::handleResult(DispatchResult const & res)
69 lyxerr << "LCursor::handleResult: " << res.val() << endl;
75 case FINISHED_RIGHT: {
77 //InsetText * inset = static_cast<InsetText *>(innerInset());
79 // inset->moveRightIntern(bv_, false, false);
81 // bv_->text->cursorRight(bv_);
82 innerText()->cursorRight(bv_);
88 //InsetText * inset = static_cast<InsetText *>(inset());
90 // result = inset->moveUp(bv);
96 //InsetText * inset = static_cast<InsetText *>(inset());
98 // result = inset->moveDown(bv);
103 lyxerr << "# unhandled result: " << res.val() << endl;
110 LCursor::LCursor(BufferView * bv)
115 void LCursor::push(InsetOld * inset, LyXText * text)
117 lyxerr << "LCursor::push() inset: " << inset << " text: " << text
119 data_.push_back(CursorItem(inset, text));
125 lyxerr << "LCursor::pop() " << endl;
126 //BOOST_ASSERT(!data_.empty());
128 lyxerr << "### TRYING TO POP FROM EMPTY CURSOR" << endl;
134 InsetOld * LCursor::innerInset() const
136 return data_.empty() ? 0 : data_.back().inset_;
140 LyXText * LCursor::innerText() const
142 return data_.empty() ? bv_->text : data_.back().text_;