mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
* BufferView_pimpl.C:
* lyxtext.h: * text.C: * text2.C: * text3.C: * undo_funcs.[Ch]: use paroffset_type instead of ParagraphList::iterators to prevent multiple conversion (and get a more robust interface) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7909 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
57c37d2760
commit
a316a54e60
@ -1340,7 +1340,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// not quite sure if we want this...
|
// not quite sure if we want this...
|
||||||
recordUndo(bv_, Undo::ATOMIC);
|
bv_->text->recUndo(bv_->text->cursor.par());
|
||||||
freezeUndo();
|
freezeUndo();
|
||||||
|
|
||||||
beforeChange(bv_->text);
|
beforeChange(bv_->text);
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
|
||||||
|
2003-10-13 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* BufferView_pimpl.C:
|
||||||
|
* lyxtext.h:
|
||||||
|
* text.C:
|
||||||
|
* text2.C:
|
||||||
|
* text3.C:
|
||||||
|
* undo_funcs.[Ch]: use paroffset_type instead of
|
||||||
|
ParagraphList::iterators to prevent multiple conversion
|
||||||
|
(and get a more robust interface)
|
||||||
|
|
||||||
2003-10-13 Lars Gullik Bjønnes <larsbj@gullik.net>
|
2003-10-13 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* lyxfunc.C (dispatch): RESULT -> dispatch_result
|
* lyxfunc.C (dispatch): RESULT -> dispatch_result
|
||||||
|
@ -635,8 +635,12 @@ dispatch_result InsetTabular::localDispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
if (cmd.action == LFUN_INSET_EDIT) {
|
if (cmd.action == LFUN_INSET_EDIT) {
|
||||||
|
|
||||||
|
lyxerr << "InsetTabular::edit: " << this << " args: '"
|
||||||
|
<< cmd.argument << "' first cell: "
|
||||||
|
<< &tabular.cell_info[0][0].inset << endl;
|
||||||
|
|
||||||
if (!bv->lockInset(this)) {
|
if (!bv->lockInset(this)) {
|
||||||
lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
|
lyxerr << "InsetTabular::Cannot lock inset" << endl;
|
||||||
return DISPATCHED;
|
return DISPATCHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2538,6 +2542,11 @@ bool InsetTabular::forceDefaultParagraphs(InsetOld const * in) const
|
|||||||
if (cell != -1)
|
if (cell != -1)
|
||||||
return tabular.getPWidth(cell).zero();
|
return tabular.getPWidth(cell).zero();
|
||||||
|
|
||||||
|
// this is a workaround for a crash (New, Insert->Tabular,
|
||||||
|
// Insert->FootNote)
|
||||||
|
if (!owner())
|
||||||
|
return false;
|
||||||
|
|
||||||
// well we didn't obviously find it so maybe our owner knows more
|
// well we didn't obviously find it so maybe our owner knows more
|
||||||
BOOST_ASSERT(owner());
|
BOOST_ASSERT(owner());
|
||||||
return owner()->forceDefaultParagraphs(in);
|
return owner()->forceDefaultParagraphs(in);
|
||||||
|
@ -1336,7 +1336,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
|||||||
|
|
||||||
|
|
||||||
if (text_.selection.set())
|
if (text_.selection.set())
|
||||||
recordUndo(bv, Undo::ATOMIC, text_.cursorPar());
|
text_.recUndo(text_.cursor.par());
|
||||||
|
|
||||||
if (selectall) {
|
if (selectall) {
|
||||||
text_.cursorTop();
|
text_.cursorTop();
|
||||||
|
@ -258,6 +258,10 @@ public:
|
|||||||
lyx::pos_type pos,
|
lyx::pos_type pos,
|
||||||
LyXFont const & font) const;
|
LyXFont const & font) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
void recUndo(lyx::paroffset_type first, lyx::paroffset_type last) const;
|
||||||
|
///
|
||||||
|
void recUndo(lyx::paroffset_type first) const;
|
||||||
///
|
///
|
||||||
void setCursorFromCoordinates(int x, int y);
|
void setCursorFromCoordinates(int x, int y);
|
||||||
///
|
///
|
||||||
|
28
src/text.C
28
src/text.C
@ -1206,7 +1206,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
|||||||
&& layout->labeltype != LABEL_SENSITIVE)
|
&& layout->labeltype != LABEL_SENSITIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, cursorPar());
|
recUndo(cursor.par());
|
||||||
|
|
||||||
// Always break behind a space
|
// Always break behind a space
|
||||||
//
|
//
|
||||||
@ -1284,7 +1284,7 @@ void LyXText::redoParagraph()
|
|||||||
// same Paragraph one to the right and make a rebreak
|
// same Paragraph one to the right and make a rebreak
|
||||||
void LyXText::insertChar(char c)
|
void LyXText::insertChar(char c)
|
||||||
{
|
{
|
||||||
recordUndo(bv(), Undo::INSERT, cursorPar());
|
recordUndo(bv(), Undo::INSERT, ownerParagraphs(), cursor.par(), cursor.par());
|
||||||
|
|
||||||
// When the free-spacing option is set for the current layout,
|
// When the free-spacing option is set for the current layout,
|
||||||
// disable the double-space checking
|
// disable the double-space checking
|
||||||
@ -1568,7 +1568,7 @@ void LyXText::acceptChange()
|
|||||||
if (selection.start.par() == selection.end.par()) {
|
if (selection.start.par() == selection.end.par()) {
|
||||||
LyXCursor & startc = selection.start;
|
LyXCursor & startc = selection.start;
|
||||||
LyXCursor & endc = selection.end;
|
LyXCursor & endc = selection.end;
|
||||||
recordUndo(bv(), Undo::INSERT, getPar(startc));
|
recordUndo(bv(), Undo::INSERT, ownerParagraphs(), startc.par());
|
||||||
getPar(startc)->acceptChange(startc.pos(), endc.pos());
|
getPar(startc)->acceptChange(startc.pos(), endc.pos());
|
||||||
finishUndo();
|
finishUndo();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@ -1587,7 +1587,7 @@ void LyXText::rejectChange()
|
|||||||
if (selection.start.par() == selection.end.par()) {
|
if (selection.start.par() == selection.end.par()) {
|
||||||
LyXCursor & startc = selection.start;
|
LyXCursor & startc = selection.start;
|
||||||
LyXCursor & endc = selection.end;
|
LyXCursor & endc = selection.end;
|
||||||
recordUndo(bv(), Undo::INSERT, getPar(startc));
|
recordUndo(bv(), Undo::INSERT, ownerParagraphs(), startc.par());
|
||||||
getPar(startc)->rejectChange(startc.pos(), endc.pos());
|
getPar(startc)->rejectChange(startc.pos(), endc.pos());
|
||||||
finishUndo();
|
finishUndo();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@ -1797,7 +1797,7 @@ void LyXText::changeCase(LyXText::TextCase action)
|
|||||||
setCursor(to.par(), to.pos() + 1);
|
setCursor(to.par(), to.pos() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, getPar(from), getPar(to));
|
recordUndo(bv(), Undo::ATOMIC, ownerParagraphs(), from.par(), to.par());
|
||||||
|
|
||||||
pos_type pos = from.pos();
|
pos_type pos = from.pos();
|
||||||
int par = from.par();
|
int par = from.par();
|
||||||
@ -1858,11 +1858,7 @@ void LyXText::Delete()
|
|||||||
|
|
||||||
// if you had success make a backspace
|
// if you had success make a backspace
|
||||||
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
|
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
|
||||||
LyXCursor tmpcursor = cursor;
|
recordUndo(bv(), Undo::DELETE, ownerParagraphs(), old_cursor.par());
|
||||||
// to make sure undo gets the right cursor position
|
|
||||||
cursor = old_cursor;
|
|
||||||
recordUndo(bv(), Undo::DELETE, cursorPar());
|
|
||||||
cursor = tmpcursor;
|
|
||||||
backspace();
|
backspace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1911,11 +1907,9 @@ void LyXText::backspace()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursorPar() != ownerParagraphs().begin()) {
|
if (cursor.par() != 0)
|
||||||
recordUndo(bv(), Undo::DELETE,
|
recordUndo(bv(), Undo::DELETE, ownerParagraphs(),
|
||||||
boost::prior(cursorPar()),
|
cursor.par() - 1, cursor.par());
|
||||||
cursorPar());
|
|
||||||
}
|
|
||||||
|
|
||||||
ParagraphList::iterator tmppit = cursorPar();
|
ParagraphList::iterator tmppit = cursorPar();
|
||||||
// We used to do cursorLeftIntern() here, but it is
|
// We used to do cursorLeftIntern() here, but it is
|
||||||
@ -1954,7 +1948,7 @@ void LyXText::backspace()
|
|||||||
} else {
|
} else {
|
||||||
// this is the code for a normal backspace, not pasting
|
// this is the code for a normal backspace, not pasting
|
||||||
// any paragraphs
|
// any paragraphs
|
||||||
recordUndo(bv(), Undo::DELETE, cursorPar());
|
recordUndo(bv(), Undo::DELETE, ownerParagraphs(), cursor.par());
|
||||||
// We used to do cursorLeftIntern() here, but it is
|
// We used to do cursorLeftIntern() here, but it is
|
||||||
// not a good idea since it triggers the auto-delete
|
// not a good idea since it triggers the auto-delete
|
||||||
// mechanism. So we do a cursorLeftIntern()-lite,
|
// mechanism. So we do a cursorLeftIntern()-lite,
|
||||||
@ -1988,7 +1982,7 @@ ParagraphList::iterator LyXText::getPar(LyXCursor const & cur) const
|
|||||||
ParagraphList::iterator LyXText::getPar(int par) const
|
ParagraphList::iterator LyXText::getPar(int par) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(par >= 0);
|
BOOST_ASSERT(par >= 0);
|
||||||
BOOST_ASSERT(par < ownerParagraphs().size());
|
BOOST_ASSERT(par < int(ownerParagraphs().size()));
|
||||||
ParagraphList::iterator pit = ownerParagraphs().begin();
|
ParagraphList::iterator pit = ownerParagraphs().begin();
|
||||||
std::advance(pit, par);
|
std::advance(pit, par);
|
||||||
return pit;
|
return pit;
|
||||||
|
36
src/text2.C
36
src/text2.C
@ -276,7 +276,7 @@ void LyXText::toggleInset()
|
|||||||
|
|
||||||
// do we want to keep this?? (JMarc)
|
// do we want to keep this?? (JMarc)
|
||||||
if (!isHighlyEditableInset(inset))
|
if (!isHighlyEditableInset(inset))
|
||||||
recordUndo(bv(), Undo::ATOMIC);
|
recUndo(cursor.par());
|
||||||
|
|
||||||
if (inset->isOpen())
|
if (inset->isOpen())
|
||||||
inset->close(bv());
|
inset->close(bv());
|
||||||
@ -328,7 +328,7 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
|
|||||||
++endpit;
|
++endpit;
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, getPar(sstart_cur), boost::prior(undoendpit));
|
recUndo(sstart_cur.par(), parOffset(undoendpit) - 1);
|
||||||
|
|
||||||
// ok we have a selection. This is always between sstart_cur
|
// ok we have a selection. This is always between sstart_cur
|
||||||
// and sel_end cursor
|
// and sel_end cursor
|
||||||
@ -421,7 +421,7 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
|||||||
ParagraphList::iterator pastend = boost::next(end);
|
ParagraphList::iterator pastend = boost::next(end);
|
||||||
|
|
||||||
if (!test_only)
|
if (!test_only)
|
||||||
recordUndo(bv(), Undo::ATOMIC, start, end);
|
recUndo(parOffset(start), parOffset(end));
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
@ -514,7 +514,7 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
|||||||
// ok we have a selection. This is always between sel_start_cursor
|
// ok we have a selection. This is always between sel_start_cursor
|
||||||
// and sel_end cursor
|
// and sel_end cursor
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, getPar(selection.start), getPar(selection.end));
|
recUndo(selection.start.par(), selection.end.par());
|
||||||
freezeUndo();
|
freezeUndo();
|
||||||
cursor = selection.start;
|
cursor = selection.start;
|
||||||
while (cursor.par() != selection.end.par() ||
|
while (cursor.par() != selection.end.par() ||
|
||||||
@ -787,8 +787,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
|
|||||||
++endpit;
|
++endpit;
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, getPar(selection.start),
|
recUndo(selection.start.par(), parOffset(undoendpit) - 1);
|
||||||
boost::prior(undoendpit));
|
|
||||||
|
|
||||||
|
|
||||||
int tmppit = selection.end.par();
|
int tmppit = selection.end.par();
|
||||||
@ -1125,7 +1124,7 @@ void LyXText::insertInset(InsetOld * inset)
|
|||||||
{
|
{
|
||||||
if (!cursorPar()->insetAllowed(inset->lyxCode()))
|
if (!cursorPar()->insetAllowed(inset->lyxCode()))
|
||||||
return;
|
return;
|
||||||
recordUndo(bv(), Undo::ATOMIC, cursorPar());
|
recUndo(cursor.par());
|
||||||
freezeUndo();
|
freezeUndo();
|
||||||
cursorPar()->insertInset(cursor.pos(), inset);
|
cursorPar()->insertInset(cursor.pos(), inset);
|
||||||
// Just to rebreak and refresh correctly.
|
// Just to rebreak and refresh correctly.
|
||||||
@ -1175,8 +1174,7 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
|||||||
++endpit;
|
++endpit;
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv(), Undo::DELETE, getPar(selection.start),
|
recUndo(selection.start.par(), parOffset(undoendpit) - 1);
|
||||||
boost::prior(undoendpit));
|
|
||||||
|
|
||||||
endpit = getPar(selection.end.par());
|
endpit = getPar(selection.end.par());
|
||||||
int endpos = selection.end.pos();
|
int endpos = selection.end.pos();
|
||||||
@ -1246,7 +1244,7 @@ void LyXText::pasteSelection(size_t sel_index)
|
|||||||
if (!CutAndPaste::checkPastePossible())
|
if (!CutAndPaste::checkPastePossible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
recordUndo(bv(), Undo::INSERT, cursorPar());
|
recUndo(cursor.par());
|
||||||
|
|
||||||
ParagraphList::iterator endpit;
|
ParagraphList::iterator endpit;
|
||||||
PitPosPair ppp;
|
PitPosPair ppp;
|
||||||
@ -1289,7 +1287,7 @@ void LyXText::setSelectionRange(lyx::pos_type length)
|
|||||||
// simple replacing. The font of the first selected character is used
|
// simple replacing. The font of the first selected character is used
|
||||||
void LyXText::replaceSelectionWithString(string const & str)
|
void LyXText::replaceSelectionWithString(string const & str)
|
||||||
{
|
{
|
||||||
recordUndo(bv(), Undo::ATOMIC);
|
recUndo(cursor.par());
|
||||||
freezeUndo();
|
freezeUndo();
|
||||||
|
|
||||||
if (!selection.set()) { // create a dummy selection
|
if (!selection.set()) { // create a dummy selection
|
||||||
@ -1325,7 +1323,7 @@ void LyXText::insertStringAsLines(string const & str)
|
|||||||
pos_type pos = cursor.pos();
|
pos_type pos = cursor.pos();
|
||||||
ParagraphList::iterator endpit = boost::next(cursorPar());
|
ParagraphList::iterator endpit = boost::next(cursorPar());
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC);
|
recUndo(cursor.par());
|
||||||
|
|
||||||
// only to be sure, should not be neccessary
|
// only to be sure, should not be neccessary
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@ -1905,7 +1903,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
|||||||
while (endpit != ownerParagraphs().end() && endpit->getDepth())
|
while (endpit != ownerParagraphs().end() && endpit->getDepth())
|
||||||
++endpit;
|
++endpit;
|
||||||
|
|
||||||
recordUndo(bv(), Undo::DELETE, old_pit, boost::prior(endpit));
|
recUndo(parOffset(old_pit), parOffset(endpit) - 1);
|
||||||
cursor = tmpcursor;
|
cursor = tmpcursor;
|
||||||
|
|
||||||
// delete old par
|
// delete old par
|
||||||
@ -1938,6 +1936,18 @@ ParagraphList & LyXText::ownerParagraphs() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LyXText::recUndo(paroffset_type first, paroffset_type last) const
|
||||||
|
{
|
||||||
|
recordUndo(bv(), Undo::ATOMIC, ownerParagraphs(), first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LyXText::recUndo(lyx::paroffset_type par) const
|
||||||
|
{
|
||||||
|
recordUndo(bv(), Undo::ATOMIC, ownerParagraphs(), par, par);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXText::isInInset() const
|
bool LyXText::isInInset() const
|
||||||
{
|
{
|
||||||
// Sub-level has non-null bv owner and non-null inset owner.
|
// Sub-level has non-null bv owner and non-null inset owner.
|
||||||
|
@ -412,14 +412,14 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
for (; tmp != end; ++tmp) {
|
for (; tmp != end; ++tmp) {
|
||||||
if (tmp->params().startOfAppendix()) {
|
if (tmp->params().startOfAppendix()) {
|
||||||
recordUndo(bv, Undo::ATOMIC, tmp);
|
recUndo(parOffset(tmp));
|
||||||
tmp->params().startOfAppendix(false);
|
tmp->params().startOfAppendix(false);
|
||||||
redoParagraph(tmp);
|
redoParagraph(tmp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv, Undo::ATOMIC, pit);
|
recUndo(parOffset(pit));
|
||||||
pit->params().startOfAppendix(start);
|
pit->params().startOfAppendix(start);
|
||||||
|
|
||||||
// we can set the refreshing parameters now
|
// we can set the refreshing parameters now
|
||||||
@ -964,7 +964,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_TRANSPOSE_CHARS:
|
case LFUN_TRANSPOSE_CHARS:
|
||||||
recordUndo(bv, Undo::ATOMIC, cursorPar());
|
recUndo(cursor.par());
|
||||||
redoParagraph();
|
redoParagraph();
|
||||||
bv->update();
|
bv->update();
|
||||||
break;
|
break;
|
||||||
@ -1434,7 +1434,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
// ...or maybe the recordUndo()
|
// ...or maybe the recordUndo()
|
||||||
// below isn't necessary at all anylonger?
|
// below isn't necessary at all anylonger?
|
||||||
if (inset_hit->lyxCode() == InsetOld::REF_CODE)
|
if (inset_hit->lyxCode() == InsetOld::REF_CODE)
|
||||||
recordUndo(bv, Undo::ATOMIC);
|
recUndo(cursor.par());
|
||||||
|
|
||||||
bv->owner()->message(inset_hit->editMessage());
|
bv->owner()->message(inset_hit->editMessage());
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "undo_funcs.h"
|
#include "undo_funcs.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "debug.h"
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "iterators.h"
|
#include "iterators.h"
|
||||||
@ -25,8 +26,13 @@
|
|||||||
|
|
||||||
#include "insets/updatableinset.h"
|
#include "insets/updatableinset.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
/// The flag used by FinishUndo().
|
using std::endl;
|
||||||
|
using lyx::paroffset_type;
|
||||||
|
|
||||||
|
|
||||||
|
/// The flag used by finishUndo().
|
||||||
bool undo_finished;
|
bool undo_finished;
|
||||||
|
|
||||||
/// Whether actions are not added to the undo stacks.
|
/// Whether actions are not added to the undo stacks.
|
||||||
@ -36,18 +42,22 @@ namespace {
|
|||||||
|
|
||||||
|
|
||||||
void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
||||||
ParagraphList::iterator first, ParagraphList::iterator last,
|
ParagraphList & plist, paroffset_type firstpar, paroffset_type lastpar,
|
||||||
limited_stack<Undo> & stack)
|
limited_stack<Undo> & stack)
|
||||||
{
|
{
|
||||||
Buffer * buf = bv->buffer();
|
Buffer * buf = bv->buffer();
|
||||||
|
|
||||||
|
ParagraphList::iterator first = plist.begin();
|
||||||
|
advance(first, firstpar);
|
||||||
|
ParagraphList::iterator last = plist.begin();
|
||||||
|
advance(last, lastpar);
|
||||||
|
|
||||||
// First, record inset id, if cursor is in one
|
// First, record inset id, if cursor is in one
|
||||||
UpdatableInset * inset = first->inInset();
|
UpdatableInset * inset = first->inInset();
|
||||||
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
||||||
int const inset_id = inset ? inset->id() : -1;
|
int const inset_id = inset ? inset->id() : -1;
|
||||||
|
|
||||||
// We simply record the entire outer paragraphs
|
// We simply record the entire outer paragraphs
|
||||||
ParagraphList & plist = buf->paragraphs();
|
|
||||||
ParIterator null = buf->par_iterator_end();
|
ParIterator null = buf->par_iterator_end();
|
||||||
|
|
||||||
// First, identify the outer paragraphs
|
// First, identify the outer paragraphs
|
||||||
@ -59,8 +69,8 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// And calculate a stable reference to them
|
// And calculate a stable reference to them
|
||||||
int const first_offset = std::distance(plist.begin(), first);
|
int const first_offset = firstpar;
|
||||||
int const last_offset = std::distance(last, plist.end());
|
int const last_offset = plist.size() - lastpar;
|
||||||
|
|
||||||
// Undo::ATOMIC are always recorded (no overlapping there).
|
// Undo::ATOMIC are always recorded (no overlapping there).
|
||||||
|
|
||||||
@ -87,6 +97,7 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
|||||||
cursor_offset, text->cursor.pos(),
|
cursor_offset, text->cursor.pos(),
|
||||||
ParagraphList()));
|
ParagraphList()));
|
||||||
|
|
||||||
|
lyxerr << "G" << endl;
|
||||||
// Record the relevant paragraphs
|
// Record the relevant paragraphs
|
||||||
ParagraphList & undo_pars = stack.top().pars;
|
ParagraphList & undo_pars = stack.top().pars;
|
||||||
|
|
||||||
@ -103,7 +114,7 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
|||||||
|
|
||||||
|
|
||||||
// Returns false if no undo possible.
|
// Returns false if no undo possible.
|
||||||
bool performUndoOrRedo(BufferView * bv, Undo & undo)
|
bool performUndoOrRedo(BufferView * bv, Undo const & undo)
|
||||||
{
|
{
|
||||||
Buffer * buf = bv->buffer();
|
Buffer * buf = bv->buffer();
|
||||||
ParagraphList & plist = buf->paragraphs();
|
ParagraphList & plist = buf->paragraphs();
|
||||||
@ -141,9 +152,16 @@ bool performUndoOrRedo(BufferView * bv, Undo & undo)
|
|||||||
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
||||||
text->setCursorIntern(undo.cursor_par_offset, undo.cursor_pos);
|
text->setCursorIntern(undo.cursor_par_offset, undo.cursor_pos);
|
||||||
|
|
||||||
|
lyxerr << "undo, inset: " << inset << endl;
|
||||||
|
|
||||||
if (inset) {
|
if (inset) {
|
||||||
|
lyxerr << "undo, inset owner: " << inset->owner() << endl;
|
||||||
|
|
||||||
// Magic needed to update inset internal state
|
// Magic needed to update inset internal state
|
||||||
FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
|
FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
|
||||||
|
if (inset->owner())
|
||||||
|
inset->owner()->localDispatch(cmd);
|
||||||
|
else
|
||||||
inset->localDispatch(cmd);
|
inset->localDispatch(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,24 +265,23 @@ bool textRedo(BufferView * bv)
|
|||||||
|
|
||||||
|
|
||||||
void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
||||||
ParagraphList::iterator first, ParagraphList::iterator last)
|
ParagraphList & plist, paroffset_type first, paroffset_type last)
|
||||||
{
|
{
|
||||||
if (!undo_frozen) {
|
if (!undo_frozen) {
|
||||||
recordUndo(bv, kind, first, last, bv->buffer()->undostack());
|
recordUndo(bv, kind, plist, first, last, bv->buffer()->undostack());
|
||||||
bv->buffer()->redostack().clear();
|
bv->buffer()->redostack().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
||||||
ParagraphList::iterator first)
|
ParagraphList & plist, paroffset_type par)
|
||||||
{
|
{
|
||||||
recordUndo(bv, kind, first, first);
|
recordUndo(bv, kind, plist, par, par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void recordUndo(BufferView * bv, Undo::undo_kind kind)
|
void recordUndo(BufferView * bv, Undo::undo_kind kind)
|
||||||
{
|
{
|
||||||
recordUndo(bv, kind, bv->text->cursorPar());
|
recordUndo(bv, kind, bv->text->ownerParagraphs(), bv->text->cursor.par());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "undo.h"
|
#include "undo.h"
|
||||||
#include "ParagraphList_fwd.h"
|
#include "ParagraphList_fwd.h"
|
||||||
|
#include "support/types.h"
|
||||||
|
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class Paragraph;
|
class Paragraph;
|
||||||
@ -48,10 +49,11 @@ void unFreezeUndo();
|
|||||||
* will record the original information of the paragraphs in the undo stack.
|
* will record the original information of the paragraphs in the undo stack.
|
||||||
*/
|
*/
|
||||||
void recordUndo(BufferView *, Undo::undo_kind kind,
|
void recordUndo(BufferView *, Undo::undo_kind kind,
|
||||||
ParagraphList::iterator first, ParagraphList::iterator last);
|
ParagraphList & plist, lyx::paroffset_type first, lyx::paroffset_type last);
|
||||||
|
|
||||||
/// Convienience: Prepare undo when change in a single paragraph.
|
/// Convienience: Prepare undo when change in a single paragraph.
|
||||||
void recordUndo(BufferView *, Undo::undo_kind kind,
|
void recordUndo(BufferView *, Undo::undo_kind kind,
|
||||||
ParagraphList::iterator first);
|
ParagraphList & plist, lyx::paroffset_type par);
|
||||||
|
|
||||||
/// Convienience: Prepare undo for the paragraph that contains the cursor
|
/// Convienience: Prepare undo for the paragraph that contains the cursor
|
||||||
void recordUndo(BufferView *, Undo::undo_kind kind);
|
void recordUndo(BufferView *, Undo::undo_kind kind);
|
||||||
|
Loading…
Reference in New Issue
Block a user