This 

- removes the remaining black magic from InsetText
(reinitLyXText, saveLyXTextState, restoreLyXTextState, resizeLyXText, sstate)
So only InsetTabular is left.

- handles some of the InsetText::init() issues in setViewCache()

- combines a couple of update() calls

and a few other things including adjusting a few not-so-up-to-date
comments.

450 lines gone...

Andre'

-- 
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...)
? 1.diff
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.410
diff -u -p -r1.410 BufferView_pimpl.C
--- BufferView_pimpl.C  5 Aug 2003 19:51:44 -0000       1.410
+++ BufferView_pimpl.C  11 Aug 2003 08:23:40 -0000
@@ -29,7 +29,6 @@
 #include "lyxfunc.h"
 #include "lyxtext.h"
 #include "lyxrc.h"
-#include "lyxrow.h"
 #include "lastfiles.h"
 #include "paragraph.h"
 #include "ParagraphParameters.h"
@@ -371,7 +370,7 @@ void BufferView::Pimpl::redoCurrentBuffe
 }
 
 
-int BufferView::Pimpl::resizeCurrentBuffer()
+void BufferView::Pimpl::resizeCurrentBuffer()
 {
        lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
 
@@ -400,7 +399,6 @@ int BufferView::Pimpl::resizeCurrentBuff
                selection = bv_->text->selection.set();
                mark_set = bv_->text->selection.mark();
                the_locking_inset = bv_->theLockingInset();
-               resizeInsets(bv_);
                bv_->text->fullRebreak();
                update();
        } else {
@@ -418,12 +416,9 @@ int BufferView::Pimpl::resizeCurrentBuff
                        //      bv_->text->owner(bv_);
                        if (lyxerr.debugging())
                                textcache.show(lyxerr, "resizeCurrentBuffer");
-
-                       resizeInsets(bv_);
                } else {
                        lyxerr << "no text in cache!" << endl;
                        bv_->text = new LyXText(bv_);
-                       resizeInsets(bv_);
                        bv_->text->init(bv_);
                }
 
@@ -461,8 +456,6 @@ int BufferView::Pimpl::resizeCurrentBuff
        owner_->clearMessage();
 
        updateScrollbar();
-
-       return 0;
 }
 
 
@@ -617,13 +610,6 @@ void BufferView::Pimpl::workAreaResize()
                        if (lyxerr.debugging())
                                textcache.show(lyxerr, "Expose delete all");
                        textcache.clear();
-                       // FIXME: this is already done in resizeCurrentBuffer() ??
-                       resizeInsets(bv_);
-               } else if (heightChange) {
-                       // fitCursor() ensures we don't jump back
-                       // to the start of the document on vertical
-                       // resize
-                       fitCursor();
                }
        }
 
@@ -633,13 +619,18 @@ void BufferView::Pimpl::workAreaResize()
        // always make sure that the scrollbar is sane.
        updateScrollbar();
        owner_->updateLayoutChoice();
-       return;
 }
 
 
 void BufferView::Pimpl::update()
 {
        lyxerr << "BufferView::update()" << endl;
+       // fix cursor coordinate cache in case something went wrong
+       if (bv_->getLyXText()) {
+               // check needed to survive LyX startup
+               bv_->getLyXText()->redoCursor();
+               fitCursor();
+       }
        screen().redraw(*bv_);
 }
 
@@ -1389,6 +1378,7 @@ void BufferView::Pimpl::updateInset()
 
        // this should not be needed, but it is...
        bv_->text->redoParagraph(bv_->text->cursor.par());
+
        update();
        updateScrollbar();
 }
Index: BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.98
diff -u -p -r1.98 BufferView_pimpl.h
--- BufferView_pimpl.h  5 Aug 2003 08:07:00 -0000       1.98
+++ BufferView_pimpl.h  11 Aug 2003 08:23:40 -0000
@@ -43,7 +43,7 @@ struct BufferView::Pimpl : public boost:
        ///
        void redoCurrentBuffer();
        ///
-       int resizeCurrentBuffer();
+       void resizeCurrentBuffer();
        ///
        void update();
        /**
Index: InsetList.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/InsetList.C,v
retrieving revision 1.6
diff -u -p -r1.6 InsetList.C
--- InsetList.C 25 Jul 2003 21:20:04 -0000      1.6
+++ InsetList.C 11 Aug 2003 08:23:40 -0000
@@ -176,18 +176,3 @@ void InsetList::deleteInsetsLyXText(Buff
                }
        }
 }
-
-
-void InsetList::resizeInsetsLyXText(BufferView * bv)
-{
-       List::iterator it = list.begin();
-       List::iterator end = list.end();
-       for (; it != end; ++it) {
-               if (it->inset) {
-                       if (it->inset->isTextInset()) {
-                               static_cast<UpdatableInset*>
-                                       (it->inset)->resizeLyXText(bv, true);
-                       }
-               }
-       }
-}
Index: InsetList.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/InsetList.h,v
retrieving revision 1.3
diff -u -p -r1.3 InsetList.h
--- InsetList.h 25 Jul 2003 21:20:04 -0000      1.3
+++ InsetList.h 11 Aug 2003 08:23:40 -0000
@@ -54,8 +54,6 @@ public:
        void decreasePosAfterPos(lyx::pos_type pos);
        ///
        void deleteInsetsLyXText(BufferView * bv);
-       ///
-       void resizeInsetsLyXText(BufferView * bv);
 private:
        ///
        List list;
Index: bufferview_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v
retrieving revision 1.89
diff -u -p -r1.89 bufferview_funcs.C
--- bufferview_funcs.C  5 Aug 2003 08:07:01 -0000       1.89
+++ bufferview_funcs.C  11 Aug 2003 08:23:40 -0000
@@ -50,16 +50,6 @@ bool toggleall(false);
 
 namespace bv_funcs {
 
-
-void resizeInsets(BufferView * bv)
-{
-       ParagraphList & paragraphs = bv->buffer()->paragraphs;
-       /// then remove all LyXText in text-insets
-       std::for_each(paragraphs.begin(), paragraphs.end(),
-                     boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
-}
-
-
 // Set data using font and toggle
 // If successful, returns true
 bool font2string(LyXFont const & font, bool toggle, string & data)
@@ -219,6 +209,7 @@ void number(BufferView * bv)
        toggleAndShow(bv, font);
 }
 
+
 void lang(BufferView * bv, string const & l)
 {
        Language const * lang = languages.getLanguage(l);
@@ -393,10 +384,6 @@ void toggleAndShow(BufferView * bv, LyXF
        }
 
        LyXText * text = bv->getLyXText();
-       // FIXME: can this happen ??
-       if (!text)
-               return;
-
        text->toggleFree(font, toggleall);
        bv->update();
 
@@ -417,9 +404,8 @@ void toggleAndShow(BufferView * bv, LyXF
 void replaceSelection(LyXText * lt)
 {
        if (lt->selection.set()) {
-               lt->update();
                lt->cutSelection(true, false);
-               lt->update();
+               lt->bv()->update();
        }
 }
 
Index: bufferview_funcs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.h,v
retrieving revision 1.20
diff -u -p -r1.20 bufferview_funcs.h
--- bufferview_funcs.h  15 Jul 2003 06:51:47 -0000      1.20
+++ bufferview_funcs.h  11 Aug 2003 08:23:40 -0000
@@ -22,8 +22,6 @@ class LyXText;
 
 namespace bv_funcs {
 
-///
-void resizeInsets(BufferView * bv);
 /** Set \param data using \param font and \param toggle.
  *  If successful, returns true.
  */
Index: factory.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/factory.C,v
retrieving revision 1.43
diff -u -p -r1.43 factory.C
--- factory.C   30 Jul 2003 13:55:44 -0000      1.43
+++ factory.C   11 Aug 2003 08:23:40 -0000
@@ -128,8 +128,7 @@ InsetOld * createInset(FuncRequest const
                if (icp.getContents().empty()) {
                        lv->getDialogs().show("index", data, 0);
                } else {
-                       FuncRequest fr(bv, LFUN_INSET_APPLY, data);
-                       lv->dispatch(fr);
+                       lv->dispatch(FuncRequest(bv, LFUN_INSET_APPLY, data));
                }
                return 0;
        }
@@ -151,8 +150,8 @@ InsetOld * createInset(FuncRequest const
                        InsetCaption * inset = new InsetCaption(params);
                        inset->setOwner(bv->theLockingInset());
                        inset->setAutoBreakRows(true);
-                       inset->setDrawFrame(0, InsetText::LOCKED);
-                       inset->setFrameColor(0, LColor::captionframe);
+                       inset->setDrawFrame(InsetText::LOCKED);
+                       inset->setFrameColor(LColor::captionframe);
                        return inset;
                }
                return 0;
