trade a few cycles for a clearer interface

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)
? .lyxtext.h.swp
? 1.diff
? insets/1.diff
Index: BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.172
diff -u -p -r1.172 BufferView.C
--- BufferView.C        28 Jul 2003 23:53:34 -0000      1.172
+++ BufferView.C        1 Aug 2003 11:11:01 -0000
@@ -625,8 +625,7 @@ bool BufferView::ChangeInsets(InsetOld::
                        // How to set the cursor corretly when it.size()>1 ??
                        if (it.size() == 1) {
                                text->setCursorIntern(it.pit(), 0);
-                               text->redoParagraphs(text->cursor,
-                                                    boost::next(text->cursor.par()));
+                               text->redoParagraph(text->cursor.par());
                                text->partialRebreak();
                        }
                }
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.202
diff -u -p -r1.202 lyxtext.h
--- lyxtext.h   31 Jul 2003 14:07:59 -0000      1.202
+++ lyxtext.h   1 Aug 2003 11:11:01 -0000
@@ -131,15 +131,15 @@ public:
          */
        void setFont(LyXFont const &, bool toggleall = false);
 
-       /** deletes and inserts again all paragaphs between the cursor
-         and the specified par. The Cursor is needed to set the refreshing
-         parameters.
-         This function is needed after SetLayout and SetFont etc.
-         */
-       void redoParagraphs(LyXCursor const & cursor,
-                           ParagraphList::iterator endpit);
-       ///
+       /// rebreaks all paragaphs between the given pars.
+       void redoParagraphs(ParagraphList::iterator begin,
+                           ParagraphList::iterator end);
+       /// rebreaks the given par
+       void redoParagraph(ParagraphList::iterator pit);
+       /// rebreaks the cursor par
        void redoParagraph();
+       /// returns first row belongin to some par
+       RowList::iterator firstRow(ParagraphList::iterator pit);
 
        ///
        void toggleFree(LyXFont const &, bool toggleall = false);
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.401
diff -u -p -r1.401 text.C
--- text.C      31 Jul 2003 14:07:59 -0000      1.401
+++ text.C      1 Aug 2003 11:11:01 -0000
@@ -1579,7 +1579,7 @@ void LyXText::breakParagraph(ParagraphLi
 void LyXText::redoParagraph()
 {
        clearSelection();
-       redoParagraphs(cursor, boost::next(cursor.par()));
+       redoParagraph(cursor.par());
        setCursorIntern(cursor.par(), cursor.pos());
 }
 
@@ -2007,7 +2007,7 @@ void LyXText::acceptChange()
                startc.par()->acceptChange(startc.pos(), endc.pos());
                finishUndo();
                clearSelection();
-               redoParagraphs(startc, boost::next(startc.par()));
+               redoParagraph(startc.par());
                setCursorIntern(startc.par(), 0);
        }
 #warning handle multi par selection
@@ -2026,7 +2026,7 @@ void LyXText::rejectChange()
                startc.par()->rejectChange(startc.pos(), endc.pos());
                finishUndo();
                clearSelection();
