CursorData::CursorData()
: DocIterator(), anchor_(),
selection_(false), mark_(false), word_selection_(false),
- logicalpos_(false), current_font(inherit_font)
+ logicalpos_(false), current_font(inherit_font),
+ autocorrect_(false), macromode_(false)
{}
CursorData::CursorData(Buffer * buffer)
: DocIterator(buffer), anchor_(),
selection_(false), mark_(false), word_selection_(false),
- logicalpos_(false), current_font(inherit_font)
+ logicalpos_(false), current_font(inherit_font),
+ autocorrect_(false), macromode_(false)
{}
CursorData::CursorData(DocIterator const & dit)
: DocIterator(dit), anchor_(),
selection_(false), mark_(false), word_selection_(false),
- logicalpos_(false), current_font(inherit_font)
+ logicalpos_(false), current_font(inherit_font),
+ autocorrect_(false), macromode_(false)
{}
+
+
+ostream & operator<<(ostream & os, CursorData const & cur)
+{
+ os << "\n cursor: | anchor:\n";
+ for (size_t i = 0, n = cur.depth(); i != n; ++i) {
+ os << " " << cur[i] << " | ";
+ if (i < cur.anchor_.depth())
+ os << cur.anchor_[i];
+ else
+ os << "-------------------------------";
+ os << "\n";
+ }
+ for (size_t i = cur.depth(), n = cur.anchor_.depth(); i < n; ++i) {
+ os << "------------------------------- | " << cur.anchor_[i] << "\n";
+ }
+ os << " selection: " << cur.selection_
+// << " x_target: " << cur.x_target_
+ << " boundary: " << cur.boundary() << endl;
+ return os;
+}
+
+
+LyXErr & operator<<(LyXErr & os, CursorData const & cur)
+{
+ os.stream() << cur;
+ return os;
+}
+
+
// be careful: this is called from the bv's constructor, too, so
// bv functions are not yet available!
Cursor::Cursor(BufferView & bv)
: CursorData(&bv.buffer()), bv_(&bv),
- x_target_(-1), textTargetOffset_(0)
+ x_target_(-1), textTargetOffset_(0),
+ beforeDispatchPosX_(0), beforeDispatchPosY_(0)
{}
setSelection(sel);
return true;
}
-
-
-ostream & operator<<(ostream & os, Cursor const & cur)
-{
- os << "\n cursor: | anchor:\n";
- for (size_t i = 0, n = cur.depth(); i != n; ++i) {
- os << " " << cur[i] << " | ";
- if (i < cur.anchor_.depth())
- os << cur.anchor_[i];
- else
- os << "-------------------------------";
- os << "\n";
- }
- for (size_t i = cur.depth(), n = cur.anchor_.depth(); i < n; ++i) {
- os << "------------------------------- | " << cur.anchor_[i] << "\n";
- }
- os << " selection: " << cur.selection_
- << " x_target: " << cur.x_target_
- << " boundary: " << cur.boundary() << endl;
- return os;
-}
-
-
-LyXErr & operator<<(LyXErr & os, Cursor const & cur)
-{
- os.stream() << cur;
- return os;
-}
-
-
} // namespace lyx
{
setBuffer(&bv_->buffer());
DocIterator::sanitize();
- anchor_.sanitize();
+ if (selection())
+ anchor_.sanitize();
+ else
+ resetAnchor();
}
}
-void Cursor::recordUndo(UndoKind kind, pit_type from, pit_type to) const
+void Cursor::recordUndo(pit_type from, pit_type to) const
{
- buffer()->undo().recordUndo(*this, kind, from, to);
+ buffer()->undo().recordUndo(*this, from, to);
}
-void Cursor::recordUndo(UndoKind kind, pit_type from) const
+void Cursor::recordUndo(pit_type from) const
{
- buffer()->undo().recordUndo(*this, kind, from);
+ buffer()->undo().recordUndo(*this, from, pit());
}
}
-void Cursor::recordUndoInset(UndoKind kind, Inset const * inset) const
+void Cursor::recordUndoInset(Inset const * in) const
+{
+ if (!in || in == &inset()) {
+ CursorData c = *this;
+ c.pop_back();
+ buffer()->undo().recordUndo(c, c.pit(), c.pit());
+ } else if (in == nextInset())
+ recordUndo();
+ else
+ LYXERR0("Inset not found, no undo element added.");
+}
+
+
+void Cursor::recordUndoFullBuffer() const
{
- buffer()->undo().recordUndoInset(*this, kind, inset);
+ buffer()->undo().recordUndoFullBuffer(*this);
}
-void Cursor::recordUndoFullDocument() const
+void Cursor::recordUndoBufferParams() const
{
- buffer()->undo().recordUndoFullDocument(*this);
+ buffer()->undo().recordUndoBufferParams(*this);
}
else
recordUndo();
} else {
- buffer()->undo().recordUndo(*this, ATOMIC_UNDO,
+ buffer()->undo().recordUndo(*this,
selBegin().pit(), selEnd().pit());
}
}