Index: graph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graph.C,v
retrieving revision 1.4
diff -u -p -r1.4 graph.C
--- graph.C     23 May 2003 13:54:07 -0000      1.4
+++ graph.C     11 Aug 2003 08:23:40 -0000
@@ -20,7 +20,6 @@ using std::queue;
 using std::vector;
 
 
-
 int Graph::bfs_init(int s, bool clear_visited)
 {
        if (s < 0)
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.475
diff -u -p -r1.475 lyxfunc.C
--- lyxfunc.C   4 Aug 2003 09:06:31 -0000       1.475
+++ lyxfunc.C   11 Aug 2003 08:23:40 -0000
@@ -13,7 +13,6 @@
 #include "lyxfunc.h"
 #include "version.h"
 #include "kbmap.h"
-#include "lyxrow.h"
 #include "bufferlist.h"
 #include "buffer.h"
 #include "buffer_funcs.h"
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.207
diff -u -p -r1.207 lyxtext.h
--- lyxtext.h   8 Aug 2003 16:24:30 -0000       1.207
+++ lyxtext.h   11 Aug 2003 08:23:40 -0000
@@ -152,8 +152,6 @@ public:
        ///
        void insertInset(InsetOld * inset);
 
-       /// Completes the insertion with a rebreak
-       void partialRebreak();
        /// a full rebreak of the whole text
        void fullRebreak();
        /// compute text metrics
@@ -238,6 +236,8 @@ public:
        WordLangTuple const selectNextWordToSpellcheck(float & value);
        ///
        void selectSelectedWord();
+       /// re-computes the cached coordinates in the cursor
+       void redoCursor();
        /// returns true if par was empty and was removed
        bool setCursor(ParagraphList::iterator pit,
                       lyx::pos_type pos,
@@ -403,12 +403,6 @@ private:
        void insertParagraph(ParagraphList::iterator pit,
                             RowList::iterator rowit);
 
-       /** appends  the implizit specified paragraph behind the specified row,
-        * start at the implizit given position */
-       void appendParagraph(RowList::iterator rowit);
-
-       ///
-       void breakAgain(RowList::iterator rit);
        /// Calculate and set the height of the row
        void setHeightOfRow(RowList::iterator rit);
 
@@ -424,8 +418,6 @@ public:
        /** Updates all counters starting BEHIND the row. Changed paragraphs
         * with a dynamic left margin will be rebroken. */
        void updateCounters();
-       ///
-       void update();
        /**
         * Returns an inset if inset was hit, or 0 if not.
         * If hit, the coordinates are changed relative to the inset.
Index: paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.301
diff -u -p -r1.301 paragraph.C
--- paragraph.C 7 Aug 2003 11:59:08 -0000       1.301
+++ paragraph.C 11 Aug 2003 08:23:40 -0000
@@ -287,7 +287,8 @@ void Paragraph::insertInset(pos_type pos
 }
 
 
-void Paragraph::insertInset(pos_type pos, InsetOld * inset, LyXFont const & font, 
Change change)
+void Paragraph::insertInset(pos_type pos, InsetOld * inset,
+       LyXFont const & font, Change change)
 {
        pimpl_->insertInset(pos, inset, font, change);
 }
@@ -1192,12 +1193,6 @@ void Paragraph::deleteInsetsLyXText(Buff
 }
 
 
-void Paragraph::resizeInsetsLyXText(BufferView * bv)
-{
-       insetlist.resizeInsetsLyXText(bv);
-}
-
-
 void Paragraph::setContentsFromPar(Paragraph const & par)
 {
        pimpl_->setContentsFromPar(par);
@@ -1355,7 +1350,7 @@ bool Paragraph::isFreeSpacing() const
                return true;
 
        // for now we just need this, later should we need this in some
-       // other way we can always add a function to InsetOld::() too.
+       // other way we can always add a function to InsetOld too.
        if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
                return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
        return false;
Index: paragraph.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v
retrieving revision 1.93
diff -u -p -r1.93 paragraph.h
--- paragraph.h 31 Jul 2003 13:38:05 -0000      1.93
+++ paragraph.h 11 Aug 2003 08:23:40 -0000
@@ -111,8 +111,6 @@ public:
        void setInsetOwner(UpdatableInset * inset);
        ///
        void deleteInsetsLyXText(BufferView *);
-       ///
-       void resizeInsetsLyXText(BufferView *);
 
        ///
        lyx::pos_type size() const;
Index: rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.39
diff -u -p -r1.39 rowpainter.C
--- rowpainter.C        28 Jul 2003 20:04:42 -0000      1.39
+++ rowpainter.C        11 Aug 2003 08:23:41 -0000
@@ -28,7 +28,6 @@
 #include "language.h"
 #include "encoding.h"
 #include "lyxtext.h"
-#include "lyxrow.h"
 #include "rowpainter.h"
 #include "lyxrc.h"
 #include "lyxrow_funcs.h"
@@ -1099,6 +1098,7 @@ int paintRows(BufferView const & bv, LyX
 {
        RowList::iterator end = text.rows().end();
        while (rit != end && yf < y2) {
+               //const_cast<LyXText &>(text).setHeightOfRow(rit);
                paintRowsHelper(bv, text, rit, y + yo, xo, y + text.top_y());
                y += rit->height();
                yf += rit->height();
Index: tabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tabular.C,v
retrieving revision 1.177
diff -u -p -r1.177 tabular.C
--- tabular.C   31 Jul 2003 12:25:35 -0000      1.177
+++ tabular.C   11 Aug 2003 08:23:41 -0000
@@ -392,7 +392,7 @@ void LyXTabular::init(BufferParams const
        for (int i = 0; i < rows_; ++i) {
                for (int j = 0; j < columns_; ++j) {
                        cell_info[i][j].inset.setOwner(owner_);
-                       cell_info[i][j].inset.setDrawFrame(0, InsetText::LOCKED);
+                       cell_info[i][j].inset.setDrawFrame(InsetText::LOCKED);
                        cell_info[i][j].cellno = cellno++;
                }
                cell_info[i].back().right_line = true;
@@ -400,15 +400,15 @@ void LyXTabular::init(BufferParams const
        row_info.back().bottom_line = true;
        row_info.front().bottom_line = true;
 
-       for (int i = 0; i < columns_; ++i) {
+       for (int i = 0; i < columns_; ++i)
                calculate_width_of_column(i);
-       }
+
        column_info.back().right_line = true;
 
        calculate_width_of_tabular();
 
-       rowofcell = vector<int>();
-       columnofcell = vector<int>();
+       rowofcell.clear();
+       columnofcell.clear();
        set_row_column_number_info();
        is_long_tabular = false;
        rotate = false;
@@ -433,16 +433,14 @@ void LyXTabular::appendRow(BufferParams 
        cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
                                                              cellstruct(bp)));
 
-       for (int i = 0; i <= row; ++i) {
-               for (int j = 0; j < columns_; ++j) {
+       for (int i = 0; i <= row; ++i)
+               for (int j = 0; j < columns_; ++j)
                        c_info[i][j] = cell_info[i][j];
-               }
-       }
-       for (int i = row + 1; i < rows_; ++i) {
-               for (int j = 0; j < columns_; ++j) {
+
+       for (int i = row + 1; i < rows_; ++i)
+               for (int j = 0; j < columns_; ++j)
                        c_info[i][j] = cell_info[i-1][j];
-               }
-       }
+
        cell_info = c_info;
        ++row;
        for (int j = 0; j < columns_; ++j) {
@@ -481,22 +479,19 @@ void LyXTabular::appendColumn(BufferPara
        column_info[column + 1] = column_info[column];
 
        for (int i = 0; i < rows_; ++i) {
-               for (int j = 0; j <= column; ++j) {
+               for (int j = 0; j <= column; ++j)
                        c_info[i][j] = cell_info[i][j];
-               }
-               for (int j = column + 1; j < columns_; ++j) {
+
+               for (int j = column + 1; j < columns_; ++j)
                        c_info[i][j] = cell_info[i][j - 1];
-               }
+
                // care about multicolumns
-               if (c_info[i][column + 1].multicolumn==CELL_BEGIN_OF_MULTICOLUMN)
-               {
+               if (c_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
                        c_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
-               }
-               if (column + 2 >= columns_ ||
-                       c_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN)
-               {
+
+               if (column + 2 >= columns_
+                   || c_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN)
                        c_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
-               }
        }
        cell_info = c_info;
        //++column;
@@ -575,6 +570,7 @@ void LyXTabular::set_row_column_number_i
                } while (column < columns_ &&
                                 cell_info[row][column].multicolumn
                                 == LyXTabular::CELL_PART_OF_MULTICOLUMN);
+
                if (column == columns_) {
                        column = 0;
                        ++row;
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.409
diff -u -p -r1.409 text.C
--- text.C      8 Aug 2003 16:24:30 -0000       1.409
+++ text.C      11 Aug 2003 08:23:41 -0000
@@ -11,7 +11,6 @@
 #include <config.h>
 
 #include "lyxtext.h"
-#include "lyxrow.h"
 #include "paragraph.h"
 #include "gettext.h"
 #include "bufferparams.h"
@@ -487,7 +486,7 @@ int LyXText::leftMargin(Row const & row)
        InsetOld * ins;
 
        if (row.pos() < row.par()->size())
-               if ((row.par()->getChar(row.pos()) == Paragraph::META_INSET) &&
+               if (row.par()->getChar(row.pos()) == Paragraph::META_INSET &&
                    (ins = row.par()->getInset(row.pos())) &&
                    (ins->needFullRow() || ins->display()))
                        return LEFT_MARGIN;
@@ -718,10 +717,9 @@ namespace {
 // this needs special handling - only newlines count as a break point
 pos_type addressBreakPoint(pos_type i, Paragraph const & par)
 {
-       for (; i < par.size(); ++i) {
+       for (; i < par.size(); ++i)
                if (par.isNewline(i))
                        return i;
-       }
 
        return par.size();
 }
@@ -1213,12 +1211,10 @@ void LyXText::setHeightOfRow(RowList::it
                        }
 
                        labeladdon = int(
-                               (font_metrics::maxAscent(labelfont) *
-                                layout->spacing.getValue() *
-                                spacing_val)
-                               +(font_metrics::maxDescent(labelfont) *
+                               (font_metrics::maxAscent(labelfont) +
+                                font_metrics::maxDescent(labelfont)) *
                                  layout->spacing.getValue() *
-                                 spacing_val)
+                                 spacing_val
                                + layout->topsep * defaultRowHeight()
                                + layout->labelbottomsep * defaultRowHeight());
                }
@@ -1351,90 +1347,6 @@ void LyXText::setHeightOfRow(RowList::it
 }
 
 
-// Appends the implicit specified paragraph before the specified row,
-// start at the implicit given position
-void LyXText::appendParagraph(RowList::iterator rowit)
-{
-       Assert(rowit != rowlist_.end());
-
-       pos_type const last = rowit->par()->size();
-       bool done = false;
-
-       do {
-               pos_type z = rowBreakPoint(*rowit);
-
-               RowList::iterator tmprow = rowit;
-
-               if (z < last) {
-                       ++z;
-                       Row newrow(rowit->par(), z);
-                       rowit = rowlist_.insert(boost::next(rowit), newrow);
-               } else {
-                       done = true;
-               }
-
-               // Set the dimensions of the row
-               // fixed fill setting now by calling inset->update() in
-               // SingleWidth when needed!
-               tmprow->fill(fill(tmprow, workWidth()));
-               setHeightOfRow(tmprow);
-
-       } while (!done);
-}
-
-
-void LyXText::breakAgain(RowList::iterator rit)
-{
-       Assert(rit != rows().end());
-
-       bool not_ready = true;
-
-       do {
-               pos_type z = rowBreakPoint(*rit);
-               RowList::iterator tmprit = rit;
-               RowList::iterator end = rows().end();
-
-               if (z < rit->par()->size()) {
-                       RowList::iterator next_rit = boost::next(rit);
-
-                       if (next_rit == end ||
-                           (next_rit != end &&
-                            next_rit->par() != rit->par())) {
-                               // insert a new row
-                               ++z;
-                               Row newrow(rit->par(), z);
-                               rit = rowlist_.insert(next_rit, newrow);
-                       } else  {
-                               ++rit;
-                               ++z;
-                               if (rit->pos() == z)
-                                       not_ready = false; // the rest will not change
-                               else {
-                                       rit->pos(z);
-                               }
-                       }
-               } else {
-                       // if there are some rows too much, delete them
-                       // only if you broke the whole paragraph!
-                       RowList::iterator tmprit2 = rit;
-                       while (boost::next(tmprit2) != end
-                              && boost::next(tmprit2)->par() == rit->par()) {
-                               ++tmprit2;
-                       }
-                       while (tmprit2 != rit) {
-                               --tmprit2;
-                               removeRow(boost::next(tmprit2));
-                       }
-                       not_ready = false;
-               }
-
-               // set the dimensions of the row
-               tmprit->fill(fill(tmprit, workWidth()));
-               setHeightOfRow(tmprit);
-       } while (not_ready);
-}
-
-
 void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
 {
        // allow only if at start or end, or all previous is new text
@@ -1521,8 +1433,7 @@ void LyXText::breakParagraph(ParagraphLi
        else
                setCursor(cursor.par(), 0);
 
-       if (boost::next(cursorRow()) != rows().end())
-               breakAgain(boost::next(cursorRow()));
+       redoParagraph(cursor.par());
 }
 
 
@@ -1602,16 +1513,10 @@ void LyXText::insertChar(char c)
        // and it should (along with realtmpfont) when we type the space.
        // CHECK There is a bug here! (Asger)
 
-       LyXFont realtmpfont = real_current_font;
-       LyXFont rawtmpfont = current_font;
        // store the current font.  This is because of the use of cursor
        // movements. The moving cursor would refresh the current font
-
-       // Get the font that is used to calculate the baselineskip
-       pos_type const lastpos = cursor.par()->size();
-       LyXFont rawparfont =
-               cursor.par()->getFontSettings(bv()->buffer()->params,
-                                             lastpos - 1);
+       LyXFont realtmpfont = real_current_font;
+       LyXFont rawtmpfont = current_font;
 
        if (!freeSpacing && IsLineSeparatorChar(c)) {
                if ((cursor.pos() > 0
@@ -2168,8 +2073,7 @@ void LyXText::backspace()
                        // This is an empty paragraph and we delete it just
                        // by moving the cursor one step
                        // left and let the DeleteEmptyParagraphMechanism
-                       // handle the actual deletion
-                       // of the paragraph.
+                       // handle the actual deletion of the paragraph.
 
                        if (cursor.par() != ownerParagraphs().begin()) {
                                ParagraphList::iterator tmppit = 
boost::prior(cursor.par());
@@ -2213,12 +2117,7 @@ void LyXText::backspace()
                // Pasting is not allowed, if the paragraphs have different
                // layout. I think it is a real bug of all other
                // word processors to allow it. It confuses the user.
-               // Even so with a footnote paragraph and a non-footnote
-               // paragraph. I will not allow pasting in this case,
-               // because the user would be confused if the footnote behaves
-               // different wether it is open or closed.
-
-               //      Correction: Pasting is always allowed with standard-layout
+               //Correction: Pasting is always allowed with standard-layout
                LyXTextClass const & tclass =
                        bv()->buffer()->params.getLyXTextClass();
 
@@ -2228,30 +2127,14 @@ void LyXText::backspace()
                    && cursor.par()->getAlign() == tmppit->getAlign()) {
                        removeParagraph(tmprow);
                        removeRow(tmprow);
-                       mergeParagraph(bv()->buffer()->params, 
bv()->buffer()->paragraphs, cursor.par());
-
-                       if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 
1))
-                               ; //cursor.par()->insertChar(cursor.pos(), ' ');
-                       // strangely enough it seems that commenting out the line 
above removes
-                       // most or all of the segfaults. I will however also try to 
move the
-                       // two Remove... lines in front of the PasteParagraph too.
-                       else
-                               if (cursor.pos())
-                                       cursor.pos(cursor.pos() - 1);
-
-                       // remove the lost paragraph
-                       // This one is not safe, since the paragraph that the tmprow 
and the
-                       // following rows belong to has been deleted by the 
PasteParagraph
-                       // above. The question is... could this be moved in front of 
the
-                       // PasteParagraph?
-                       //RemoveParagraph(tmprow);
-                       //RemoveRow(tmprow);
+                       mergeParagraph(bv()->buffer()->params,
+                               bv()->buffer()->paragraphs, cursor.par());
 
-                       // This rebuilds the rows.
-                       appendParagraph(cursorRow());
-                       updateCounters();
+                       if (cursor.pos() && cursor.par()->isSeparator(cursor.pos() - 
1))
+                               cursor.pos(cursor.pos() - 1);
 
                        // the row may have changed, block, hfills etc.
+                       updateCounters();
                        setCursor(cursor.par(), cursor.pos(), false);
                }
        } else {
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.424
diff -u -p -r1.424 text2.C
--- text2.C     8 Aug 2003 16:24:31 -0000       1.424
+++ text2.C     11 Aug 2003 08:23:41 -0000
@@ -28,7 +28,6 @@
 #include "frontends/font_metrics.h"
 #include "debug.h"
 #include "lyxrc.h"
-#include "lyxrow.h"
 #include "FloatList.h"
 #include "language.h"
 #include "ParagraphParameters.h"
@@ -103,8 +102,6 @@ void LyXText::init(BufferView * bview)
 // The difference is that this one is used for displaying, and thus we
 // are allowed to make cosmetic improvements. For instance make footnotes
 // smaller. (Asger)
-// If position is -1, we get the layout font of the paragraph.
-// If position is -2, we get the font of the manual label of the paragraph.
 LyXFont LyXText::getFont(ParagraphList::iterator pit, pos_type pos) const
 {
        Assert(pos >= 0);
@@ -285,7 +282,31 @@ void LyXText::insertParagraph(ParagraphL
        rit = rowlist_.insert(rit, Row(pit, 0));
 
        // and now append the whole paragraph before the new row
-       appendParagraph(rit);
+       Assert(rit != rowlist_.end());
+
+       pos_type const last = rit->par()->size();
+       bool done = false;
+
+       do {
+               pos_type z = rowBreakPoint(*rit);
+
+               RowList::iterator tmprow = rit;
+
+               if (z < last) {
+                       ++z;
+                       Row newrow(rit->par(), z);
+                       rit = rowlist_.insert(boost::next(rit), newrow);
+               } else {
+                       done = true;
+               }
+
+               // Set the dimensions of the row
+               // fixed fill setting now by calling inset->update() in
+               // SingleWidth when needed!
+               tmprow->fill(fill(tmprow, workWidth()));
+               setHeightOfRow(tmprow);
+
+       } while (!done);
 }
 
 
@@ -385,11 +406,10 @@ LyXText::setLayout(LyXCursor & cur, LyXC
        do {
                pit->applyLayout(lyxlayout);
                makeFontEntriesLayoutSpecific(bv()->buffer()->params, *pit);
-               ParagraphList::iterator fppit = pit;
-               fppit->params().spaceTop(lyxlayout->fill_top ?
+               pit->params().spaceTop(lyxlayout->fill_top ?
                                         VSpace(VSpace::VFILL)
                                         : VSpace(VSpace::NONE));
-               fppit->params().spaceBottom(lyxlayout->fill_bottom ?
+               pit->params().spaceBottom(lyxlayout->fill_bottom ?
                                            VSpace(VSpace::VFILL)
                                            : VSpace(VSpace::NONE));
                if (lyxlayout->margintype == MARGIN_MANUAL)
@@ -451,8 +471,8 @@ void LyXText::setLayout(string const & l
 
 bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
 {
-       ParagraphList::iterator pit(cursor.par());
-       ParagraphList::iterator end(cursor.par());
+       ParagraphList::iterator pit = cursor.par();
+       ParagraphList::iterator end = cursor.par();
        ParagraphList::iterator start = pit;
 
        if (selection.set()) {
@@ -480,10 +500,8 @@ bool LyXText::changeDepth(bv_funcs::DEPT
                        if (depth < prev_after_depth
                            && pit->layout()->labeltype != LABEL_BIBLIO) {
                                changed = true;
-                               if (!test_only) {
+                               if (!test_only)
                                        pit->params().depth(depth + 1);
-                               }
-
                        }
                } else if (depth) {
                        changed = true;
@@ -503,7 +521,6 @@ bool LyXText::changeDepth(bv_funcs::DEPT
        if (test_only)
                return changed;
 
-
        redoParagraphs(start, pastend);
 
        // We need to actually move the text->cursor. I don't
@@ -623,35 +640,9 @@ void LyXText::redoParagraph(ParagraphLis
        }
 
        // reinsert the paragraph
-       // insert a new row, starting at position 0
-       Row newrow(pit, 0);
-       rit = rowlist_.insert(rit, newrow);
-
-       // and now append the whole paragraph before the new row
-       pos_type const last = rit->par()->size();
-       bool done = false;
-
-       do {
-               pos_type z = rowBreakPoint(*rit);
-
-               RowList::iterator tmprow = rit;
-
-               if (z < last) {
-                       ++z;
-                       Row newrow(rit->par(), z);
-                       rit = rowlist_.insert(boost::next(rit), newrow);
-               } else {
-                       done = true;
-               }
-
-               // Set the dimensions of the row
-               // fixed fill setting now by calling inset->update() in
-               // SingleWidth when needed!
-               tmprow->fill(fill(tmprow, workWidth()));
-               setHeightOfRow(tmprow);
-
-       } while (!done);
+       insertParagraph(pit, rit);
 
+       // why?
        setHeightOfRow(rows().begin());
 }
 
@@ -659,7 +650,7 @@ void LyXText::redoParagraph(ParagraphLis
 void LyXText::fullRebreak()
 {
        redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
-       setCursorIntern(cursor.par(), cursor.pos());
+       redoCursor();
        selection.cursor = cursor;
 }
 
@@ -691,25 +682,9 @@ void LyXText::metrics(MetricsInfo & mi, 
                        ii->inset->metrics(m, dim);
                }
 
-#if 1
-               // insert a new row, starting at position 0
-               Row newrow(pit, 0);
-               RowList::iterator rit = rowlist_.insert(rowlist_.end(), newrow);
-
-               // and now append the whole paragraph before the new row
-               appendParagraph(rit);
-#else
                redoParagraph(pit);
-#endif
        }
 
-       // compute height
-       //lyxerr << "height 0: " << height << endl;
-       //for (RowList::iterator rit = rows().begin(); rit != rows().end(); ++rit) {
-       //      height += rit->height();
-       //}
-       //lyxerr << "height 1: " << height << endl;
-
        // final dimension
        dim.asc = rows().begin()->ascent_of_text();
        dim.des = height - dim.asc;
@@ -717,16 +692,6 @@ void LyXText::metrics(MetricsInfo & mi, 
 }
 
 
-void LyXText::partialRebreak()
-{
-       if (rows().empty()) {
-               init(bv());
-               return;
-       }
-       breakAgain(rows().begin());
-}
-
-
 // important for the screen
 
 
@@ -857,8 +822,8 @@ string LyXText::getStringToIndex()
 
 
 // the DTP switches for paragraphs. LyX will store them in the first
-// physicla paragraph. When a paragraph is broken, the top settings rest,
-// the bottom settings are given to the new one. So I can make shure,
+// physical paragraph. When a paragraph is broken, the top settings rest,
+// the bottom settings are given to the new one. So I can make sure,
 // they do not duplicate themself and you cannnot make dirty things with
 // them!
 
@@ -962,13 +927,12 @@ void LyXText::setCounter(Buffer const * 
                pit->itemdepth = 0;
        }
 
-       /* Maybe we have to increment the enumeration depth.
-        * BUT, enumeration in a footnote is considered in isolation from its
-        *      surrounding paragraph so don't increment if this is the
-        *      first line of the footnote
-        * AND, bibliographies can't have their depth changed ie. they
-        *      are always of depth 0
-        */
+       // Maybe we have to increment the enumeration depth.
+       // BUT, enumeration in a footnote is considered in isolation from its
+       //      surrounding paragraph so don't increment if this is the
+       //      first line of the footnote
+       // AND, bibliographies can't have their depth changed ie. they
+       //      are always of depth 0
        if (pit != ownerParagraphs().begin()
            && boost::prior(pit)->getDepth() < pit->getDepth()
            && boost::prior(pit)->layout()->labeltype == LABEL_COUNTER_ENUMI
@@ -990,9 +954,8 @@ void LyXText::setCounter(Buffer const * 
        }
 
        if (layout->margintype == MARGIN_MANUAL) {
-               if (pit->params().labelWidthString().empty()) {
+               if (pit->params().labelWidthString().empty())
                        pit->setLabelWidthString(layout->labelstring());
-               }
        } else {
                pit->setLabelWidthString(string());
        }
@@ -1145,18 +1108,12 @@ void LyXText::setCounter(Buffer const * 
 // Updates all counters. Paragraphs with changed label string will be rebroken
 void LyXText::updateCounters()
 {
-       RowList::iterator rowit = rows().begin();
-       ParagraphList::iterator pit = rowit->par();
-
-       // CHECK if this is really needed. (Lgb)
+       // start over
        bv()->buffer()->params.getLyXTextClass().counters().reset();
 
        ParagraphList::iterator beg = ownerParagraphs().begin();
        ParagraphList::iterator end = ownerParagraphs().end();
-       for (; pit != end; ++pit) {
-               while (rowit->par() != pit)
-                       ++rowit;
-
+       for (ParagraphList::iterator pit = beg; pit != end; ++pit) {
                string const oldLabel = pit->params().labelString();
 
                size_t maxdepth = 0;
@@ -1171,10 +1128,8 @@ void LyXText::updateCounters()
 
                string const & newLabel = pit->params().labelString();
 
-               if (oldLabel.empty() && !newLabel.empty()) {
-                       removeParagraph(rowit);
-                       appendParagraph(rowit);
-               }
+               if (oldLabel != newLabel)
+                       redoParagraph(pit);
        }
 }
 
@@ -1189,14 +1144,12 @@ void LyXText::insertInset(InsetOld * ins
        // Just to rebreak and refresh correctly.
        // The character will not be inserted a second time
        insertChar(Paragraph::META_INSET);
-       // If we enter a highly editable inset the cursor should be to before
-       // the inset. This couldn't happen before as Undo was not handled inside
-       // inset now after the Undo LyX tries to call inset->Edit(...) again
-       // and cannot do this as the cursor is behind the inset and GetInset
+       // If we enter a highly editable inset the cursor should be before
+       // the inset. After an Undo LyX tries to call inset->edit(...) 
+       // and fails if the cursor is behind the inset and getInset
        // does not return the inset!
-       if (isHighlyEditableInset(inset)) {
+       if (isHighlyEditableInset(inset))
                cursorLeft(true);
-       }
        unFreezeUndo();
 }
 
@@ -1238,7 +1191,6 @@ void LyXText::cutSelection(bool doclear,
        recordUndo(bv(), Undo::DELETE, selection.start.par(),
                   boost::prior(undoendpit));
 
-
        endpit = selection.end.par();
        int endpos = selection.end.pos();
 
@@ -1438,6 +1390,13 @@ bool LyXText::setCursor(ParagraphList::i
 }
 
 
+void LyXText::redoCursor()
+{
+#warning maybe the same for selections?
+       setCursor(cursor, cursor.par(), cursor.pos(), cursor.boundary());
+}
+
+
 void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
                        pos_type pos, bool boundary)
 {
@@ -1538,11 +1497,11 @@ float LyXText::getCursorX(RowList::itera
                cursor_vpos = (rit_par->isRightToLeftPar(bv()->buffer()->params))
                        ? rit_pos : last + 1;
        else if (pos > rit_pos && (pos > last || boundary))
-               /// Place cursor after char at (logical) position pos - 1
+               // Place cursor after char at (logical) position pos - 1
                cursor_vpos = (bidi_level(pos - 1) % 2 == 0)
                        ? log2vis(pos - 1) + 1 : log2vis(pos - 1);
        else
-               /// Place cursor before char at (logical) position pos
+               // Place cursor before char at (logical) position pos
                cursor_vpos = (bidi_level(pos) % 2 == 0)
                        ? log2vis(pos) : log2vis(pos) + 1;
 
@@ -1581,32 +1540,6 @@ float LyXText::getCursorX(RowList::itera
 void LyXText::setCursorIntern(ParagraphList::iterator pit,
                              pos_type pos, bool setfont, bool boundary)
 {
-       UpdatableInset * it = pit->inInset();
-       if (it) {
-               if (it != inset_owner) {
-                       lyxerr[Debug::INSETS] << "InsetText   is " << it
-                                             << endl
-                                             << "inset_owner is "
-                                             << inset_owner << endl;
-#ifdef WITH_WARNINGS
-#warning I believe this code is wrong. (Lgb)
-#warning Jürgen, have a look at this. (Lgb)
-#warning Hmmm, I guess you are right but we
-#warning should verify when this is needed
-#endif
-                       // Jürgen, would you like to have a look?
-                       // I guess we need to move the outer cursor
-                       // and open and lock the inset (bla bla bla)
-                       // stuff I don't know... so can you have a look?
-                       // (Lgb)
-                       // I moved the lyxerr stuff in here so we can see if
-                       // this is actually really needed and where!
-                       // (Jug)
-                       // it->getLyXText(bv())->setCursorIntern(bv(), par, pos, 
setfont, boundary);
-                       return;
-               }
-       }
-
        setCursor(cursor, pit, pos, boundary);
        if (setfont)
                setCurrentFont();
@@ -1940,8 +1873,7 @@ void LyXText::cursorDownParagraph()
 
 // fix the cursor `cur' after a characters has been deleted at `where'
 // position. Called by deleteEmptyParagraphMechanism
-void LyXText::fixCursorAfterDelete(LyXCursor & cur,
-                                  LyXCursor const & where)
+void LyXText::fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where)
 {
        // if cursor is not in the paragraph where the delete occured,
        // do nothing
@@ -1970,10 +1902,8 @@ bool LyXText::deleteEmptyParagraphMechan
                return false;
 
        // We allow all kinds of "mumbo-jumbo" when freespacing.
-       if (old_cursor.par()->layout()->free_spacing
-           || old_cursor.par()->isFreeSpacing()) {
+       if (old_cursor.par()->isFreeSpacing())
                return false;
-       }
 
        /* Ok I'll put some comments here about what is missing.
           I have fixed BackSpace (and thus Delete) to not delete
@@ -2001,8 +1931,8 @@ bool LyXText::deleteEmptyParagraphMechan
        // If the pos around the old_cursor were spaces, delete one of them.
        if (old_cursor.par() != cursor.par()
            || old_cursor.pos() != cursor.pos()) {
-               // Only if the cursor has really moved
 
+               // Only if the cursor has really moved
                if (old_cursor.pos() > 0
                    && old_cursor.pos() < old_cursor.par()->size()
                    && old_cursor.par()->isLineSeparator(old_cursor.pos())
@@ -2081,7 +2011,7 @@ bool LyXText::deleteEmptyParagraphMechan
                         * there is another layout before */
                        RowList::iterator tmprit = boost::next(prevrow);
                        if (tmprit != rows().end()) {
-                               breakAgain(tmprit);
+                               redoParagraph(tmprit->par());
                                updateCounters();
                        }
                        setHeightOfRow(prevrow);
@@ -2110,7 +2040,7 @@ bool LyXText::deleteEmptyParagraphMechan
                           The next row can change its height, if
                           there is another layout before */
                        if (nextrow != rows().end()) {
-                               breakAgain(nextrow);
+                               redoParagraph(nextrow->par());
                                updateCounters();
                        }
                }
@@ -2146,8 +2076,7 @@ ParagraphList & LyXText::ownerParagraphs
 
 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.
        return inset_owner != 0 && bv_owner != 0;
 }
 
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.107
diff -u -p -r1.107 text3.C
--- text3.C     8 Aug 2003 16:24:31 -0000       1.107
+++ text3.C     11 Aug 2003 08:23:41 -0000
@@ -11,7 +11,6 @@
 #include <config.h>
 
 #include "lyxtext.h"
-#include "lyxrow.h"
 #include "paragraph.h"
 #include "BufferView.h"
 #include "funcrequest.h"
@@ -226,7 +225,7 @@ void LyXText::gotoInset(vector<InsetOld:
                        bv()->owner()->message(_("No more insets"));
                }
        }
-       update();
+       bv()->update();
        selection.cursor = cursor;
 }
 
@@ -348,16 +347,11 @@ void LyXText::cursorNext()
 }
 
 
-void LyXText::update()
-{
-       bv()->update();
-}
-
 namespace {
 
 void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
 {
-       lt->update();
+       bv->update();
        InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
        replaceSelection(lt);
        if (!bv->insertInset(new_inset))
@@ -415,8 +409,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        if (tmp->params().startOfAppendix()) {
                                recordUndo(bv, Undo::ATOMIC, tmp);
                                tmp->params().startOfAppendix(false);
-                               int tmpy;
-                               setHeightOfRow(getRow(tmp, 0, tmpy));
+                               setHeightOfRow(getRow(tmp, 0));
                                break;
                        }
                }
@@ -428,28 +421,25 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                updateCounters();
                redoParagraph(cursor.par());
                setCursor(cursor.par(), cursor.pos());
-               update();
+               bv->update();
                break;
        }
 
        case LFUN_DELETE_WORD_FORWARD:
                bv->beforeChange(this);
                deleteWordForward();
-               update();
                finishChange(bv);
                break;
 
        case LFUN_DELETE_WORD_BACKWARD:
                bv->beforeChange(this);
                deleteWordBackward();
-               update();
                finishChange(bv);
                break;
 
        case LFUN_DELETE_LINE_FORWARD:
                bv->beforeChange(this);
                deleteLineForward();
-               update();
                finishChange(bv);
                break;
 
@@ -461,7 +451,6 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                else
                        cursorRightOneWord();
                finishChange(bv);
-               update();
                break;
 
        case LFUN_WORDLEFT:
@@ -718,7 +707,6 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                }
                moveCursorUpdate(bv, false);
                bv->owner()->view_state_changed();
-               bv->switchKeyMap();
                break;
 
        case LFUN_DELETE_SKIP:
@@ -754,7 +742,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                } else {
                        cutSelection(true, false);
                }
-               update();
+               bv->update();
                break;
 
 
@@ -771,7 +759,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                }
                bv->owner()->view_state_changed();
                bv->switchKeyMap();
