]> git.lyx.org Git - lyx.git/commitdiff
require BufferView argument in ParIterator::text
authorAlfredo Braunstein <abraunst@lyx.org>
Wed, 5 Nov 2003 11:17:11 +0000 (11:17 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Wed, 5 Nov 2003 11:17:11 +0000 (11:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8045 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/bufferview_funcs.C
src/iterators.C
src/iterators.h
src/lyxfunc.C
src/undo.C

index 9b375987ae1dc22380912b797417bb696604e99d..cd98cdcac8d226d02e3f7c0158dfe27da9efffa1 100644 (file)
@@ -1,3 +1,10 @@
+2003-11-05  Alfredo Braunstein  <abraunst@libero.it>
+
+       * 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  <assirati@fma.if.usp.br>
 
        * lyxsocket.C: export variables XEDITOR and LYXSOCKET
index 3c2738ace22f075719ea17a7271d99b8b882dce4..a2f1b8f328d93433342a0a822c915c91b0f664f7 100644 (file)
@@ -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());
index 6240fd82aae51d6b26b0e02ad61cf53836e534be..2eccf985a58aedb0bd2146c89d38d202839c1847 100644 (file)
@@ -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);
index b705a4a1298886edcc83a96a738a33bac35ed74d..1f23dbf494a88bd87406a2983ec8a75269e9a88f 100644 (file)
@@ -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
index 415b4192bbc6e61479f4efcec091e66d6568e171..1cf0de8c676e918f268d41ae7ace3541cfdfaf3e 100644 (file)
@@ -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);
index e62cb065246e5c4608454673d54035bd089c7505..44166bca4ccb497edffbe4da28256e7ab7418a56 100644 (file)
@@ -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<Undo> & 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;