mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
preparations to regain ability of per-inset undo.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7911 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
45a8d5a93a
commit
b79331e005
@ -15,12 +15,14 @@
|
||||
#include "paragraph.h"
|
||||
|
||||
Undo::Undo(undo_kind kind_arg, int inset,
|
||||
int plist_arg,
|
||||
int first, int last,
|
||||
int cursor, int cursor_pos_arg,
|
||||
ParagraphList const & par)
|
||||
:
|
||||
kind(kind_arg),
|
||||
inset_id(inset),
|
||||
plist(plist_arg),
|
||||
first_par_offset(first),
|
||||
last_par_offset(last),
|
||||
cursor_par_offset(cursor),
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
};
|
||||
///
|
||||
Undo(undo_kind kind, int inset_id,
|
||||
int plist,
|
||||
int first, int last,
|
||||
int cursor, int cursor_pos,
|
||||
ParagraphList const & par_arg);
|
||||
@ -52,6 +53,9 @@ public:
|
||||
/// Which kind of operation are we recording for?
|
||||
undo_kind kind;
|
||||
|
||||
/// to what paragraph list do we belong?
|
||||
int plist;
|
||||
|
||||
/**
|
||||
* ID of hosting inset if the cursor is in one.
|
||||
* if -1, then the cursor is not in an inset.
|
||||
|
@ -57,9 +57,16 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
||||
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
||||
int const inset_id = inset ? inset->id() : -1;
|
||||
|
||||
// We simply record the entire outer paragraphs
|
||||
// Try to find the appropriate list by counting the,
|
||||
ParIterator null = buf->par_iterator_end();
|
||||
|
||||
int pcount = 0;
|
||||
for (ParIterator it = buf->par_iterator_begin(); it != null; ++it, ++pcount)
|
||||
if (&it.plist() == &plist)
|
||||
break;
|
||||
//lyxerr << "This is plist #" << pcount << ' ' << &plist << endl;
|
||||
|
||||
// We simply record the entire outer paragraphs
|
||||
// First, identify the outer paragraphs
|
||||
for (ParIterator it = buf->par_iterator_begin(); it != null; ++it) {
|
||||
if (it->id() == first->id())
|
||||
@ -93,11 +100,11 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
||||
|
||||
// Make and push the Undo entry
|
||||
stack.push(Undo(kind, inset_id,
|
||||
pcount,
|
||||
first_offset, last_offset,
|
||||
cursor_offset, text->cursor.pos(),
|
||||
ParagraphList()));
|
||||
|
||||
lyxerr << "G" << endl;
|
||||
// Record the relevant paragraphs
|
||||
ParagraphList & undo_pars = stack.top().pars;
|
||||
|
||||
@ -119,6 +126,13 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
|
||||
Buffer * buf = bv->buffer();
|
||||
ParagraphList & plist = buf->paragraphs();
|
||||
|
||||
ParIterator null = buf->par_iterator_end();
|
||||
ParIterator plit = buf->par_iterator_begin();
|
||||
int n = undo.plist;
|
||||
for ( ; n && plit != null; ++plit, --n)
|
||||
;
|
||||
//lyxerr << "undo: using plist #" << undo.plist << " " << &plit.plist() << endl;
|
||||
|
||||
// Remove new stuff between first and last
|
||||
{
|
||||
ParagraphList::iterator first = plist.begin();
|
||||
@ -152,10 +166,10 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
|
||||
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
||||
text->setCursorIntern(undo.cursor_par_offset, undo.cursor_pos);
|
||||
|
||||
lyxerr << "undo, inset: " << inset << endl;
|
||||
//lyxerr << "undo, inset: " << inset << endl;
|
||||
|
||||
if (inset) {
|
||||
lyxerr << "undo, inset owner: " << inset->owner() << endl;
|
||||
//lyxerr << "undo, inset owner: " << inset->owner() << endl;
|
||||
|
||||
// Magic needed to update inset internal state
|
||||
FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
|
||||
|
Loading…
Reference in New Issue
Block a user