-               update();
+               bv->update();
                break;
 
        case LFUN_BACKSPACE_SKIP:
@@ -795,16 +783,15 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                                selection.cursor = cur;
                        }
                } else {
-                       update();
                        cutSelection(true, false);
                }
-               update();
+               bv->update();
                break;
 
        case LFUN_BREAKPARAGRAPH:
                replaceSelection(bv->getLyXText());
                breakParagraph(bv->buffer()->paragraphs, 0);
-               update();
+               bv->update();
                selection.cursor = cursor;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -813,7 +800,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
        case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
                replaceSelection(bv->getLyXText());
                breakParagraph(bv->buffer()->paragraphs, 1);
-               update();
+               bv->update();
                selection.cursor = cursor;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -841,7 +828,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                else {
                        breakParagraph(bv->buffer()->paragraphs, 0);
                }
-               update();
+               bv->update();
                selection.cursor = cur;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -885,7 +872,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                if (cur_spacing != new_spacing || cur_value != new_value) {
                        pit->params().spacing(Spacing(new_spacing, new_value));
                        redoParagraph();
-                       update();
+                       bv->update();
                }
                break;
        }
@@ -897,19 +884,16 @@ InsetOld::RESULT LyXText::dispatch(FuncR
 
        case LFUN_INSET_TOGGLE:
                bv->beforeChange(this);
-               update();
                toggleInset();
-               update();
+               bv->update();
                bv->switchKeyMap();
                break;
 
        case LFUN_SPACE_INSERT:
-               if (cursor.par()->layout()->free_spacing) {
+               if (cursor.par()->layout()->free_spacing)
                        insertChar(' ');
-                       update();
-               } else {
+               else
                        doInsertInset(this, cmd, false, false);
-               }
                moveCursorUpdate(bv, false);
                break;
 
@@ -935,7 +919,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
 
        case LFUN_MARK_OFF:
                bv->beforeChange(this);
-               update();
+               bv->update();
                selection.cursor = cursor;
                cmd.message(N_("Mark off"));
                break;
@@ -943,7 +927,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
        case LFUN_MARK_ON:
                bv->beforeChange(this);
                selection.mark(true);
-               update();
+               bv->update();
                selection.cursor = cursor;
                cmd.message(N_("Mark on"));
                break;
@@ -957,37 +941,28 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        cmd.message(N_("Mark set"));
                }
                selection.cursor = cursor;
