3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
7 * \author Alfredo Braunstein
10 * Full author contact details are available in file CREDITS.
15 #include "BufferView.h"
16 #include "bufferview_funcs.h"
19 #include "CoordCache.h"
20 #include "CutAndPaste.h"
22 #include "DispatchResult.h"
24 #include "FuncRequest.h"
28 #include "LyXFunc.h" // only for setMessage()
32 #include "Paragraph.h"
33 #include "paragraph_funcs.h"
34 #include "ParIterator.h"
36 #include "insets/InsetTabular.h"
37 #include "insets/InsetText.h"
39 #include "mathed/MathData.h"
40 #include "mathed/InsetMath.h"
41 #include "mathed/InsetMathScript.h"
42 #include "mathed/MacroTable.h"
44 #include "support/limited_stack.h"
46 #include <boost/assert.hpp>
47 #include <boost/bind.hpp>
48 #include <boost/current_function.hpp>
65 positionable(DocIterator const & cursor, DocIterator const & anchor)
67 // avoid deeper nested insets when selecting
68 if (cursor.depth() > anchor.depth())
71 // anchor might be deeper, should have same path then
72 for (size_t i = 0; i < cursor.depth(); ++i)
73 if (&cursor[i].inset() != &anchor[i].inset())
76 // position should be ok.
81 // Find position closest to (x, y) in cell given by iter.
82 // Used only in mathed
83 DocIterator bruteFind2(Cursor const & c, int x, int y)
85 double best_dist = std::numeric_limits<double>::max();
92 et.top().pos() = et.top().asInsetMath()->cell(et.top().idx()).size();
93 for (size_t i = 0;; ++i) {
96 Inset const * inset = &it.inset();
97 std::map<Inset const *, Point> const & data =
98 c.bv().coordCache().getInsets().getData();
99 std::map<Inset const *, Point>::const_iterator I = data.find(inset);
101 // FIXME: in the case where the inset is not in the cache, this
102 // means that no part of it is visible on screen. In this case
103 // we don't do elaborate search and we just return the forwarded
104 // DocIterator at its beginning.
105 if (I == data.end()) {
111 inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
112 // Convert to absolute
115 double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
116 // '<=' in order to take the last possible position
117 // this is important for clicking behind \sum in e.g. '\sum_i a'
118 LYXERR(Debug::DEBUG) << "i: " << i << " d: " << d
119 << " best: " << best_dist << endl;
120 if (d <= best_dist) {
132 /// moves position closest to (x, y) in given box
133 bool bruteFind(Cursor & cursor,
134 int x, int y, int xlow, int xhigh, int ylow, int yhigh)
136 BOOST_ASSERT(!cursor.empty());
137 Inset & inset = cursor[0].inset();
138 BufferView & bv = cursor.bv();
140 CoordCache::InnerParPosCache const & cache =
141 bv.coordCache().getParPos().find(cursor.bottom().text())->second;
142 // Get an iterator on the first paragraph in the cache
143 DocIterator it(inset);
144 it.push_back(CursorSlice(inset));
145 it.pit() = cache.begin()->first;
146 // Get an iterator after the last paragraph in the cache
147 DocIterator et(inset);
148 et.push_back(CursorSlice(inset));
149 et.pit() = boost::prior(cache.end())->first;
150 if (et.pit() >= et.lastpit())
151 et = doc_iterator_end(inset);
155 double best_dist = std::numeric_limits<double>::max();;
156 DocIterator best_cursor = et;
158 for ( ; it != et; it.forwardPos(true)) {
159 // avoid invalid nesting when selecting
160 if (!cursor.selection() || positionable(it, cursor.anchor_)) {
161 Point p = bv_funcs::getPos(bv, it, false);
164 if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
165 double const dx = xo - x;
166 double const dy = yo - y;
167 double const d = dx * dx + dy * dy;
168 // '<=' in order to take the last possible position
169 // this is important for clicking behind \sum in e.g. '\sum_i a'
170 if (d <= best_dist) {
171 // lyxerr << "*" << endl;
179 if (best_cursor != et) {
180 cursor.setCursor(best_cursor);
188 /// moves position closest to (x, y) in given box
189 bool bruteFind3(Cursor & cur, int x, int y, bool up)
191 BufferView & bv = cur.bv();
192 int ylow = up ? 0 : y + 1;
193 int yhigh = up ? y - 1 : bv.workHeight();
195 int xhigh = bv.workWidth();
197 // FIXME: bit more work needed to get 'from' and 'to' right.
198 pit_type from = cur.bottom().pit();
199 //pit_type to = cur.bottom().pit();
200 //lyxerr << "Pit start: " << from << endl;
202 //lyxerr << "bruteFind3: x: " << x << " y: " << y
203 // << " xlow: " << xlow << " xhigh: " << xhigh
204 // << " ylow: " << ylow << " yhigh: " << yhigh
206 Inset & inset = bv.buffer()->inset();
207 DocIterator it = doc_iterator_begin(inset);
209 DocIterator et = doc_iterator_end(inset);
211 double best_dist = std::numeric_limits<double>::max();
212 DocIterator best_cursor = et;
214 for ( ; it != et; it.forwardPos()) {
215 // avoid invalid nesting when selecting
216 if (bv_funcs::status(&bv, it) == bv_funcs::CUR_INSIDE
217 && (!cur.selection() || positionable(it, cur.anchor_))) {
218 Point p = bv_funcs::getPos(bv, it, false);
221 if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
222 double const dx = xo - x;
223 double const dy = yo - y;
224 double const d = dx * dx + dy * dy;
225 //lyxerr << "itx: " << xo << " ity: " << yo << " d: " << d
226 // << " dx: " << dx << " dy: " << dy
227 // << " idx: " << it.idx() << " pos: " << it.pos()
230 // '<=' in order to take the last possible position
231 // this is important for clicking behind \sum in e.g. '\sum_i a'
232 if (d <= best_dist) {
233 //lyxerr << "*" << endl;
241 //lyxerr << "best_dist: " << best_dist << " cur:\n" << best_cursor << endl;
242 if (best_cursor == et)
244 cur.setCursor(best_cursor);
251 // be careful: this is called from the bv's constructor, too, so
252 // bv functions are not yet available!
253 Cursor::Cursor(BufferView & bv)
254 : DocIterator(), bv_(&bv), anchor_(), x_target_(-1),
255 selection_(false), mark_(false), logicalpos_(false)
259 void Cursor::reset(Inset & inset)
262 push_back(CursorSlice(inset));
263 anchor_ = DocIterator(inset);
270 // this (intentionally) does neither touch anchor nor selection status
271 void Cursor::setCursor(DocIterator const & cur)
273 DocIterator::operator=(cur);
277 void Cursor::dispatch(FuncRequest const & cmd0)
279 LYXERR(Debug::DEBUG) << BOOST_CURRENT_FUNCTION
280 << " cmd: " << cmd0 << '\n'
286 FuncRequest cmd = cmd0;
289 for (; depth(); pop()) {
290 LYXERR(Debug::DEBUG) << "Cursor::dispatch: cmd: "
291 << cmd0 << endl << *this << endl;
292 BOOST_ASSERT(pos() <= lastpos());
293 BOOST_ASSERT(idx() <= lastidx());
294 BOOST_ASSERT(pit() <= lastpit());
296 // The common case is 'LFUN handled, need update', so make the
297 // LFUN handler's life easier by assuming this as default value.
298 // The handler can reset the update and val flags if necessary.
299 disp_.update(Update::FitCursor | Update::Force);
300 disp_.dispatched(true);
301 inset().dispatch(*this, cmd);
302 if (disp_.dispatched())
305 // it completely to get a 'bomb early' behaviour in case this
306 // object will be used again.
307 if (!disp_.dispatched()) {
308 LYXERR(Debug::DEBUG) << "RESTORING OLD CURSOR!" << endl;
310 disp_.update(Update::None);
311 disp_.dispatched(false);
316 DispatchResult Cursor::result() const
322 BufferView & Cursor::bv() const
329 Buffer & Cursor::buffer() const
332 BOOST_ASSERT(bv_->buffer());
333 return *bv_->buffer();
339 BOOST_ASSERT(depth() >= 1);
344 void Cursor::push(Inset & p)
346 push_back(CursorSlice(p));
350 void Cursor::pushLeft(Inset & p)
352 BOOST_ASSERT(!empty());
353 //lyxerr << "Entering inset " << t << " left" << endl;
359 bool Cursor::popLeft()
361 BOOST_ASSERT(!empty());
362 //lyxerr << "Leaving inset to the left" << endl;
363 inset().notifyCursorLeaves(*this);
371 bool Cursor::popRight()
373 BOOST_ASSERT(!empty());
374 //lyxerr << "Leaving inset to the right" << endl;
375 const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
376 inset().notifyCursorLeaves(*this);
380 pos() += lastpos() - lp + 1;
385 int Cursor::currentMode()
387 BOOST_ASSERT(!empty());
388 for (int i = depth() - 1; i >= 0; --i) {
389 int res = operator[](i).inset().currentMode();
390 if (res != Inset::UNDECIDED_MODE)
393 return Inset::TEXT_MODE;
397 void Cursor::getPos(int & x, int & y) const
399 Point p = bv_funcs::getPos(bv(), *this, boundary());
405 Row const & Cursor::textRow() const
407 ParagraphMetrics const & pm = bv().parMetrics(text(), pit());
408 BOOST_ASSERT(!pm.rows().empty());
409 return pm.getRow(pos(), boundary());
413 void Cursor::resetAnchor()
420 bool Cursor::posLeft()
429 bool Cursor::posRight()
431 if (pos() == lastpos())
438 CursorSlice Cursor::anchor() const
440 BOOST_ASSERT(anchor_.depth() >= depth());
441 CursorSlice normal = anchor_[depth() - 1];
442 if (depth() < anchor_.depth() && top() <= normal) {
443 // anchor is behind cursor -> move anchor behind the inset
450 CursorSlice Cursor::selBegin() const
454 return anchor() < top() ? anchor() : top();
458 CursorSlice Cursor::selEnd() const
462 return anchor() > top() ? anchor() : top();
466 DocIterator Cursor::selectionBegin() const
470 DocIterator di = (anchor() < top() ? anchor_ : *this);
476 DocIterator Cursor::selectionEnd() const
480 DocIterator di = (anchor() > top() ? anchor_ : *this);
481 if (di.depth() > depth()) {
489 void Cursor::setSelection()
492 // A selection with no contents is not a selection
494 #warning doesnt look ok
496 if (pit() == anchor().pit() && pos() == anchor().pos())
501 void Cursor::setSelection(DocIterator const & where, int n)
510 void Cursor::clearSelection()
518 int & Cursor::x_target()
524 int Cursor::x_target() const
530 void Cursor::clearTargetX()
537 void Cursor::info(odocstream & os) const
539 for (int i = 1, n = depth(); i < n; ++i) {
540 operator[](i).inset().infoize(os);
544 Inset const * inset = prevInset();
545 // prevInset() can return 0 in certain case.
547 prevInset()->infoize2(os);
549 // overwite old message
554 bool Cursor::selHandle(bool sel)
556 //lyxerr << "Cursor::selHandle" << endl;
557 if (sel == selection())
562 cap::saveSelection(*this);
567 std::ostream & operator<<(std::ostream & os, Cursor const & cur)
569 os << "\n cursor: | anchor:\n";
570 for (size_t i = 0, n = cur.depth(); i != n; ++i) {
571 os << " " << cur[i] << " | ";
572 if (i < cur.anchor_.depth())
573 os << cur.anchor_[i];
575 os << "-------------------------------";
578 for (size_t i = cur.depth(), n = cur.anchor_.depth(); i < n; ++i) {
579 os << "------------------------------- | " << cur.anchor_[i] << "\n";
581 os << " selection: " << cur.selection_
582 << " x_target: " << cur.x_target_ << endl;
589 ///////////////////////////////////////////////////////////////////
591 // The part below is the non-integrated rest of the original math
592 // cursor. This should be either generalized for texted or moved
593 // back to mathed (in most cases to InsetMathNest).
595 ///////////////////////////////////////////////////////////////////
597 #include "mathed/InsetMathChar.h"
598 #include "mathed/InsetMathGrid.h"
599 #include "mathed/InsetMathScript.h"
600 #include "mathed/InsetMathUnknown.h"
601 #include "mathed/MathFactory.h"
602 #include "mathed/MathStream.h"
603 #include "mathed/MathSupport.h"
608 //#define FILEDEBUG 1
611 bool Cursor::isInside(Inset const * p)
613 for (size_t i = 0; i != depth(); ++i)
614 if (&operator[](i).inset() == p)
620 void Cursor::leaveInset(Inset const & inset)
622 for (size_t i = 0; i != depth(); ++i) {
623 if (&operator[](i).inset() == &inset) {
631 bool Cursor::openable(MathAtom const & t) const
642 // we can't move into anything new during selection
643 if (depth() >= anchor_.depth())
645 if (!ptr_cmp(t.nucleus(), &anchor_[depth()].inset()))
652 void Cursor::setScreenPos(int x, int y)
655 bruteFind(*this, x, y, 0, bv().workWidth(), 0, bv().workHeight());
660 void Cursor::plainErase()
666 void Cursor::markInsert()
668 insert(char_type(0));
672 void Cursor::markErase()
678 void Cursor::plainInsert(MathAtom const & t)
680 cell().insert(pos(), t);
685 void Cursor::insert(docstring const & str)
687 for_each(str.begin(), str.end(),
688 boost::bind(static_cast<void(Cursor::*)(char_type)>
689 (&Cursor::insert), this, _1));
693 void Cursor::insert(char_type c)
695 //lyxerr << "Cursor::insert char '" << c << "'" << endl;
696 BOOST_ASSERT(!empty());
698 cap::selClearOrDel(*this);
699 insert(new InsetMathChar(c));
701 text()->insertChar(*this, c);
706 void Cursor::insert(MathAtom const & t)
708 //lyxerr << "Cursor::insert MathAtom '" << t << "'" << endl;
710 cap::selClearOrDel(*this);
715 void Cursor::insert(Inset * inset)
718 insert(MathAtom(inset));
720 text()->insertInset(*this, inset);
724 void Cursor::niceInsert(docstring const & t)
735 void Cursor::niceInsert(MathAtom const & t)
738 docstring const safe = cap::grabAndEraseSelection(*this);
740 // enter the new inset and move the contents of the selection if possible
743 // be careful here: don't use 'pushLeft(t)' as this we need to
744 // push the clone, not the original
745 pushLeft(*nextInset());
746 // We may not use niceInsert here (recursion)
754 void Cursor::insert(MathData const & ar)
758 cap::eraseSelection(*this);
759 cell().insert(pos(), ar);
764 bool Cursor::backspace()
766 autocorrect() = false;
769 cap::eraseSelection(*this);
774 // If empty cell, and not part of a big cell
775 if (lastpos() == 0 && inset().nargs() == 1) {
777 // Directly delete empty cell: [|[]] => [|]
783 // [|], can not delete from inside
795 InsetMathUnknown * p = activeMacro();
796 if (p->name().size() > 1) {
797 p->setName(p->name().substr(0, p->name().size() - 1));
802 if (pos() != 0 && prevAtom()->nargs() > 0) {
803 // let's require two backspaces for 'big stuff' and
804 // highlight on the first
818 autocorrect() = false;
823 cap::eraseSelection(*this);
827 // delete empty cells if possible
828 if (pos() == lastpos() && inset().idxDelete(idx()))
831 // special behaviour when in last position of cell
832 if (pos() == lastpos()) {
833 bool one_cell = inset().nargs() == 1;
834 if (one_cell && lastpos() == 0) {
836 // Directly delete empty cell: [|[]] => [|]
842 // [|], can not delete from inside
847 inset().idxGlue(idx());
851 // 'clever' UI hack: only erase large items if previously slected
852 if (pos() != lastpos() && nextAtom()->nargs() > 0) {
867 DocIterator save = *this;
871 autocorrect() = false;
879 DocIterator save = *this;
883 autocorrect() = false;
888 bool Cursor::macroModeClose()
892 InsetMathUnknown * p = activeMacro();
894 docstring const s = p->name();
898 // do nothing if the macro name is empty
902 // trigger updates of macros, at least, if no full
903 // updates take place anyway
904 updateFlags(Update::Force);
906 docstring const name = s.substr(1);
907 InsetMathNest * const in = inset().asInsetMath()->asNestInset();
908 if (in && in->interpretString(*this, s))
910 plainInsert(createInsetMath(name));
915 docstring Cursor::macroName()
917 return inMacroMode() ? activeMacro()->name() : docstring();
921 void Cursor::handleNest(MathAtom const & a, int c)
923 //lyxerr << "Cursor::handleNest: " << c << endl;
925 asArray(cap::grabAndEraseSelection(*this), t.nucleus()->cell(c));
928 pushLeft(*nextInset());
932 int Cursor::targetX() const
934 if (x_target() != -1)
943 void Cursor::setTargetX()
952 bool Cursor::inMacroMode() const
956 InsetMathUnknown const * p = prevAtom()->asUnknownInset();
957 return p && !p->final();
961 InsetMathUnknown * Cursor::activeMacro()
963 return inMacroMode() ? prevAtom().nucleus()->asUnknownInset() : 0;
967 void Cursor::pullArg()
972 MathData ar = cell();
973 if (popLeft() && inMathed()) {
975 cell().insert(pos(), ar);
978 //formula()->mutateToText();
989 DocIterator::const_iterator it = begin();
990 DocIterator::const_iterator et = end();
991 for ( ; it != et; ++it)
997 void Cursor::normalize()
999 if (idx() > lastidx()) {
1000 lyxerr << "this should not really happen - 1: "
1001 << idx() << ' ' << nargs()
1002 << " in: " << &inset() << endl;
1006 if (pos() > lastpos()) {
1007 lyxerr << "this should not really happen - 2: "
1008 << pos() << ' ' << lastpos() << " in idx: " << idx()
1010 odocstringstream os;
1011 WriteStream wi(os, false, true);
1012 inset().asInsetMath()->write(wi);
1013 lyxerr << to_utf8(os.str()) << endl;
1019 bool Cursor::goUpDown(bool up)
1021 // Be warned: The 'logic' implemented in this function is highly
1022 // fragile. A distance of one pixel or a '<' vs '<=' _really
1023 // matters. So fiddle around with it only if you think you know
1024 // what you are doing!
1030 // check if we had something else in mind, if not, this is the future
1032 if (x_target() == -1)
1037 // try neigbouring script insets
1041 InsetMathScript const * p = prevAtom()->asScriptInset();
1042 if (p && p->has(up)) {
1044 push(*const_cast<InsetMathScript*>(p));
1045 idx() = p->idxOfScript(up);
1052 if (pos() != lastpos()) {
1053 InsetMathScript const * p = nextAtom()->asScriptInset();
1054 if (p && p->has(up)) {
1055 push(*const_cast<InsetMathScript*>(p));
1056 idx() = p->idxOfScript(up);
1063 // FIXME: Switch this on for more robust movement
1066 return bruteFind3(*this, xo, yo, up);
1069 //xarray().boundingBox(xlow, xhigh, ylow, yhigh);
1074 //if (bruteFind(*this, xo, yo, xlow, xhigh, ylow, yhigh)) {
1075 // lyxerr << "updown: handled by brute find in the same cell" << endl;
1079 // try to find an inset that knows better then we
1081 //lyxerr << "updown: We are in " << &inset() << " idx: " << idx() << endl;
1083 if (inset().idxUpDown(*this, up)) {
1084 //lyxerr << "idxUpDown triggered" << endl;
1085 // try to find best position within this inset
1087 setCursor(bruteFind2(*this, xo, yo));
1091 // no such inset found, just take something "above"
1093 //lyxerr << "updown: popleft failed (strange case)" << endl;
1094 int ylow = up ? 0 : yo + 1;
1095 int yhigh = up ? yo - 1 : bv().workHeight();
1096 return bruteFind(*this, xo, yo, 0, bv().workWidth(), ylow, yhigh);
1099 // any improvement so far?
1100 //lyxerr << "updown: popLeft succeeded" << endl;
1104 if (up ? ynew < yo : ynew > yo)
1108 // we should not come here.
1109 BOOST_ASSERT(false);
1114 void Cursor::handleFont(string const & font)
1116 LYXERR(Debug::DEBUG) << BOOST_CURRENT_FUNCTION << ": " << font << endl;
1120 safe = cap::grabAndEraseSelection(*this);
1123 if (lastpos() != 0) {
1124 // something left in the cell
1126 // cursor in first position
1128 } else if (pos() == lastpos()) {
1129 // cursor in last position
1132 // cursor in between. split cell
1133 MathData::iterator bt = cell().begin();
1134 MathAtom at = createInsetMath(from_utf8(font));
1135 at.nucleus()->cell(0) = MathData(bt, bt + pos());
1136 cell().erase(bt, bt + pos());
1141 // nothing left in the cell
1149 void Cursor::message(docstring const & msg) const
1151 theLyXFunc().setMessage(msg);
1155 void Cursor::errorMessage(docstring const & msg) const
1157 theLyXFunc().setErrorMessage(msg);
1161 docstring Cursor::selectionAsString(bool label) const
1167 Buffer const & buffer = *bv().buffer();
1168 ParagraphList const & pars = text()->paragraphs();
1170 // should be const ...
1171 pit_type startpit = selBegin().pit();
1172 pit_type endpit = selEnd().pit();
1173 size_t const startpos = selBegin().pos();
1174 size_t const endpos = selEnd().pos();
1176 if (startpit == endpit)
1177 return pars[startpit].asString(buffer, startpos, endpos, label);
1179 // First paragraph in selection
1180 docstring result = pars[startpit].
1181 asString(buffer, startpos, pars[startpit].size(), label) + "\n\n";
1183 // The paragraphs in between (if any)
1184 for (pit_type pit = startpit + 1; pit != endpit; ++pit) {
1185 Paragraph const & par = pars[pit];
1186 result += par.asString(buffer, 0, par.size(), label) + "\n\n";
1189 // Last paragraph in selection
1190 result += pars[endpit].asString(buffer, 0, endpos, label);
1196 return cap::grabSelection(*this);
1202 docstring Cursor::currentState()
1205 odocstringstream os;
1211 return text()->currentState(*this);
1217 docstring Cursor::getPossibleLabel()
1219 return inMathed() ? from_ascii("eq:") : text()->getPossibleLabel(*this);
1223 Encoding const * Cursor::getEncoding() const
1230 // go up until first non-0 text is hit
1231 // (innermost text is 0 in mathed)
1232 for (s = depth() - 1; s >= 0; --s)
1233 if (operator[](s).text())
1235 CursorSlice const & sl = operator[](s);
1236 Text const & text = *sl.text();
1237 Font font = text.getPar(sl.pit()).getFont(
1238 bv().buffer()->params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
1239 return font.language()->encoding();
1243 void Cursor::undispatched()
1245 disp_.dispatched(false);
1249 void Cursor::dispatched()
1251 disp_.dispatched(true);
1255 void Cursor::updateFlags(Update::flags f)
1261 void Cursor::noUpdate()
1263 disp_.update(Update::None);
1267 Font Cursor::getFont() const
1269 // HACK. far from being perfect...
1271 // go up until first non-0 text is hit
1272 // (innermost text is 0 in mathed)
1273 for (s = depth() - 1; s >= 0; --s)
1274 if (operator[](s).text())
1276 CursorSlice const & sl = operator[](s);
1277 Text const & text = *sl.text();
1278 Font font = text.getPar(sl.pit()).getFont(
1279 bv().buffer()->params(),
1281 outerFont(sl.pit(), text.paragraphs()));
1287 void Cursor::fixIfBroken()
1289 // find out last good level
1290 Cursor copy = *this;
1291 size_t newdepth = depth();
1292 while (!copy.empty()) {
1293 if (copy.idx() > copy.lastidx()) {
1294 lyxerr << "wrong idx " << copy.idx()
1295 << ", max is " << copy.lastidx()
1296 << " at level " << copy.depth()
1297 << ". Trying to correct this." << endl;
1298 lyxerr << "old: " << *this << endl;
1299 newdepth = copy.depth() - 1;
1301 else if (copy.pit() > copy.lastpit()) {
1302 lyxerr << "wrong pit " << copy.pit()
1303 << ", max is " << copy.lastpit()
1304 << " at level " << copy.depth()
1305 << ". Trying to correct this." << endl;
1306 lyxerr << "old: " << *this << endl;
1307 newdepth = copy.depth() - 1;
1309 else if (copy.pos() > copy.lastpos()) {
1310 lyxerr << "wrong pos " << copy.pos()
1311 << ", max is " << copy.lastpos()
1312 << " at level " << copy.depth()
1313 << ". Trying to correct this." << endl;
1314 lyxerr << "old: " << *this << endl;
1315 newdepth = copy.depth() - 1;
1319 // shrink cursor to a size where everything is valid, possibly
1321 while (depth() > newdepth) {
1323 lyxerr << "correcting cursor to level " << depth() << endl;
1324 lyxerr << "new: " << *this << endl;
1330 bool Cursor::isRTL() const
1333 return innerParagraph().isRightToLeftPar(bv().buffer()->params());
1335 return top().paragraph().isRightToLeftPar(bv().buffer()->params());