X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCursor.cpp;h=92b9110ba7629b9b7215acae81e3296df281be48;hb=2f271f61bcd514da3ab5b44d2b7bf61e12ac0c44;hp=65d9feea4f672f1abd0f3f04bd225031488c5605;hpb=3589a75a11866b11e3c0686190e5ae0a6e742e3c;p=lyx.git diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 65d9feea4f..92b9110ba7 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -468,7 +468,7 @@ bool Cursor::posVisRight(bool skip_inset) new_cur.pos() = right_pos; new_cur.boundary(false); if (!skip_inset && - text()->checkAndActivateInsetVisual(new_cur, right_pos>=pos(), false)) { + text()->checkAndActivateInsetVisual(new_cur, right_pos >= pos(), false)) { // we actually move the cursor at the end of this function, for now // we just keep track of the new position in new_cur... LYXERR(Debug::RTL, "entering inset at: " << new_cur.pos()); @@ -944,7 +944,14 @@ DocIterator Cursor::selectionBegin() const { if (!selection()) return *this; - DocIterator di = (anchor() < top() ? anchor_ : *this); + + DocIterator di; + // FIXME: This is a work-around for the problem that + // CursorSlice doesn't keep track of the boundary. + if (anchor() == top()) + di = anchor_.boundary() > boundary() ? anchor_ : *this; + else + di = anchor() < top() ? anchor_ : *this; di.resize(depth()); return di; } @@ -954,7 +961,15 @@ DocIterator Cursor::selectionEnd() const { if (!selection()) return *this; - DocIterator di = (anchor() > top() ? anchor_ : *this); + + DocIterator di; + // FIXME: This is a work-around for the problem that + // CursorSlice doesn't keep track of the boundary. + if (anchor() == top()) + di = anchor_.boundary() < boundary() ? anchor_ : *this; + else + di = anchor() > top() ? anchor_ : *this; + if (di.depth() > depth()) { di.resize(depth()); ++di.pos(); @@ -968,7 +983,9 @@ void Cursor::setSelection() selection() = true; // A selection with no contents is not a selection // FIXME: doesnt look ok - if (pit() == anchor().pit() && pos() == anchor().pos()) + if (idx() == anchor().idx() && + pit() == anchor().pit() && + pos() == anchor().pos()) selection() = false; } @@ -1812,6 +1829,8 @@ void Cursor::handleFont(string const & font) safe = cap::grabAndEraseSelection(*this); } + recordUndoInset(); + if (lastpos() != 0) { // something left in the cell if (pos() == 0) { @@ -1831,8 +1850,9 @@ void Cursor::handleFont(string const & font) } } else { // nothing left in the cell - pullArg(); + popBackward(); plainErase(); + resetAnchor(); } insert(safe); } @@ -2115,6 +2135,18 @@ void Cursor::finishUndo() const } +void Cursor::beginUndoGroup() const +{ + bv_->buffer().undo().beginUndoGroup(); +} + + +void Cursor::endUndoGroup() const +{ + bv_->buffer().undo().endUndoGroup(); +} + + void Cursor::recordUndo(UndoKind kind, pit_type from, pit_type to) const { bv_->buffer().undo().recordUndo(*this, kind, from, to);