-               update();
+               bv->update();
                break;
 
        case LFUN_UPCASE_WORD:
-               update();
                changeCase(LyXText::text_uppercase);
-               if (inset_owner)
-                       bv->updateInset();
-               update();
+               bv->update();
                break;
 
        case LFUN_LOWCASE_WORD:
                changeCase(LyXText::text_lowercase);
-               if (inset_owner)
-                       bv->updateInset();
-               update();
+               bv->update();
                break;
 
        case LFUN_CAPITALIZE_WORD:
                changeCase(LyXText::text_capitalization);
-               if (inset_owner)
-                       bv->updateInset();
-               update();
+               bv->update();
                break;
 
        case LFUN_TRANSPOSE_CHARS:
                recordUndo(bv, Undo::ATOMIC, cursor.par());
-               if (inset_owner)
-                       bv->updateInset();
                redoParagraph();
-               update();
+               bv->update();
                break;
 
        case LFUN_PASTE: {
@@ -1002,7 +977,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                }
                pasteSelection(sel_index);
                clearSelection(); // bug 393
-               update();
+               bv->update();
                bv->switchKeyMap();
                break;
        }
@@ -1010,7 +985,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
        case LFUN_CUT:
                cutSelection(true, true);
                cmd.message(_("Cut"));
-               update();
+               bv->update();
                break;
 
        case LFUN_COPY:
