else
++et.pit();
- double best_dist = numeric_limits<double>::max();;
+ double best_dist = numeric_limits<double>::max();
DocIterator best_cursor = et;
for ( ; it != et; it.forwardPos(true)) {
fixIfBroken();
FuncRequest cmd = cmd0;
Cursor safe = *this;
+ Cursor old = *this;
disp_ = DispatchResult();
buffer()->undo().beginUndoGroup();
-
+
// Is this a function that acts on inset at point?
if (lyxaction.funcHasFlag(cmd.action(), LyXAction::AtPoint)
&& nextInset()) {
beforeDispatchCursor_ = safe.beforeDispatchCursor_;
}
buffer()->undo().endUndoGroup();
+
+ // notify insets we just left
+ if (*this != old) {
+ old.beginUndoGroup();
+ old.fixIfBroken();
+ bool badcursor = notifyCursorLeavesOrEnters(old, *this);
+ if (badcursor) {
+ fixIfBroken();
+ bv().resetInlineCompletionPos();
+ }
+ old.endUndoGroup();
+ }
}
void Cursor::resetAnchor()
{
anchor_ = *this;
+ checkNewWordPosition();
}
}
+void Cursor::markEditPosition()
+{
+ if (lyxrc.spellcheck_continuously && inTexted() && new_word_.empty()) {
+ FontSpan ow = locateWord(WHOLE_WORD);
+ if (ow.size() == 1) {
+ LYXERR(Debug::DEBUG, "start new word: "
+ << " par: " << pit()
+ << " pos: " << ow.first);
+ new_word_ = *this;
+ }
+ }
+}
+
+
+void Cursor::clearNewWordPosition()
+{
+ if (!new_word_.empty()) {
+ LYXERR(Debug::DEBUG, "clear new word: "
+ << " par: " << pit()
+ << " pos: " << pos());
+ new_word_.resize(0);
+ }
+}
+
+
+void Cursor::checkNewWordPosition()
+{
+ if (!lyxrc.spellcheck_continuously || new_word_.empty())
+ return ;
+ if (!inTexted())
+ clearNewWordPosition();
+ else {
+ // forget the position of the current new word if
+ // 1) the paragraph changes or
+ // 2) the count of nested insets changes or
+ // 3) the cursor pos is out of paragraph bound
+ if (pit() != new_word_.pit() ||
+ depth() != new_word_.depth() ||
+ new_word_.pos() > new_word_.lastpos()) {
+ clearNewWordPosition();
+ } else if (new_word_.fixIfBroken())
+ // 4) or the remembered position was "broken"
+ clearNewWordPosition();
+ else {
+ FontSpan nw = locateWord(WHOLE_WORD);
+ if (nw.size()) {
+ FontSpan ow = new_word_.locateWord(WHOLE_WORD);
+ if (nw.intersect(ow).empty())
+ clearNewWordPosition();
+ else
+ LYXERR(Debug::DEBUG, "new word: "
+ << " par: " << pit()
+ << " pos: " << nw.first << ".." << nw.last);
+ } else {
+ clearNewWordPosition();
+ }
+ }
+ }
+}
+
+
bool Cursor::posBackward()
{
if (pos() == 0)
namespace lyx {
-//#define FILEDEBUG 1
-
-
bool Cursor::isInside(Inset const * p) const
{
for (size_t i = 0; i != depth(); ++i)
}
-void Cursor::niceInsert(docstring const & t, Parse::flags f, bool enter)
+int Cursor::niceInsert(docstring const & t, Parse::flags f, bool enter)
{
MathData ar(buffer());
asArray(t, ar, f);
niceInsert(ar[0]);
else
insert(ar);
+ return ar.size();
}
{
if (!inMathed())
return false;
- if (pos() == 0)
+ if (pos() == 0 || cell().empty())
return false;
InsetMathUnknown const * p = prevAtom()->asUnknownInset();
return p && !p->final();
}
-void Cursor::undispatched()
+void Cursor::undispatched() const
{
disp_.dispatched(false);
}
-void Cursor::dispatched()
+void Cursor::dispatched() const
{
disp_.dispatched(true);
}
-void Cursor::screenUpdateFlags(Update::flags f)
+void Cursor::screenUpdateFlags(Update::flags f) const
{
disp_.screenUpdate(f);
}
-void Cursor::forceBufferUpdate()
+void Cursor::forceBufferUpdate() const
{
disp_.forceBufferUpdate();
}
-void Cursor::clearBufferUpdate()
+void Cursor::clearBufferUpdate() const
{
disp_.clearBufferUpdate();
}
}
-void Cursor::noScreenUpdate()
+void Cursor::noScreenUpdate() const
{
disp_.screenUpdate(Update::None);
}
bool const broken_anchor = anchor_.fixIfBroken();
if (broken_cursor || broken_anchor) {
+ clearNewWordPosition();
clearSelection();
return true;
}
}
-void Cursor::recordUndoInset(UndoKind kind) const
+void Cursor::recordUndoInset(UndoKind kind, Inset const * inset) const
{
- buffer()->undo().recordUndoInset(*this, kind);
+ buffer()->undo().recordUndoInset(*this, kind, inset);
}