-               redoParagraphs(startc, boost::next(startc.par()));
+               redoParagraph(startc.par());
                setCursorIntern(startc.par(), 0);
        }
 #warning handle multi par selection
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.407
diff -u -p -r1.407 text2.C
--- text2.C     31 Jul 2003 13:38:06 -0000      1.407
+++ text2.C     1 Aug 2003 11:11:01 -0000
@@ -443,7 +443,7 @@ void LyXText::setLayout(string const & l
 
        ParagraphList::iterator endpit = setLayout(cursor, selection.start,
                                                   selection.end, layout);
-       redoParagraphs(selection.start, endpit);
+       redoParagraphs(selection.start.par(), endpit);
 
        // we have to reset the selection, because the
        // geometry could have changed
@@ -511,15 +511,12 @@ bool LyXText::changeDepth(bv_funcs::DEPT
        if (test_only)
                return changed;
 
-       // Wow, redoParagraphs is stupid.
-       LyXCursor tmpcursor;
-       setCursor(tmpcursor, start, 0);
 
-       redoParagraphs(tmpcursor, pastend);
+       redoParagraphs(start, pastend);
 
        // We need to actually move the text->cursor. I don't
        // understand why ...
-       tmpcursor = cursor;
+       LyXCursor tmpcursor = cursor;
 
        // we have to reset the visual selection because the
        // geometry could have changed
@@ -589,7 +586,7 @@ void LyXText::setFont(LyXFont const & fo
        }
        unFreezeUndo();
 
-       redoParagraphs(selection.start, boost::next(selection.end.par()));
+       redoParagraph(selection.start.par());
 
        // we have to reset the selection, because the
        // geometry could have changed, but we keep
@@ -621,17 +618,31 @@ void LyXText::redoHeightOfParagraph()
 }
 
 
-// deletes and inserts again all paragraphs between the cursor
-// and the specified par
+RowList::iterator LyXText::firstRow(ParagraphList::iterator pit)
+{
+       RowList::iterator rit;
+       for (rit = rows().begin(); rit != rows().end(); ++rit)
+               if (rit->par() == pit)
+                       break;
+       return rit;
+}
+
+
+// rebreaks all paragraphs between the specified pars
 // This function is needed after SetLayout and SetFont etc.
-void LyXText::redoParagraphs(LyXCursor const & cur,
-                            ParagraphList::iterator endpit)
+void LyXText::redoParagraphs(ParagraphList::iterator start,
+  ParagraphList::iterator endpit)
 {
-       RowList::iterator tmprit = getRow(cur);
+       RowList::iterator rit = firstRow(start);
+
+       if (rit == rows().end()) {
+               lyxerr << "LyXText::redoParagraphs: should not happen\n";
+               Assert(0);
+       }
 
        ParagraphList::iterator first_phys_pit;
        RowList::iterator prevrit;
-       if (tmprit == rows().begin()) {
+       if (rit == rows().begin()) {
                // A trick/hack for UNDO.
                // This is needed because in an UNDO/REDO we could have
                // changed the ownerParagraph() so the paragraph inside
@@ -640,30 +651,28 @@ void LyXText::redoParagraphs(LyXCursor c
                first_phys_pit = ownerParagraphs().begin();
                prevrit = rows().end();
        } else {
-               first_phys_pit = tmprit->par();
-               while (tmprit != rows().begin()
-                      && boost::prior(tmprit)->par() == first_phys_pit)
+               first_phys_pit = rit->par();
+               while (rit != rows().begin()
+                      && boost::prior(rit)->par() == first_phys_pit)
                {
-                       --tmprit;
+                       --rit;
                }
-               prevrit = boost::prior(tmprit);
+               prevrit = boost::prior(rit);
        }
 
        // remove it
-       while (tmprit != rows().end() && tmprit->par() != endpit) {
-               RowList::iterator tmprit2 = tmprit++;
-               removeRow(tmprit2);
+       while (rit != rows().end() && rit->par() != endpit) {
+               RowList::iterator rit2 = rit++;
+               removeRow(rit2);
        }
 
        // Reinsert the paragraphs.
        ParagraphList::iterator tmppit = first_phys_pit;
 
        while (tmppit != ownerParagraphs().end()) {
-               insertParagraph(tmppit, tmprit);
-               while (tmprit != rows().end()
-                      && tmprit->par() == tmppit) {
-                       ++tmprit;
-               }
+               insertParagraph(tmppit, rit);
+               while (rit != rows().end() && rit->par() == tmppit)
+                       ++rit;
                ++tmppit;
                if (tmppit == endpit)
                        break;
@@ -673,13 +682,19 @@ void LyXText::redoParagraphs(LyXCursor c
        else
                setHeightOfRow(rows().begin());
        postPaint();
-       if (tmprit != rows().end())
-               setHeightOfRow(tmprit);
+       if (rit != rows().end())
+               setHeightOfRow(rit);
 
        updateCounters();
 }
 
 
+void LyXText::redoParagraph(ParagraphList::iterator pit)
+{
+       redoParagraphs(pit, boost::next(pit));
+}
+
+
 void LyXText::fullRebreak()
 {
        init(bv());
@@ -948,7 +963,7 @@ void LyXText::setParagraph(bool line_top
        }
        postPaint();
 
-       redoParagraphs(selection.start, endpit);
+       redoParagraphs(selection.start.par(), endpit);
 
        clearSelection();
        setCursor(selection.start.par(), selection.start.pos());
@@ -1279,7 +1294,7 @@ void LyXText::cutSelection(bool doclear,
        if (doclear)
                selection.start.par()->stripLeadingSpaces();
 
-       redoParagraphs(selection.start, boost::next(endpit));
+       redoParagraphs(selection.start.par(), boost::next(endpit));
 #warning FIXME latent bug
        // endpit will be invalidated on redoParagraphs once ParagraphList
        // becomes a std::list? There are maybe other places on which this
@@ -1347,7 +1362,7 @@ void LyXText::pasteSelection(size_t sel_
        bufferErrors(*bv()->buffer(), el);
        bv()->showErrorList(_("Paste"));
 
-       redoParagraphs(cursor, endpit);
+       redoParagraphs(cursor.par(), endpit);
 
        setCursor(cursor.par(), cursor.pos());
        clearSelection();
@@ -1417,7 +1432,7 @@ void LyXText::insertStringAsLines(string
 
        bv()->buffer()->insertStringAsLines(pit, pos, current_font, str);
 
-       redoParagraphs(cursor, endpit);
+       redoParagraphs(cursor.par(), endpit);
        setCursor(cursor.par(), cursor.pos());
        selection.cursor = cursor;
        setCursor(pit, pos);
@@ -2067,7 +2082,7 @@ bool LyXText::deleteEmptyParagraphMechan
                    && old_cursor.par()->isLineSeparator(old_cursor.pos())
                    && old_cursor.par()->isLineSeparator(old_cursor.pos() - 1)) {
                        old_cursor.par()->erase(old_cursor.pos() - 1);
-                       redoParagraphs(old_cursor, boost::next(old_cursor.par()));
+                       redoParagraph(old_cursor.par());
 
 #ifdef WITH_WARNINGS
 #warning This will not work anymore when we have multiple views of the same buffer
@@ -2185,7 +2200,7 @@ bool LyXText::deleteEmptyParagraphMechan
        }
        if (!deleted) {
                if (old_cursor.par()->stripLeadingSpaces()) {
-                       redoParagraphs(old_cursor, boost::next(old_cursor.par()));
+                       redoParagraph(old_cursor.par());
                        // correct cursor y
                        setCursorIntern(cursor.par(), cursor.pos());
                        selection.cursor = cursor;
Index: insets/insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.159
diff -u -p -r1.159 insetcollapsable.C
--- insets/insetcollapsable.C   31 Jul 2003 10:48:50 -0000      1.159
+++ insets/insetcollapsable.C   1 Aug 2003 11:11:02 -0000
@@ -289,8 +289,8 @@ bool InsetCollapsable::hitButton(FuncReq
 
 InsetOld::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
 {
-       lyxerr << "InsetCollapsable::localDispatch: "
-               << cmd.action << " '" << cmd.argument << "'\n";
+       //lyxerr << "InsetCollapsable::localDispatch: "
+       //      << cmd.action << " '" << cmd.argument << "'\n";
        BufferView * bv = cmd.view();
        switch (cmd.action) {
                case LFUN_INSET_EDIT: {

Reply via email to