@@ -1023,7 +998,6 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        return UNDISPATCHED;
                cursorTop();
                finishChange(bv, true);
-               update();
                break;
 
        case LFUN_ENDBUFSEL:
@@ -1031,7 +1005,6 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        return UNDISPATCHED;
                cursorBottom();
                finishChange(bv, true);
-               update();
                break;
 
        case LFUN_GETXY:
@@ -1117,7 +1090,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        current_layout = layout;
                        setLayout(layout);
                        bv->owner()->setLayout(layout);
-                       update();
+                       bv->update();
                        bv->switchKeyMap();
                }
                break;
@@ -1134,7 +1107,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        else
                                insertStringAsLines(clip);
                        clearSelection();
-                       update();
+                       bv->update();
                }
                break;
        }
@@ -1192,10 +1165,9 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                int const datetmp_len =
                        ::strftime(datetmp, 32, arg.c_str(), now_tm);
 
-               for (int i = 0; i < datetmp_len; i++) {
+               for (int i = 0; i < datetmp_len; i++)
                        insertChar(datetmp[i]);
-                       update();
-               }
+
                selection.cursor = cursor;
                moveCursorUpdate(bv, false);
                break;
@@ -1215,7 +1187,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        setSelection();
                        if (!isInInset())
                                bv->screen().toggleSelection(this, bv, false);
