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"
19 #include "dispatchresult.h"
21 #include "funcrequest.h"
22 #include "iterators.h"
26 #include "lyxfunc.h" // only for setMessage()
30 #include "paragraph.h"
31 #include "paragraph_funcs.h"
33 #include "insets/updatableinset.h"
34 #include "insets/insettabular.h"
35 #include "insets/insettext.h"
37 #include "mathed/math_data.h"
38 #include "mathed/math_hullinset.h"
39 #include "mathed/math_support.h"
41 #include "support/limited_stack.h"
42 #include "support/std_sstream.h"
44 #include "frontends/LyXView.h"
46 #include <boost/assert.hpp>
51 #ifndef CXX_GLOBAL_CSTD
60 limited_stack<string> theCutBuffer;
63 LCursor::LCursor(BufferView & bv)
64 : DocumentIterator(), bv_(&bv), anchor_(),
65 cached_y_(0), x_target_(-1), selection_(false), mark_(false)
72 push_back(CursorSlice());
74 anchor_.push_back(CursorSlice());
82 void LCursor::setCursor(DocumentIterator const & cur, bool sel)
84 // this (intentionally) does not touch the anchor
85 DocumentIterator::operator=(cur);
90 DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
92 //lyxerr << "\nLCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
94 return DispatchResult(false);
96 BOOST_ASSERT(pos() <= lastpos());
97 BOOST_ASSERT(idx() <= lastidx());
98 BOOST_ASSERT(par() <= lastpar());
99 FuncRequest cmd = cmd0;
101 DocumentIterator orig = *this;
105 // the inset's dispatch() is supposed to reset the update and
106 // val flags if necessary
107 inset().dispatch(*this, cmd);
109 // "Mutate" the request for semi-handled requests that need
110 // additional handling in outer levels.
111 switch (disp_.val()) {
113 // the inset handled the event fully
114 return DispatchResult(true, true);
116 // the inset handled the event partially
117 cmd = FuncRequest(LFUN_FINISHED_LEFT);
120 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
123 cmd = FuncRequest(LFUN_FINISHED_UP);
126 cmd = FuncRequest(LFUN_FINISHED_DOWN);
129 //lyxerr << "not handled on level " << depth()
130 // << " val: " << disp_.val() << endl;
135 setCursor(orig, false);
136 //lyxerr << " result: " << res.val() << endl;
141 bool LCursor::getStatus(FuncRequest const & cmd, FuncStatus & status)
143 lyxerr << "\nLCursor::getStatus: cmd: " << cmd << endl << *this << endl;
144 DocumentIterator orig = *this;
145 BOOST_ASSERT(pos() <= lastpos());
146 BOOST_ASSERT(idx() <= lastidx());
147 BOOST_ASSERT(par() <= lastpar());
148 for ( ; size() != 0; pop_back()) {
149 // the inset's getStatus() will return 'true' if it made
150 // a definitive decision on whether it want to handle the
151 // request or not. The result of this decision is put into
152 // the 'status' parameter.
153 bool const res = inset().getStatus(*this, cmd, status);
155 setCursor(orig, false);
159 bool const res = bv().text()->getStatus(*this, cmd, status);
160 setCursor(orig, false);
165 BufferView & LCursor::bv() const
173 BOOST_ASSERT(size() >= 1);
179 void LCursor::push(InsetBase & p)
181 push_back(CursorSlice(p));
185 void LCursor::pushLeft(InsetBase & p)
187 BOOST_ASSERT(!empty());
188 //lyxerr << "Entering inset " << t << " left" << endl;
194 bool LCursor::popLeft()
196 BOOST_ASSERT(!empty());
197 //lyxerr << "Leaving inset to the left" << endl;
200 inset().notifyCursorLeaves(idx());
203 inset().notifyCursorLeaves(idx());
209 bool LCursor::popRight()
211 BOOST_ASSERT(!empty());
212 //lyxerr << "Leaving inset to the right" << endl;
215 inset().notifyCursorLeaves(idx());
218 inset().notifyCursorLeaves(idx());
225 int LCursor::currentMode()
227 BOOST_ASSERT(!empty());
228 for (int i = size() - 1; i >= 1; --i) {
229 int res = operator[](i).inset().currentMode();
230 if (res != MathInset::UNDECIDED_MODE)
233 return MathInset::TEXT_MODE;
237 void LCursor::updatePos()
239 BOOST_ASSERT(!empty());
241 cached_y_ = bv().top_y() + back().inset().yo();
242 //cached_y_ = back().inset().yo();
246 void LCursor::getDim(int & asc, int & des) const
248 BOOST_ASSERT(!empty());
250 BOOST_ASSERT(inset().asMathInset());
251 //inset().asMathInset()->getCursorDim(asc, des);
255 Row const & row = textRow();
256 asc = row.baseline();
257 des = row.height() - asc;
262 void LCursor::getPos(int & x, int & y) const
264 BOOST_ASSERT(!empty());
268 x = bv().text()->cursorX(front());
269 y = bv().text()->cursorY(front());
271 inset().getCursorPos(back(), x, y);
272 // getCursorPos gives _screen_ coordinates. We need to add
273 // top_y to get document coordinates. This is hidden in cached_y_.
274 //y += cached_y_ - inset().yo();
275 // The rest is non-obvious. The reason we have to have these
276 // extra computation is that the getCursorPos() calls rely
277 // on the inset's own knowledge of its screen position.
278 // If we scroll up or down in a big enough increment,
279 // inset->draw() is not called: this doesn't update
280 // inset.yo_, so getCursor() returns an old value.
283 //lyxerr << "#### LCursor::getPos: " << *this
284 // << " x: " << x << " y: " << y << endl;
288 void LCursor::paste(string const & data)
290 dispatch(FuncRequest(LFUN_PASTE, data));
294 void LCursor::resetAnchor()
301 bool LCursor::posLeft()
310 bool LCursor::posRight()
312 if (pos() == lastpos())
319 CursorSlice & LCursor::anchor()
321 return anchor_.back();
325 CursorSlice const & LCursor::anchor() const
327 return anchor_.back();
331 CursorSlice const & LCursor::selBegin() const
335 return anchor() < back() ? anchor() : back();
339 CursorSlice & LCursor::selBegin()
343 // can't use std::min as this returns a const ref
344 return anchor() < back() ? anchor() : back();
348 CursorSlice const & LCursor::selEnd() const
352 return anchor() > back() ? anchor() : back();
356 CursorSlice & LCursor::selEnd()
360 // can't use std::min as this returns a const ref
361 return anchor() > back() ? anchor() : back();
365 void LCursor::setSelection()
368 // a selection with no contents is not a selection
369 if (par() == anchor().par() && pos() == anchor().pos())
374 void LCursor::setSelection(DocumentIterator const & where, size_t n)
377 setCursor(where, false);
383 void LCursor::clearSelection()
392 int & LCursor::x_target()
398 int LCursor::x_target() const
404 void LCursor::clearTargetX()
411 void LCursor::info(std::ostream & os) const
413 for (int i = 1, n = depth(); i < n; ++i) {
414 operator[](i).inset().infoize(os);
418 prevInset()->infoize2(os);
419 // overwite old message
426 void region(CursorSlice const & i1, CursorSlice const & i2,
427 LCursor::row_type & r1, LCursor::row_type & r2,
428 LCursor::col_type & c1, LCursor::col_type & c2)
430 InsetBase & p = i1.inset();
444 string LCursor::grabSelection()
449 CursorSlice i1 = selBegin();
450 CursorSlice i2 = selEnd();
452 if (i1.idx_ == i2.idx_) {
453 if (i1.inset().asMathInset()) {
454 MathArray::const_iterator it = i1.cell().begin();
455 return asString(MathArray(it + i1.pos_, it + i2.pos_));
457 return "unknown selection 1";
463 region(i1, i2, r1, r2, c1, c2);
466 if (i1.inset().asMathInset()) {
467 for (row_type row = r1; row <= r2; ++row) {
470 for (col_type col = c1; col <= c2; ++col) {
473 data += asString(i1.asMathInset()->cell(i1.asMathInset()->index(row, col)));
477 data = "unknown selection 2";
483 void LCursor::eraseSelection()
485 //lyxerr << "LCursor::eraseSelection" << endl;
486 CursorSlice const & i1 = selBegin();
487 CursorSlice const & i2 = selEnd();
489 if (i1.inset().asMathInset()) {
490 if (i1.idx_ == i2.idx_) {
491 i1.cell().erase(i1.pos_, i2.pos_);
493 MathInset * p = i1.asMathInset();
496 region(i1, i2, r1, r2, c1, c2);
497 for (row_type row = r1; row <= r2; ++row)
498 for (col_type col = c1; col <= c2; ++col)
499 p->cell(p->index(row, col)).clear();
503 lyxerr << "can't erase this selection 1" << endl;
505 //lyxerr << "LCursor::eraseSelection end" << endl;
509 string LCursor::grabAndEraseSelection()
513 string res = grabSelection();
520 void LCursor::selClear()
527 void LCursor::selCopy()
530 theCutBuffer.push(grabSelection());
533 //theCutBuffer.erase();
538 void LCursor::selCut()
540 theCutBuffer.push(grabAndEraseSelection());
544 void LCursor::selDel()
546 //lyxerr << "LCursor::selDel" << endl;
554 void LCursor::selPaste(size_t n)
557 if (n < theCutBuffer.size())
558 paste(theCutBuffer[n]);
564 void LCursor::selHandle(bool sel)
566 //lyxerr << "LCursor::selHandle" << endl;
567 if (sel == selection())
574 void LCursor::selClearOrDel()
576 //lyxerr << "LCursor::selClearOrDel" << endl;
577 if (lyxrc.auto_region_delete)
584 std::ostream & operator<<(std::ostream & os, LCursor const & cur)
586 for (size_t i = 0, n = cur.size(); i != n; ++i)
587 os << " " << cur.operator[](i) << " | " << cur.anchor_[i] << "\n";
588 os << " selection: " << cur.selection_ << endl;
595 ///////////////////////////////////////////////////////////////////
597 // The part below is the non-integrated rest of the original math
598 // cursor. This should be either generalized for texted or moved
599 // back to mathed (in most cases to MathNestInset).
601 ///////////////////////////////////////////////////////////////////
603 #include "mathed/math_charinset.h"
604 #include "mathed/math_factory.h"
605 #include "mathed/math_gridinset.h"
606 #include "mathed/math_macroarg.h"
607 #include "mathed/math_macrotemplate.h"
608 #include "mathed/math_mathmlstream.h"
609 #include "mathed/math_scriptinset.h"
610 #include "mathed/math_support.h"
611 #include "mathed/math_unknowninset.h"
613 //#define FILEDEBUG 1
616 bool LCursor::isInside(InsetBase const * p)
618 for (unsigned i = 0; i < depth(); ++i)
619 if (&operator[](i).inset() == p)
625 bool LCursor::openable(MathAtom const & t) const
636 // we can't move into anything new during selection
637 if (depth() == anchor_.size())
639 if (!ptr_cmp(t.nucleus(), &anchor_[depth()].inset()))
646 bool positionable(DocumentIterator const & cursor,
647 DocumentIterator const & anchor)
649 // avoid deeper nested insets when selecting
650 if (cursor.size() > anchor.size())
653 // anchor might be deeper, should have same path then
654 for (size_t i = 0; i < cursor.size(); ++i)
655 if (&cursor[i].inset() != &anchor[i].inset())
658 // position should be ok.
663 void LCursor::setScreenPos(int x, int y)
665 bool res = bruteFind(x, y, formula()->xlow(), formula()->xhigh(),
666 formula()->ylow(), formula()->yhigh());
668 // this can happen on creation of "math-display"
677 void LCursor::plainErase()
683 void LCursor::markInsert()
685 cell().insert(pos(), MathAtom(new MathCharInset(0)));
689 void LCursor::markErase()
695 void LCursor::plainInsert(MathAtom const & t)
697 cell().insert(pos(), t);
702 void LCursor::insert(string const & str)
704 lyxerr << "LCursor::insert str '" << str << "'" << endl;
707 for (string::const_iterator it = str.begin(); it != str.end(); ++it)
708 plainInsert(MathAtom(new MathCharInset(*it)));
717 void LCursor::insert(char c)
719 //lyxerr << "LCursor::insert char '" << c << "'" << endl;
721 plainInsert(MathAtom(new MathCharInset(c)));
725 void LCursor::insert(MathAtom const & t)
727 //lyxerr << "LCursor::insert MathAtom: " << endl;
734 void LCursor::insert(InsetBase * inset)
737 insert(MathAtom(inset));
739 text()->insertInset(*this, inset);
743 void LCursor::niceInsert(string const & t)
754 void LCursor::niceInsert(MathAtom const & t)
757 string safe = grabAndEraseSelection();
759 // enter the new inset and move the contents of the selection if possible
762 // be careful here: don't use 'pushLeft(t)' as this we need to
763 // push the clone, not the original
764 pushLeft(*nextInset());
770 void LCursor::insert(MathArray const & ar)
775 cell().insert(pos(), ar);
780 bool LCursor::backspace()
782 autocorrect() = false;
790 if (inset().nargs() == 1 && depth() == 1 && lastpos() == 0)
797 MathUnknownInset * p = activeMacro();
798 if (p->name().size() > 1) {
799 p->setName(p->name().substr(0, p->name().size() - 1));
804 if (pos() != 0 && prevAtom()->nargs() > 0) {
805 // let's require two backspaces for 'big stuff' and
806 // highlight on the first
817 bool LCursor::erase()
819 autocorrect() = false;
828 // delete empty cells if possible
829 if (pos() == lastpos() && inset().idxDelete(idx()))
832 // special behaviour when in last position of cell
833 if (pos() == lastpos()) {
834 bool one_cell = inset().nargs() == 1;
835 if (one_cell && depth() == 1 && lastpos() == 0)
841 inset().idxGlue(idx());
845 if (pos() != lastpos() && inset().nargs() > 0) {
859 DocumentIterator save = *this;
862 setCursor(save, false);
863 autocorrect() = false;
871 DocumentIterator save = *this;
874 setCursor(save, false);
875 autocorrect() = false;
880 void LCursor::macroModeClose()
884 MathUnknownInset * p = activeMacro();
886 string s = p->name();
890 // do nothing if the macro name is empty
894 string const name = s.substr(1);
896 // prevent entering of recursive macros
897 InsetBase const * macro = innerInsetOfType(InsetBase::MATHMACRO_CODE);
898 if (macro && macro->getInsetName() == name)
899 lyxerr << "can't enter recursive macro" << endl;
901 niceInsert(createMathInset(name));
905 string LCursor::macroName()
907 return inMacroMode() ? activeMacro()->name() : string();
911 void LCursor::handleNest(MathAtom const & a, int c)
913 //lyxerr << "LCursor::handleNest: " << c << endl;
915 asArray(grabAndEraseSelection(), t.nucleus()->cell(c));
918 pushLeft(*nextInset());
922 int LCursor::targetX() const
924 if (x_target() != -1)
933 MathHullInset * LCursor::formula() const
935 for (int i = size() - 1; i >= 1; --i) {
936 MathInset * inset = operator[](i).inset().asMathInset();
937 if (inset && inset->asHullInset())
938 return static_cast<MathHullInset *>(inset);
944 void LCursor::adjust(pos_type from, int diff)
948 if (anchor().pos_ > from)
949 anchor().pos_ += diff;
950 // just to be on the safe side
951 // theoretically unecessary
956 bool LCursor::inMacroMode() const
960 MathUnknownInset const * p = prevAtom()->asUnknownInset();
961 return p && !p->final();
965 MathUnknownInset * LCursor::activeMacro()
967 return inMacroMode() ? prevAtom().nucleus()->asUnknownInset() : 0;
971 bool LCursor::inMacroArgMode() const
973 return pos() > 0 && prevAtom()->getChar() == '#';
977 MathGridInset * LCursor::enclosingGrid(idx_type & idx) const
979 for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
980 MathInset * m = operator[](i).inset().asMathInset();
983 MathGridInset * p = m->asGridInset();
985 idx = operator[](i).idx_;
993 void LCursor::pullArg()
996 MathArray ar = cell();
997 if (popLeft() && inMathed()) {
999 cell().insert(pos(), ar);
1002 //formula()->mutateToText();
1007 void LCursor::touch()
1011 DocumentIterator::const_iterator it = begin();
1012 DocumentIterator::const_iterator et = end();
1013 for ( ; it != et; ++it)
1019 void LCursor::normalize()
1021 if (idx() >= nargs()) {
1022 lyxerr << "this should not really happen - 1: "
1023 << idx() << ' ' << nargs()
1024 << " in: " << &inset() << endl;
1026 idx() = min(idx(), lastidx());
1028 if (pos() > lastpos()) {
1029 lyxerr << "this should not really happen - 2: "
1030 << pos() << ' ' << lastpos() << " in idx: " << idx()
1032 WriteStream wi(lyxerr, false, true);
1033 inset().asMathInset()->write(wi);
1036 pos() = min(pos(), lastpos());
1040 char LCursor::valign()
1043 MathGridInset * p = enclosingGrid(idx);
1044 return p ? p->valign() : '\0';
1048 char LCursor::halign()
1051 MathGridInset * p = enclosingGrid(idx);
1052 return p ? p->halign(idx % p->ncols()) : '\0';
1056 bool LCursor::goUpDown(bool up)
1058 // Be warned: The 'logic' implemented in this function is highly
1059 // fragile. A distance of one pixel or a '<' vs '<=' _really
1060 // matters. So fiddle around with it only if you think you know
1061 // what you are doing!
1066 // check if we had something else in mind, if not, this is the future goal
1067 if (x_target() == -1)
1072 // try neigbouring script insets
1076 MathScriptInset const * p = prevAtom()->asScriptInset();
1077 if (p && p->has(up)) {
1080 idx() = up; // the superscript has index 1
1082 //lyxerr << "updown: handled by scriptinset to the left" << endl;
1088 if (pos() != lastpos()) {
1089 MathScriptInset const * p = nextAtom()->asScriptInset();
1090 if (p && p->has(up)) {
1094 //lyxerr << "updown: handled by scriptinset to the right" << endl;
1100 // try current cell for e.g. text insets
1101 if (inset().idxUpDown2(*this, up))
1104 //xarray().boundingBox(xlow, xhigh, ylow, yhigh);
1109 //if (bruteFind(xo, yo, xlow, xhigh, ylow, yhigh)) {
1110 // lyxerr << "updown: handled by brute find in the same cell" << endl;
1114 // try to find an inset that knows better then we
1116 //lyxerr << "updown: We are in " << &inset() << " idx: " << idx() << endl;
1118 if (inset().idxUpDown(*this, up)) {
1119 // try to find best position within this inset
1125 // no such inset found, just take something "above"
1126 //lyxerr << "updown: handled by strange case" << endl;
1132 up ? formula()->ylow() : yo + 4,
1133 up ? yo - 4 : formula()->yhigh()
1137 // any improvement so far?
1140 if (up ? ynew < yo : ynew > yo)
1146 bool LCursor::bruteFind(int x, int y, int xlow, int xhigh, int ylow, int yhigh)
1148 DocumentIterator best_cursor;
1149 double best_dist = 1e10;
1151 DocumentIterator it = insetBegin(bv().buffer()->inset());
1152 DocumentIterator et = insetEnd();
1154 // avoid invalid nesting when selecting
1155 if (!selection() || positionable(it, anchor_)) {
1157 CursorSlice & cur = it.back();
1158 cur.inset().getCursorPos(cur, xo, yo);
1159 if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
1160 double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
1161 //lyxerr << "x: " << x << " y: " << y << " d: " << endl;
1162 // '<=' in order to take the last possible position
1163 // this is important for clicking behind \sum in e.g. '\sum_i a'
1164 if (d <= best_dist) {
1176 if (best_dist < 1e10)
1177 setCursor(best_cursor, false);
1178 return best_dist < 1e10;
1182 void LCursor::bruteFind2(int x, int y)
1184 double best_dist = 1e10;
1186 DocumentIterator it = *this;
1187 it.back().pos() = 0;
1188 DocumentIterator et = *this;
1189 et.back().pos() = et.back().asMathInset()->cell(et.back().idx_).size();
1190 for (int i = 0; ; ++i) {
1192 CursorSlice & cur = it.back();
1193 cur.inset().getCursorPos(cur, xo, yo);
1194 double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
1195 // '<=' in order to take the last possible position
1196 // this is important for clicking behind \sum in e.g. '\sum_i a'
1197 lyxerr << "i: " << i << " d: " << d << " best: " << best_dist << endl;
1198 if (d <= best_dist) {
1200 setCursor(it, false);
1209 CursorSlice LCursor::normalAnchor()
1211 if (anchor_.size() < depth()) {
1213 lyxerr << "unusual Anchor size" << endl;
1215 //lyx::BOOST_ASSERT(Anchor_.size() >= cursor.depth());
1216 // use Anchor on the same level as Cursor
1217 CursorSlice normal = anchor_[size() - 1];
1219 if (depth() < anchor_.size() && !(normal < xx())) {
1220 // anchor is behind cursor -> move anchor behind the inset
1228 void LCursor::handleFont(string const & font)
1230 lyxerr << "LCursor::handleFont: " << font << endl;
1234 safe = grabAndEraseSelection();
1237 if (lastpos() != 0) {
1238 // something left in the cell
1240 // cursor in first position
1242 } else if (pos() == lastpos()) {
1243 // cursor in last position
1246 // cursor in between. split cell
1247 MathArray::iterator bt = cell().begin();
1248 MathAtom at = createMathInset(font);
1249 at.nucleus()->cell(0) = MathArray(bt, bt + pos());
1250 cell().erase(bt, bt + pos());
1255 // nothing left in the cell
1263 void LCursor::message(string const & msg) const
1265 bv().owner()->getLyXFunc().setMessage(msg);
1269 void LCursor::errorMessage(string const & msg) const
1271 bv().owner()->getLyXFunc().setErrorMessage(msg);
1275 string LCursor::selectionAsString(bool label) const
1281 Buffer const & buffer = *bv().buffer();
1283 // should be const ...
1284 ParagraphList::iterator startpit = text()->getPar(selBegin());
1285 ParagraphList::iterator endpit = text()->getPar(selEnd());
1286 size_t const startpos = selBegin().pos();
1287 size_t const endpos = selEnd().pos();
1289 if (startpit == endpit)
1290 return startpit->asString(buffer, startpos, endpos, label);
1292 // First paragraph in selection
1294 startpit->asString(buffer, startpos, startpit->size(), label) + "\n\n";
1296 // The paragraphs in between (if any)
1297 ParagraphList::iterator pit = startpit;
1298 for (++pit; pit != endpit; ++pit)
1299 result += pit->asString(buffer, 0, pit->size(), label) + "\n\n";
1301 // Last paragraph in selection
1302 result += endpit->asString(buffer, 0, endpos, label);
1307 #warning and mathed?
1312 string LCursor::currentState()
1315 std::ostringstream os;
1321 return text()->currentState(*this);
1327 // only used by the spellchecker
1328 void LCursor::replaceWord(string const & replacestring)
1330 LyXText * t = text();
1333 t->replaceSelectionWithString(*this, replacestring);
1334 t->setSelectionRange(*this, replacestring.length());
1336 // Go back so that replacement string is also spellchecked
1337 for (string::size_type i = 0; i < replacestring.length() + 1; ++i)
1338 t->cursorLeft(*this);
1342 void LCursor::update()
1348 string LCursor::getPossibleLabel()
1350 return inMathed() ? "eq:" : text()->getPossibleLabel(*this);
1354 Encoding const * LCursor::getEncoding() const
1361 // go up until first non-0 text is hit
1362 // (innermost text is 0 in mathed)
1363 for (s = size() - 1; s >= 0; --s)
1364 if (operator[](s).text())
1366 CursorSlice const & sl = operator[](s);
1367 LyXText & text = *sl.text();
1368 ParagraphList::iterator pit = text.getPar(sl.par());
1369 LyXFont font = pit->getFont(
1370 bv().buffer()->params(), sl.pos(), outerFont(pit, text.paragraphs()));
1371 return font.language()->encoding();
1375 void LCursor::undispatched()
1377 disp_.dispatched(false);
1381 void LCursor::dispatched(dispatch_result_t res)
1387 void LCursor::noUpdate()
1389 disp_.update(false);
1393 void LCursor::noPop()