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 & citem = data_[i];
55 lyxerr << "trying to dispatch to inset" << citem.inset_ << endl;
56 DispatchResult res = citem.inset_->dispatch(cmd);
57 lyxerr << " result: " << res.val() << endl;
62 return DispatchResult(true, true);
64 case FINISHED_RIGHT: {
66 //InsetText * inset = static_cast<InsetText *>(innerInset());
68 // inset->moveRightIntern(bv_, false, false);
70 // bv_->text->cursorRight(bv_);
71 innerText()->cursorRight(bv_);
72 return DispatchResult(true);
77 //InsetText * inset = static_cast<InsetText *>(inset());
79 // result = inset->moveUp(bv);
80 return DispatchResult(true);
85 //InsetText * inset = static_cast<InsetText *>(inset());
87 // result = inset->moveDown(bv);
88 return DispatchResult(true);
95 lyxerr << "# unhandled result: " << res.val() << endl;
98 lyxerr << "trying to dispatch to main text " << bv_->text << endl;
99 DispatchResult res = bv_->text->dispatch(cmd);
100 lyxerr << " result: " << res.val() << endl;
105 LCursor::LCursor(BufferView * bv)
110 void LCursor::push(InsetOld * inset, LyXText * text)
112 data_.push_back(CursorItem(inset, text));
118 BOOST_ASSERT(!data_.empty());
123 InsetOld * LCursor::innerInset() const
125 return data_.empty() ? 0 : data_.back().inset_;
129 LyXText * LCursor::innerText() const
131 return data_.empty() ? bv_->text : data_.back().text_;