-                       update();
+                       bv->update();
                        bv->haveSelection(selection.set());
                }
                break;
@@ -1233,7 +1205,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        } else {
                                selectWord(lyx::WHOLE_WORD_STRICT);
                        }
-                       update();
+                       bv->update();
                        bv->haveSelection(selection.set());
                }
                break;
@@ -1509,7 +1481,6 @@ InsetOld::RESULT LyXText::dispatch(FuncR
                        bv->owner()->getIntl().getTransManager().
                                TranslateAndInsert(*cit, this);
 
-               update();
                selection.cursor = cursor;
                moveCursorUpdate(bv, false);
 
Index: trans_mgr.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/trans_mgr.h,v
retrieving revision 1.15
diff -u -p -r1.15 trans_mgr.h
--- trans_mgr.h 13 Feb 2003 16:52:45 -0000      1.15
+++ trans_mgr.h 11 Aug 2003 08:23:41 -0000
@@ -57,7 +57,7 @@ public:
 
 
 /// Init State
-class TransInitState : virtual public TransFSMData, public TransState {
+class TransInitState :virtual public TransFSMData, public TransState {
 public:
        ///
        TransInitState();
Index: insets/inset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v
retrieving revision 1.108
diff -u -p -r1.108 inset.h
--- insets/inset.h      7 Aug 2003 11:59:09 -0000       1.108
+++ insets/inset.h      11 Aug 2003 08:23:41 -0000
@@ -232,8 +232,6 @@ public:
                                     bool recursive = false) const;
        ///
        virtual void deleteLyXText(BufferView *, bool = true) const {}
-       ///
-       virtual void resizeLyXText(BufferView *, bool /*force*/= false) const {}
        /// returns the actuall scroll-value
        virtual int scroll(bool recursive=true) const {
                if (!recursive || !owner_)
Index: insets/insetcaption.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcaption.C,v
retrieving revision 1.34
diff -u -p -r1.34 insetcaption.C
--- insets/insetcaption.C       25 Jul 2003 21:20:13 -0000      1.34
+++ insets/insetcaption.C       11 Aug 2003 08:23:41 -0000
@@ -36,8 +36,8 @@ InsetCaption::InsetCaption(BufferParams 
        : InsetText(bp)
 {
        setAutoBreakRows(true);
-       setDrawFrame(0, InsetText::LOCKED);
-       setFrameColor(0, LColor::captionframe);
+       setDrawFrame(InsetText::LOCKED);
+       setFrameColor(LColor::captionframe);
 }
 
 
Index: insets/insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.163
diff -u -p -r1.163 insetcollapsable.C
--- insets/insetcollapsable.C   5 Aug 2003 08:07:02 -0000       1.163
+++ insets/insetcollapsable.C   11 Aug 2003 08:23:41 -0000
@@ -49,12 +49,12 @@ InsetCollapsable::InsetCollapsable(Buffe
 #if 0
        autocollapse(false),
 #endif
-         oldWidth(0), in_update(false), first_after_edit(false)
+         in_update(false), first_after_edit(false)
 {
        inset.setOwner(this);
        inset.setAutoBreakRows(true);
-       inset.setDrawFrame(0, InsetText::ALWAYS);
-       inset.setFrameColor(0, LColor::collapsableframe);
+       inset.setDrawFrame(InsetText::ALWAYS);
+       inset.setFrameColor(LColor::collapsableframe);
        setInsetName("Collapsable");
 }
 
@@ -66,7 +66,7 @@ InsetCollapsable::InsetCollapsable(Inset
 #if 0
          autocollapse(in.autocollapse),
 #endif
-         oldWidth(0), in_update(false), first_after_edit(false)
+         in_update(false), first_after_edit(false)
 {
        inset.init(&(in.inset));
        inset.setOwner(this);
@@ -243,6 +243,7 @@ void InsetCollapsable::lfunMouseRelease(
                }
                bv->updateInset();
                bv->buffer()->markDirty();
+               lyxerr << "InsetCollapsable::lfunMouseRelease\n";
        } else if (!collapsed_ && cmd.y > button_dim.y2) {
                ret = inset.localDispatch(adjustCommand(cmd)) == DISPATCHED;
        }
@@ -441,13 +442,6 @@ LyXText * InsetCollapsable::getLyXText(B
 void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const
 {
        inset.deleteLyXText(bv, recursive);
-}
-
-
-void InsetCollapsable::resizeLyXText(BufferView * bv, bool force) const
-{
-       inset.resizeLyXText(bv, force);
-       oldWidth = width();
 }
 
 
Index: insets/insetcollapsable.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v
retrieving revision 1.117
diff -u -p -r1.117 insetcollapsable.h
--- insets/insetcollapsable.h   5 Aug 2003 08:07:02 -0000       1.117
+++ insets/insetcollapsable.h   11 Aug 2003 08:23:41 -0000
@@ -114,8 +114,6 @@ public:
        ///
        void deleteLyXText(BufferView *, bool recursive=true) const;
        ///
-       void resizeLyXText(BufferView *, bool force = false) const;
-       ///
        void getLabelList(std::vector<string> &) const;
        ///
        int scroll(bool recursive=true) const;
@@ -205,8 +203,6 @@ private:
        ///
        bool autocollapse;
 #endif
-       ///
-       mutable int oldWidth;
        ///
        bool in_update;
        ///
Index: insets/insetminipage.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetminipage.C,v
retrieving revision 1.86
diff -u -p -r1.86 insetminipage.C
--- insets/insetminipage.C      5 Aug 2003 08:07:03 -0000       1.86
+++ insets/insetminipage.C      11 Aug 2003 08:23:41 -0000
@@ -76,16 +76,7 @@ InsetMinipage::InsetMinipage(BufferParam
 #if 0
        setAutoCollapse(false);
 #endif
-
-#if 0
-#ifdef WITH_WARNINGS
-#warning Remove this color definitions before 1.2.0 final!
-#endif
-       // just for experimentation :)
-       setBackgroundColor(LColor::green);
-#endif
-
-       inset.setFrameColor(0, LColor::blue);
+       inset.setFrameColor(LColor::blue);
        setInsetName("Minipage");
 }
 
Index: insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.325
diff -u -p -r1.325 insettabular.C
--- insets/insettabular.C       5 Aug 2003 12:35:25 -0000       1.325
+++ insets/insettabular.C       11 Aug 2003 08:23:41 -0000
@@ -45,7 +45,6 @@
 #include <fstream>
 #include <algorithm>
 #include <cstdlib>
-#include <map>
 
 
 using namespace lyx::support;
@@ -1650,10 +1649,7 @@ void InsetTabular::tabularFeatures(Buffe
                        // the insettext of the active cell (if any)
                        // until later (see InsetText::do_resize)
                        unlockInsetInInset(bv, the_locking_inset);
-
-                       for (int i = 0; i < tabular.rows(); ++i)
-                               tabular.getCellInset(i, column).resizeLyXText(bv);
-                       updateLocal(bv);
+                       bv->update();
                }
 
                if (vallen.zero()
@@ -1677,10 +1673,6 @@ void InsetTabular::tabularFeatures(Buffe
                        // the insettext of the active cell (if any)
                        // until later (see InsetText::do_resize)
                        unlockInsetInInset(bv, the_locking_inset);
-
-                       for (int i = 0; i < tabular.rows(); ++i)
-                               tabular.getCellInset(i, column).resizeLyXText(bv);
-
                        updateLocal(bv);
                }
        }
@@ -1989,16 +1981,7 @@ bool InsetTabular::insetHit(BufferView *
 
 void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const
 {
-       resizeLyXText(bv, recursive);
-}
-
-
-void InsetTabular::resizeLyXText(BufferView * bv, bool force) const
-{
-       if (force)
-               for (int i = 0; i < tabular.rows(); ++i)
-                       for (int j = 0; j < tabular.columns(); ++j)
-                               tabular.getCellInset(i, j).resizeLyXText(bv, true);
+       //resizeLyXText(bv, recursive);
 }
 
 
Index: insets/insettabular.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v
retrieving revision 1.143
diff -u -p -r1.143 insettabular.h
--- insets/insettabular.h       5 Aug 2003 12:35:25 -0000       1.143
+++ insets/insettabular.h       11 Aug 2003 08:23:41 -0000
@@ -140,8 +140,6 @@ public:
        ///
        void deleteLyXText(BufferView *, bool recursive = true) const;
        ///
-       void resizeLyXText(BufferView *, bool force = false) const;
-       ///
        void openLayoutDialog(BufferView *) const;
        ///
        bool showInsetDialog(BufferView *) const;
Index: insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.475
diff -u -p -r1.475 insettext.C
--- insets/insettext.C  8 Aug 2003 16:24:32 -0000       1.475
+++ insets/insettext.C  11 Aug 2003 08:23:41 -0000
@@ -42,6 +42,7 @@
 #include "rowpainter.h"
 #include "insetnewline.h"
 #include "metricsinfo.h"
+#include "textcursor.h"
 
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
@@ -80,50 +81,6 @@ using lyx::pos_type;
 using lyx::textclass_type;
 
 
-// we should get rid of these (Andre')
-
-void InsetText::saveLyXTextState() const
-{
-       // check if my paragraphs are still valid
-       ParagraphList::iterator it = const_cast<ParagraphList&>(paragraphs).begin();
-       ParagraphList::iterator end = const_cast<ParagraphList&>(paragraphs).end();
-       for (; it != end; ++it)
-               if (it == text_.cursor.par())
-                       break;
-
-       if (it != end && text_.cursor.pos() <= it->size())
-               sstate = text_; // slicing intended
-       else
-               sstate.cursor.par(end);
-}
-
-
-void InsetText::restoreLyXTextState() const
-{
-       if (sstate.cursor.par() == const_cast<ParagraphList&>(paragraphs).end())
-               return;
-
-       text_.selection.set(true);
-       // at this point just to avoid the DEPM when setting the cursor
-       text_.selection.mark(sstate.selection.mark());
-       if (sstate.selection.set()) {
-               text_.setCursor(sstate.selection.start.par(),
-                       sstate.selection.start.pos(),
-                       true, sstate.selection.start.boundary());
-               text_.selection.cursor = text_.cursor;
-               text_.setCursor(sstate.selection.end.par(), sstate.selection.end.pos(),
-                       true, sstate.selection.end.boundary());
-               text_.setSelection();
-               text_.setCursor(sstate.cursor.par(), sstate.cursor.pos());
-       } else {
-               text_.setCursor(sstate.cursor.par(), sstate.cursor.pos(),
-                       true, sstate.cursor.boundary());
-               text_.selection.cursor = text_.cursor;
-               text_.selection.set(false);
-       }
-}
-
-
 InsetText::InsetText(BufferParams const & bp)
        : UpdatableInset(), text_(0, this)
 {
@@ -162,8 +119,6 @@ void InsetText::init(InsetText const * i
                for (; pit != end; ++pit)
                        pit->setInsetOwner(this);
 
-               reinitLyXText();
-
                autoBreakRows = ins->autoBreakRows;
                drawFrame_ = ins->drawFrame_;
                frame_color = ins->frame_color;
@@ -182,7 +137,6 @@ void InsetText::init(InsetText const * i
        drawTextYOffset = 0;
        locked = false;
        old_par = paragraphs.end();
-       sstate.cursor.par(paragraphs.end());
        in_insetAllowed = false;
 }
 
@@ -192,9 +146,8 @@ void InsetText::clear(bool just_mark_era
        if (just_mark_erased) {
                ParagraphList::iterator it = paragraphs.begin();
                ParagraphList::iterator end = paragraphs.end();
-               for (; it != end; ++it) {
+               for (; it != end; ++it) 
                        it->markErased();
-               }
                return;
        }
 
@@ -205,8 +158,6 @@ void InsetText::clear(bool just_mark_era
        paragraphs.push_back(Paragraph());
        paragraphs.begin()->setInsetOwner(this);
        paragraphs.begin()->layout(old_layout);
-
-       reinitLyXText();
 }
 
 
@@ -385,7 +336,6 @@ void InsetText::updateLocal(BufferView *
        if (!autoBreakRows && paragraphs.size() > 1)
                collapseParagraphs(bv);
 
-       text_.partialRebreak();
        if (!text_.selection.set())
                text_.selection.cursor = text_.cursor;
 
@@ -1470,6 +1420,8 @@ void InsetText::setFont(BufferView * bv,
 
 bool InsetText::checkAndActivateInset(BufferView * bv, bool front)
 {
+       if (cpos() == cpar()->size())
+               return false;
        InsetOld * inset = cpar()->getInset(cpos());
        if (!isHighlyEditableInset(inset))
                return false;
@@ -1534,7 +1486,6 @@ void InsetText::setText(string const & d
        clear(false);
        for (unsigned int i = 0; i < data.length(); ++i)
                paragraphs.begin()->insertChar(i, data[i], font);
-       reinitLyXText();
 }
 
 
@@ -1548,21 +1499,15 @@ void InsetText::setAutoBreakRows(bool fl
 }
 
 
-void InsetText::setDrawFrame(BufferView * bv, DrawFrame how)
+void InsetText::setDrawFrame(DrawFrame how)
 {
-       if (how != drawFrame_) {
-               drawFrame_ = how;
-               updateLocal(bv, false);
-       }
+       drawFrame_ = how;
 }
 
 
-void InsetText::setFrameColor(BufferView * bv, LColor::color col)
+void InsetText::setFrameColor(LColor::color col)
 {
-       if (frame_color != col) {
-               frame_color = col;
-               updateLocal(bv, false);
-       }
+       frame_color = col;
 }
 
 
@@ -1638,8 +1583,14 @@ LyXText * InsetText::getLyXText(BufferVi
 
 void InsetText::setViewCache(BufferView const * bv) const
 {
-       if (bv)
+       if (bv) {
+               if (bv != text_.bv_owner) {
+                       lyxerr << "setting view cache from "
+                               << text_.bv_owner << " to " << bv << "\n";
+                       text_.init(const_cast<BufferView *>(bv));
+               }
                text_.bv_owner = const_cast<BufferView *>(bv);
+       }
 }
 
 
@@ -1654,87 +1605,14 @@ void InsetText::deleteLyXText(BufferView
 }
 
 
-void InsetText::resizeLyXText(BufferView * bv, bool /*force*/) const
-{
-       if (paragraphs.size() == 1 && paragraphs.begin()->empty())
-               return;
-
-       if (!bv)
-               return;
-
-       Assert(bv);
-       setViewCache(bv);
-
-       for_each(const_cast<ParagraphList&>(paragraphs).begin(),
-                const_cast<ParagraphList&>(paragraphs).end(),
-                boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
-
-       saveLyXTextState();
-       text_.init(bv);
-       restoreLyXTextState();
-
-       // seems to be unneeded
-#if 1
-       if (the_locking_inset) {
-               inset_x = cix() - top_x + drawTextXOffset;
-               inset_y = ciy() + drawTextYOffset;
-       }
-#endif
-
-#if 0
-       text_.top_y(bv->screen().topCursorVisible(&text_));
-       if (!owner()) {
-               const_cast<InsetText*>(this)->updateLocal(bv, false);
-               // this will scroll the screen such that the cursor becomes visible
-               bv->updateScrollbar();
-       }
-#endif
-}
-
-
-void InsetText::reinitLyXText() const
-{
-       BufferView * bv = text_.bv_owner;
-
-       if (!bv)
-               return;
-
-       saveLyXTextState();
-
-       for_each(const_cast<ParagraphList&>(paragraphs).begin(),
-                const_cast<ParagraphList&>(paragraphs).end(),
-                boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
-
-       text_.init(bv);
-       restoreLyXTextState();
-       if (the_locking_inset) {
-               inset_x = cix() - top_x + drawTextXOffset;
-               inset_y = ciy() + drawTextYOffset;
-       }
-       text_.top_y(bv->screen().topCursorVisible(&text_));
-       if (!owner()) {
-               // this will scroll the screen such that the cursor becomes visible
-               bv->updateScrollbar();
-       }
-}
-
-
 void InsetText::removeNewlines()
 {
-       bool changed = false;
-
        ParagraphList::iterator it = paragraphs.begin();
        ParagraphList::iterator end = paragraphs.end();
-       for (; it != end; ++it) {
-               for (int i = 0; i < it->size(); ++i) {
-                       if (it->isNewline(i)) {
-                               changed = true;
+       for (; it != end; ++it)
+               for (int i = 0; i < it->size(); ++i)
+                       if (it->isNewline(i))
                                it->erase(i);
-                       }
-               }
-       }
-       if (changed)
-               reinitLyXText();
 }
 
 
@@ -1956,7 +1834,6 @@ void InsetText::collapseParagraphs(Buffe
 
                mergeParagraph(bv->buffer()->params, paragraphs, first_par);
        }
-       reinitLyXText();
 }
 
 
@@ -1981,8 +1858,6 @@ void InsetText::appendParagraphs(Buffer 
        ParagraphList::iterator pend = plist.end();
        for (; pit != pend; ++pit)
                paragraphs.push_back(*pit);
-
-       reinitLyXText();
 }
 
 
Index: insets/insettext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v
retrieving revision 1.195
diff -u -p -r1.195 insettext.h
--- insets/insettext.h  5 Aug 2003 11:54:44 -0000       1.195
+++ insets/insettext.h  11 Aug 2003 08:23:41 -0000
@@ -13,7 +13,6 @@
 #define INSETTEXT_H
 
 #include "updatableinset.h"
-#include "textcursor.h"
 #include "LString.h"
 #include "LColor.h"
 #include "ParagraphList.h"
@@ -129,9 +128,9 @@ public:
        ///
        bool getAutoBreakRows() const { return autoBreakRows; }
        ///
-       void setDrawFrame(BufferView *, DrawFrame);
+       void setDrawFrame(DrawFrame);
        ///
-       void setFrameColor(BufferView *, LColor::color);
+       void setFrameColor(LColor::color);
        ///
        LyXText * getLyXText(BufferView const *,
                             bool const recursive = false) const;
@@ -140,8 +139,6 @@ public:
        ///
        void deleteLyXText(BufferView *, bool recursive = true) const;
        ///
-       void resizeLyXText(BufferView *, bool force = false) const;
-       ///
        bool showInsetDialog(BufferView *) const;
        ///
        void getLabelList(std::vector<string> &) const;
@@ -279,9 +276,7 @@ private:
        ///
        void clearInset(BufferView *, int start_x, int baseline) const;
        ///
-       void saveLyXTextState() const;
-       ///
-       void restoreLyXTextState() const;
+       void strangeInit() const;
        ///
        void collapseParagraphs(BufferView *);
 
@@ -307,9 +302,6 @@ private:
        ///
        mutable ParagraphList::iterator old_par;
 
-       /// some funny 'temporarily saved state'
-       mutable TextCursor sstate;
-
        ///
        // to remember old painted frame dimensions to clear it on the right spot!
        ///
@@ -320,8 +312,6 @@ private:
        int mouse_x;
        int mouse_y;
 public:
-       ///
-       void reinitLyXText() const;
        ///
        mutable LyXText text_;
        ///

Reply via email to