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)
44 for (size_t i = 0, n = cursor.data_.size(); i != n; ++i)
45 os << " " << cursor.data_[i];
50 DispatchResult LCursor::dispatch(FuncRequest const & cmd)
52 for (int i = data_.size() - 1; i >= 0; --i) {
53 CursorItem const & citem = data_[i];
54 lyxerr << "trying to dispatch to inset" << citem.inset_ << endl;
55 DispatchResult res = citem.inset_->dispatch(cmd);
56 if (handleResult(res))
57 return DispatchResult(true, true);
59 lyxerr << "trying to dispatch to main text " << bv_->text << endl;
60 DispatchResult res = bv_->text->dispatch(cmd);
61 lyxerr << " result: " << res.val() << endl;
66 bool LCursor::handleResult(DispatchResult const & res)
68 lyxerr << "LCursor::handleResult: " << res.val() << endl;
74 case FINISHED_RIGHT: {
76 //InsetText * inset = static_cast<InsetText *>(innerInset());
78 // inset->moveRightIntern(bv_, false, false);
80 // bv_->text->cursorRight(bv_);
81 innerText()->cursorRight(bv_);
87 //InsetText * inset = static_cast<InsetText *>(inset());
89 // result = inset->moveUp(bv);
95 //InsetText * inset = static_cast<InsetText *>(inset());
97 // 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 data_.push_back(CursorItem(inset, text));
123 BOOST_ASSERT(!data_.empty());
128 InsetOld * LCursor::innerInset() const
130 return data_.empty() ? 0 : data_.back().inset_;
134 LyXText * LCursor::innerText() const
136 return data_.empty() ? bv_->text : data_.back().text_;