From 267a040d10327373c171c328799f09242d8bf9e9 Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Wed, 5 Nov 2003 11:17:11 +0000 Subject: [PATCH] require BufferView argument in ParIterator::text git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8045 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 7 +++++++ src/bufferview_funcs.C | 3 +-- src/iterators.C | 4 ++-- src/iterators.h | 2 +- src/lyxfunc.C | 2 +- src/undo.C | 22 +++++----------------- 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 9b375987ae..cd98cdcac8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2003-11-05 Alfredo Braunstein + + * iterators.[Ch] (text): require bv argument + * undo.C (recordUndo): + * lyxfunc.C (dispatch): + * bufferview_funcs.C (put_selection_at): adjust + 2003-11-05 João Luis M. Assirati * lyxsocket.C: export variables XEDITOR and LYXSOCKET diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 3c2738ace2..a2f1b8f328 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -434,8 +434,7 @@ void put_selection_at(BufferView * bv, PosIterator const & cur, bv->getLyXText()->clearSelection(); - LyXText * text = par.text() ? par.text() : bv->text; - + LyXText * text = par.text(bv); par.lockPath(bv); text->setCursor(cur.pit(), cur.pos()); diff --git a/src/iterators.C b/src/iterators.C index 6240fd82aa..2eccf985a5 100644 --- a/src/iterators.C +++ b/src/iterators.C @@ -149,11 +149,11 @@ ParIterator & ParIterator::operator++() } -LyXText * ParIterator::text() const +LyXText * ParIterator::text(BufferView * bv) const { //lyxerr << "positions.size: " << pimpl_->positions.size() << std::endl; if (pimpl_->positions.size() <= 1) - return 0; + return bv->text; ParPosition const & pos = pimpl_->positions[pimpl_->positions.size() - 2]; return (*pos.it)->inset->getText(*pos.index); diff --git a/src/iterators.h b/src/iterators.h index b705a4a129..1f23dbf494 100644 --- a/src/iterators.h +++ b/src/iterators.h @@ -48,7 +48,7 @@ public: ParagraphList & plist() const; /// returns 'innermost' LyXText if in an inset or '0' instead of //bv->text - LyXText * text() const; + LyXText * text(BufferView *) const; /// returns innermost inset InsetOld * inset() const; /// returns index of cell in innermost inset diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 415b4192bb..1cf0de8c67 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1406,7 +1406,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) par.lockPath(view()); - LyXText * lt = par.text() ? par.text() : view()->text; + LyXText * lt = par.text(view()); // Set the cursor lt->setCursor(par.pit(), 0); diff --git a/src/undo.C b/src/undo.C index e62cb06524..44166bca4c 100644 --- a/src/undo.C +++ b/src/undo.C @@ -61,19 +61,15 @@ std::ostream & operator<<(std::ostream & os, Undo const & undo) // translates LyXText pointer into offset count from document begin -ParIterator text2pit(LyXText * text, int & tcount) +ParIterator text2pit(BufferView * bv, LyXText * text, int & tcount) { tcount = 0; Buffer * buf = text->bv()->buffer(); ParIterator pit = buf->par_iterator_begin(); ParIterator end = buf->par_iterator_end(); - // it.text() returns 0 for outermost text. - if (text == text->bv()->text) - return pit; - for ( ; pit != end; ++pit, ++tcount) - if (pit.text() == text) + if (pit.text(bv) == text) return pit; lyxerr << "undo: should not happen" << std::endl; return end; @@ -100,14 +96,6 @@ ParIterator num2pit(BufferView * bv, int num) } -// translates offset from buffer begin to LyXText -LyXText * pit2text(BufferView * bv, ParIterator const & pit) -{ - LyXText * text = pit.text(); - return text ? text : bv->text; -} - - void recordUndo(Undo::undo_kind kind, LyXText * text, paroffset_type first_par, paroffset_type last_par, limited_stack & stack) @@ -133,7 +121,7 @@ void recordUndo(Undo::undo_kind kind, // make and push the Undo entry int textnum; - ParIterator pit = text2pit(text, textnum); + ParIterator pit = text2pit(text->bv(), text, textnum); stack.push(Undo(kind, textnum, pit.index(), first_par, end_par, text->cursor.par(), text->cursor.pos())); lyxerr << "undo record: " << stack.top() << std::endl; @@ -161,7 +149,7 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo) { lyxerr << "undo, performing: " << undo << std::endl; ParIterator pit = num2pit(bv, undo.text); - LyXText * text = pit2text(bv, pit); + LyXText * text = pit.text(bv); ParagraphList & plist = text->ownerParagraphs(); // remove new stuff between first and last @@ -238,7 +226,7 @@ bool textUndoOrRedo(BufferView * bv, advance(last, plist.size() - undo.end_par + 1); otherstack.top().pars.insert(otherstack.top().pars.begin(), first, last); } - LyXText * text = pit2text(bv, pit); + LyXText * text = pit.text(bv); otherstack.top().cursor_pos = text->cursor.pos(); otherstack.top().cursor_par = text->cursor.par(); lyxerr << " undo other: " << otherstack.top() << std::endl; -- 2.39.2