]> git.lyx.org Git - features.git/commitdiff
Changes to make text-inset work better (f.ex. cursor), and now we have
authorJürgen Vigna <jug@sad.it>
Fri, 16 Jun 2000 15:13:25 +0000 (15:13 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 16 Jun 2000 15:13:25 +0000 (15:13 +0000)
multi paragraph text insets!!!

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@818 a592a061-630c-0410-9148-cb99ea01b6c8

15 files changed:
ChangeLog
po/POTFILES.in
src/BufferView_pimpl.C
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/lyxfr1.C
src/lyxfunc.C
src/lyxtext.h
src/text.C
src/text2.C

index 3438c8f82dff1fe21200383f8fe6ef638abb339d..17d994b1b759e719da77227d9b3c318047257336 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2000-06-16  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/insettabular.C (UpdateLocal): 
+       * src/insets/insettext.C (UpdateLocal): fixed mark_dirty problem.
+       (LocalDispatch): Changed all functions to use LyXText.
+
+2000-06-15  Juergen Vigna  <jug@sad.it>
+
+       * src/text.C (SetHeightOfRow): call inset::update before requesting
+       any width/height.
+
+       * src/insets/insettext.C (update): 
+       * src/insets/insettabular.C (update): added implementation
+
+       * src/insets/lyxinset.h: added update function
+
 2000-06-15  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/text.C (SelectNextWord): protect against null pointers with
index fc50126cfd4e041b6c20b1e162fc7509b52987b6..b80c5a8da6a1dbe19107216b783712ecf189d476 100644 (file)
@@ -17,7 +17,6 @@ src/BufferView_pimpl.C
 src/bullet_forms.C
 src/bullet_forms_cb.C
 src/Chktex.C
-src/cite.C
 src/ColorHandler.C
 src/combox.C
 src/credits.C
index 731f4dd3943bfa49495b0af90700d15c10fbbbff..8613ee40b5c8d057ec5756a3fb49849f3dfee19f 100644 (file)
@@ -258,7 +258,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                        bv_->text->SetCursor(bv_, selstartpar, selstartpos);
                        bv_->text->sel_cursor = bv_->text->cursor;
                        bv_->text->SetCursor(bv_, selendpar, selendpos);
-                       bv_->text->SetSelection(bv_);
+                       bv_->text->SetSelection();
                        bv_->text->SetCursor(bv_, par, pos);
                } else {
                        bv_->text->SetCursor(bv_, par, pos);
@@ -507,7 +507,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
                if (!bv_->text->selection)
                        update(BufferView::UPDATE); // Maybe an empty line was deleted
       
-               bv_->text->SetSelection(bv_);
+               bv_->text->SetSelection();
                screen->ToggleToggle();
                fitCursor();
                screen->ShowCursor();
@@ -686,7 +686,7 @@ void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
                bv_->text->CursorHome(bv_);
                bv_->text->sel_cursor = bv_->text->cursor;
                bv_->text->CursorEnd(bv_);
-               bv_->text->SetSelection(bv_);
+               bv_->text->SetSelection();
                screen->ToggleSelection(false);
                /* This will fit the cursor on the screen
                 * if necessary */
index 5648e3c1ec06c43757fed2b1d295b94475e523c7..68f12ab101f36768546626ced3a4e5ab6d0ddf97 100644 (file)
@@ -166,7 +166,7 @@ void InsetCollapsable::Edit(BufferView * bv, int x, int y, unsigned int button)
 {
     if (collapsed && autocollapse) {
        collapsed = false;
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, false);
        InsetText::Edit(bv, 0, 0, button);
     } else if (!collapsed) {
        InsetText::Edit(bv, x, y, button);
@@ -188,13 +188,7 @@ void InsetCollapsable::InsetUnlock(BufferView * bv)
        collapsed = true;
     }
     InsetText::InsetUnlock(bv);
-    UpdateLocal(bv, false);
-}
-
-
-void InsetCollapsable::UpdateLocal(BufferView * bv, bool flag)
-{
-    InsetText::UpdateLocal(bv, flag);
+    UpdateLocal(bv, false, false);
 }
 
 
@@ -214,10 +208,10 @@ void InsetCollapsable::InsetButtonRelease(BufferView * bv,
        if (collapsed) {
            collapsed = false;
            InsetText::InsetButtonRelease(bv, 0, 0, button);
-           UpdateLocal(bv, true);
+           UpdateLocal(bv, true, false);
        } else {
            collapsed = true;
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
            bv->unlockInset(this);
        }
     } else if (!collapsed && (x >= button_length) && (y >= button_top_y)) {
index 604867de7d7cf1cab526e1e58f55536985e48084..bf21fb5506cb976f976d31a2e3f35f118b692a9f 100644 (file)
@@ -85,8 +85,6 @@ protected:
     ///
     void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
     ///
-    void UpdateLocal(BufferView *, bool);
-    ///
     int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
     
     ///
index 5a139487a1554655d48c2365b0ee109fd3ed0f0e..8a0cac3fea3a20df60a2b4bcd4d477e235f0bbba 100644 (file)
@@ -171,12 +171,12 @@ void InsetTabular::draw(Painter & pain, const LyXFont & font, int baseline,
 
     UpdatableInset::draw(pain,font,baseline,x);
     if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
-       int ox = top_x;
+//     int ox = top_x;
        init_inset = false;
        top_x = int(x);
        top_baseline = baseline;
-       if (ox != top_x)
-           recomputeTextInsets(pain, font);
+//     if (ox != top_x)
+//         recomputeTextInsets(pain, font);
        calculate_width_of_cells(pain, font);
        resetPos(pain);
        reinit = true;
@@ -202,6 +202,13 @@ void InsetTabular::draw(Painter & pain, const LyXFont & font, int baseline,
 }
 
 
+void InsetTabular::update(BufferView * bv, LyXFont const & font) const
+{
+    if (init_inset)
+       recomputeTextInsets(bv, font);
+}
+
+
 void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
                                  int row, int cell) const
 {
@@ -292,7 +299,7 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
     if (InsetHit(bv, x, y)) {
        ActivateCellInset(bv, x, y, button);
     }
-    UpdateLocal(bv, true);
+    UpdateLocal(bv, true, false);
 //    bv->getOwner()->getPopups().updateFormTabular();
 }
 
@@ -308,19 +315,19 @@ void InsetTabular::InsetUnlock(BufferView * bv)
     if (hasSelection()) {
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
     }
     no_selection = false;
     oldcell = -1;
     locked = false;
 }
 
-void InsetTabular::UpdateLocal(BufferView * bv, bool flag)
+void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
 {
-    if (flag)
+    if (what)
        calculate_width_of_cells(bv->painter(), LyXFont(LyXFont::ALL_SANE));
-    bv->updateInset(this, flag);
-    if (flag)
+    bv->updateInset(this, mark_dirty);
+    if (what)
        resetPos(bv->painter());
 }
 
@@ -385,7 +392,7 @@ bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
        return false;
     if (the_locking_inset != inset)
        return the_locking_inset->UpdateInsetInInset(bv, inset);
-    UpdateLocal(bv);
+    UpdateLocal(bv, true, false);
     return true;
 }
 
@@ -449,7 +456,7 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
 {
     if (hasSelection()) {
        sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
     }
     no_selection = false;
 
@@ -497,7 +504,7 @@ void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
        sel_pos_end = cursor.pos();
        sel_cell_end = actcell;
        if (old != sel_pos_end)
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
 #if 0
        if (ocell != actcell)
            bview->getOwner()->getPopups().updateFormTabular();
@@ -544,7 +551,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        else if (result == DISPATCHED) {
             bool upd = SetCellDimensions(bv->painter(), actcell, actrow);
            the_locking_inset->ToggleInsetCursor(bv);
-           UpdateLocal(bv, upd);
+           UpdateLocal(bv, upd, false);
            the_locking_inset->ToggleInsetCursor(bv);
             return result;
         } else if (result == FINISHED) {
@@ -579,14 +586,14 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
            else
                sel_cell_end = actcell;
        }
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_RIGHT:
        result = moveRight(bv);
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
        break;
     case LFUN_LEFTSEL:
        if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
@@ -600,14 +607,14 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
            else
                sel_cell_end = actcell-1;
        }
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_LEFT:
        result = moveLeft(bv);
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
        break;
     case LFUN_DOWNSEL:
     {
@@ -619,7 +626,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
            sel_cell_end = tabular->GetCellBelow(sel_cell_end);
        else
            sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
     }
     break;
     case LFUN_DOWN:
@@ -627,7 +634,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
        break;
     case LFUN_UPSEL:
     {
@@ -639,7 +646,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
            sel_cell_end = tabular->GetCellAbove(sel_cell_end);
        else
            sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
     }
     break;
     case LFUN_UP:
@@ -647,7 +654,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
        break;
     case LFUN_BACKSPACE:
        break;
@@ -670,7 +677,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
        break;
     case LFUN_LAYOUT_TABLE:
     {
@@ -1059,7 +1066,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        bool update = (tabular->GetPWidth(actcell) != val);
        tabular->SetPWidth(actcell,val);
        if (update)
-           UpdateLocal(bv, true);
+           UpdateLocal(bv, true, true);
     }
     break;
     case LyXTabular::SET_SPECIAL_COLUMN:
@@ -1070,34 +1077,34 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        // append the row into the tabular
        UnlockInsetInInset(bv, the_locking_inset);
        tabular->AppendRow(actcell);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     case LyXTabular::APPEND_COLUMN:
        // append the column into the tabular
        tabular->AppendColumn(actcell);
        actcell = tabular->GetCellNumber(row, column);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     case LyXTabular::DELETE_ROW:
        tabular->DeleteRow(tabular->row_of_cell(actcell));
        if ((row+1) > tabular->rows())
            --row;
        actcell = tabular->GetCellNumber(row, column);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     case LyXTabular::DELETE_COLUMN:
        tabular->DeleteColumn(tabular->column_of_cell(actcell));
        if ((column+1) > tabular->columns())
            --column;
        actcell = tabular->GetCellNumber(row, column);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     case LyXTabular::TOGGLE_LINE_TOP:
        lineSet = !tabular->TopLine(actcell);
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     
     case LyXTabular::TOGGLE_LINE_BOTTOM:
@@ -1105,7 +1112,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
                
     case LyXTabular::TOGGLE_LINE_LEFT:
@@ -1113,7 +1120,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
 
     case LyXTabular::TOGGLE_LINE_RIGHT:
@@ -1121,7 +1128,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     case LyXTabular::ALIGN_LEFT:
     case LyXTabular::ALIGN_RIGHT:
@@ -1129,7 +1136,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     case LyXTabular::MULTICOLUMN:
     {
@@ -1144,10 +1151,10 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
            // check wether we are completly in a multicol
            if (tabular->IsMultiColumn(actcell)) {
                tabular->UnsetMultiColumn(actcell);
-               UpdateLocal(bv, true);
+               UpdateLocal(bv, true, true);
            } else {
                tabular->SetMultiColumn(actcell, 1);
-               UpdateLocal(bv, false);
+               UpdateLocal(bv, false, true);
            }
            return;
        }
@@ -1168,7 +1175,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        cursor.pos(0);
        sel_cell_end = sel_cell_start;
        sel_pos_end = sel_pos_start;
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     }
     case LyXTabular::SET_ALL_LINES:
@@ -1177,15 +1184,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines);
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, true);
        break;
     case LyXTabular::SET_LONGTABULAR:
        tabular->SetLongTabular(true);
-       UpdateLocal(bv, true); // because this toggles displayed
+       UpdateLocal(bv, true, true); // because this toggles displayed
        break;
     case LyXTabular::UNSET_LONGTABULAR:
        tabular->SetLongTabular(false);
-       UpdateLocal(bv, true); // because this toggles displayed
+       UpdateLocal(bv, true, true); // because this toggles displayed
        break;
     case LyXTabular::SET_ROTATE_TABULAR:
        tabular->SetRotateTabular(true);
@@ -1249,7 +1256,7 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
     inset->Edit(bv, x - inset_x, y - inset_y, button);
     if (!the_locking_inset)
        return false;
-    UpdateLocal(bv, true);
+    UpdateLocal(bv, true, false);
     return true;
 }
 
@@ -1300,22 +1307,23 @@ int InsetTabular::getMaxWidth(Painter & pain,
     return w;
 }
 
-void InsetTabular::recomputeTextInsets(Painter & pain, const LyXFont & font) const
+void InsetTabular::recomputeTextInsets(BufferView * bv, const LyXFont & font) const
 {
     InsetText * inset;
-    int cx, cell;
+    int cell;
 
-    cx = top_x;
+//    cx = top_x;
     for(int j= 0; j < tabular->columns(); ++j) {
        for(int i = 0; i < tabular->rows(); ++i) {
            if (tabular->IsPartOfMultiColumn(i,j))
                continue;
            cell = tabular->GetCellNumber(i,j);
            inset = tabular->GetCellInset(cell);
-           inset->computeTextRows(pain);
-           tabular->SetWidthOfCell(cell, inset->width(pain, font));
+           inset->update(bv, font);
+           inset->computeTextRows(bv->painter());
+           tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font));
        }
-       cell = tabular->GetCellNumber(0, j);
-       cx += tabular->GetWidthOfColumn(cell);
+//     cell = tabular->GetCellNumber(0, j);
+//     cx += tabular->GetWidthOfColumn(cell);
     }
 }
index 4175f2376ff5b8e39a2600e770561eb3093ca0ec..7c5b1340da07b7815e76077bf9eb87f3cfcd2104 100644 (file)
@@ -82,13 +82,15 @@ public:
     ///
     void draw(Painter & pain, const LyXFont &, int , float &) const;
     ///
+    void update(BufferView *, LyXFont const &) const;
+    ///
     const char * EditMessage() const;
     ///
     void Edit(BufferView *, int x, int y, unsigned int);
     ///
     void InsetUnlock(BufferView *);
     ///
-    void UpdateLocal(BufferView *, bool flag = true);
+    void UpdateLocal(BufferView *, bool what, bool mark_dirty);
     ///
     bool LockInsetInInset(BufferView *, UpdatableInset *);
     ///
@@ -187,7 +189,7 @@ private:
     ///
     int GetMaxWidthOfCell(Painter &, int cell) const;
     ///
-    void recomputeTextInsets(Painter &, const LyXFont &) const;
+    void recomputeTextInsets(BufferView *, const LyXFont &) const;
 
     ///
     /// Private structures and variables
index e5eaf8902c5258ad174aeaf13a833bebcb7b4b12..bf90dc2a145b2189b9cf03b9bf073f826df66fde 100644 (file)
@@ -43,6 +43,9 @@
 #include "support/textutils.h"
 #include "support/LAssert.h"
 #include "lyxrow.h"
+#include "lyxrc.h"
+#include "intl.h"
+#include "trans_mgr.h"
 
 using std::ostream;
 using std::ifstream;
@@ -103,6 +106,7 @@ void InsetText::init(InsetText const * ins)
     selection_start_cursor = selection_end_cursor = cursor;
     frame_color = LColor::insetframe;
     locked = false;
+    old_par = 0;
 }
 
 
@@ -162,6 +166,9 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex)
            return;
        }
     }
+    if (!return_par)
+           return_par = par;
+    par = return_par;
     if (token != "\\end_inset") {
         lex.printError("Missing \\end_inset at this point. "
                        "Read: `$$Token'");
@@ -170,26 +177,16 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex)
 }
 
 
-int InsetText::ascent(Painter & pain, LyXFont const & font) const
+int InsetText::ascent(Painter &, LyXFont const &) const
 {
-    if (init_inset) {
-       text->init(current_view);
-       computeTextRows(pain);
-       init_inset = false;
-    }
     long int y_temp = 0;
     Row * row = text->GetRowNearY(y_temp);
     return row->ascent_of_text() + 2;
 }
 
 
-int InsetText::descent(Painter & pain, LyXFont const & font) const
+int InsetText::descent(Painter &, LyXFont const &) const
 {
-    if (init_inset) {
-       text->init(current_view);
-       computeTextRows(pain);
-       init_inset = false;
-    }
     long int y = 0;
     Row * row = text->GetRowNearY(y);
     return text->height - row->ascent_of_text() + 2;
@@ -198,14 +195,8 @@ int InsetText::descent(Painter & pain, LyXFont const & font) const
 
 int InsetText::width(Painter & pain, LyXFont const &) const
 {
-    if (init_inset) {
-       text->init(current_view);
-       computeTextRows(pain);
-       init_inset = false;
-    }
     return std::max(static_cast<long int>(getMaxTextWidth(pain, this)),
                    text->width);
-//    return insetWidth;
 }
 
 
@@ -214,12 +205,14 @@ void InsetText::draw(Painter & pain, LyXFont const & f,
 {
     xpos = x;
     UpdatableInset::draw(pain, f, baseline, x);
-    
+#if 0   
     if (init_inset) {
        text->init(current_view);
-           computeTextRows(pain);
-           init_inset = false;
-       }
+       computeTextRows(pain);
+       init_inset = false;
+    }
+#endif
     if ((baseline != top_baseline) || (top_x != int(x))) {
        top_baseline = baseline;
        top_x = int(x);
@@ -227,8 +220,8 @@ void InsetText::draw(Painter & pain, LyXFont const & f,
     }
     if (the_locking_inset && (text->cursor.pos() == inset_pos)) {
        resetPos(pain);
-       inset_x = text->cursor.x() - top_x + drawTextXOffset;
-       inset_y = text->cursor.y() + drawTextYOffset;
+       inset_x = cx() - top_x + drawTextXOffset;
+       inset_y = cy() + drawTextYOffset;
     }
     if (drawLockedFrame && locked) {
        pain.rectangle(int(x), baseline - ascent(pain, f), width(pain, f),
@@ -236,24 +229,9 @@ void InsetText::draw(Painter & pain, LyXFont const & f,
     }
     x += TEXT_TO_INSET_OFFSET; // place for border
 #if 1
-    // Dump all rowinformation:
-    long y_dummy = 0;
-    Row * tmprow = text->GetRowNearY(y_dummy);
-    lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
-    while (tmprow) {
-       lyxerr << tmprow->baseline() << '\t'
-              << tmprow->par() << '\t'
-              << tmprow->pos() << '\t'
-              << tmprow->height() << '\t'
-              << tmprow->ascent_of_text() << '\t'
-              << tmprow->fill() << '\n';
-       tmprow = tmprow->next();
-    }
-    lyxerr.flush();
     long int y = 0;
     Row * row = text->GetRowNearY(y);
     y += baseline - row->ascent_of_text() + 1;
-    text->width = 0;
     while (row != 0) {
        text->GetVisibleRow(current_view, y, x, row, y);
        y += row->height();
@@ -270,6 +248,32 @@ void InsetText::draw(Painter & pain, LyXFont const & f,
 }
 
 
+void InsetText::update(BufferView * bv, LyXFont const &) const
+{
+    if (init_inset) {
+       text->init(bv);
+       init_inset = false;
+#if 0
+       // Dump all rowinformation:
+       long y_dummy = 0;
+       Row * tmprow = text->GetRowNearY(y_dummy);
+       lyxerr << "Width = " << text->width << endl;
+       lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
+       while (tmprow) {
+               lyxerr << tmprow->baseline() << '\t'
+                      << tmprow->par() << '\t'
+                      << tmprow->pos() << '\t'
+                      << tmprow->height() << '\t'
+                      << tmprow->ascent_of_text() << '\t'
+                      << tmprow->fill() << '\n';
+               tmprow = tmprow->next();
+       }
+       lyxerr.flush();
+#endif
+    }
+}
+
+
 void InsetText::drawRowSelection(Painter & pain, int startpos, int endpos,
                                  int row, int baseline, float x) const
 {
@@ -392,9 +396,9 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
     setPos(bv->painter(), x, y);
     checkAndActivateInset(bv, x, y, button);
     selection_start_cursor = selection_end_cursor = cursor;
-    current_font = real_current_font =GetFont(bv->buffer(), par, cursor.pos());
+    text->sel_cursor = text->cursor;
     bv->text->FinishUndo();
-    UpdateLocal(bv, true);
+    UpdateLocal(bv, true, false);
 }
 
 
@@ -410,7 +414,7 @@ void InsetText::InsetUnlock(BufferView * bv)
     selection_start_cursor = selection_end_cursor = cursor;
     no_selection = false;
     locked = false;
-    UpdateLocal(bv, true);
+    UpdateLocal(bv, true, false);
 }
 
 
@@ -423,16 +427,16 @@ bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
        lyxerr[Debug::INSETS] << "OK" << endl;
        the_locking_inset = inset;
        resetPos(bv->painter());
-       inset_x = text->cursor.x() - top_x + drawTextXOffset;
-       inset_y = text->cursor.y() + drawTextYOffset;
+       inset_x = cx() - top_x + drawTextXOffset;
+       inset_y = cy() + drawTextYOffset;
        inset_pos = text->cursor.pos();
        return true;
     } else if (the_locking_inset && (the_locking_inset == inset)) {
        if (text->cursor.pos() == inset_pos) {
            lyxerr[Debug::INSETS] << "OK" << endl;
            resetPos(bv->painter());
-           inset_x = text->cursor.x() - top_x + drawTextXOffset;
-           inset_y = text->cursor.y() + drawTextYOffset;
+           inset_x = cx() - top_x + drawTextXOffset;
+           inset_y = cy() + drawTextYOffset;
        } else {
            lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
        }
@@ -469,10 +473,10 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
         return the_locking_inset->UpdateInsetInInset(bv, inset);
     lyxerr[Debug::INSETS] << "InsetText::UpdateInsetInInset(" << inset <<
            ")" << endl;
-    UpdateLocal(bv, true);
+    UpdateLocal(bv, true, false);
     if (text->cursor.pos() == inset_pos) {
-       inset_x = text->cursor.x() - top_x + drawTextXOffset;
-       inset_y = text->cursor.y() + drawTextYOffset;
+       inset_x = cx() - top_x + drawTextXOffset;
+       inset_y = cy() + drawTextYOffset;
     }
     return true;
 }
@@ -482,7 +486,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
 {
     if (hasSelection()) {
        selection_start_cursor = selection_end_cursor = cursor;
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
     }
     no_selection = false;
     setPos(bv->painter(), x, y);
@@ -501,7 +505,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
            inset_y = cursor.y() + drawTextYOffset;
            inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
            inset->Edit(bv, x - inset_x, y - inset_y, button);
-           UpdateLocal(bv, true);
+           UpdateLocal(bv, true, false);
            return;
        }
        // otherwise only unlock the_locking_inset
@@ -518,7 +522,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
            inset_y = cursor.y() + drawTextYOffset;
            inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
            inset->Edit(bv, x - inset_x, y - inset_y, 0);
-           UpdateLocal(bv, true);
+           UpdateLocal(bv, true, false);
        }
     }
     selection_start_cursor = selection_end_cursor = cursor;
@@ -561,7 +565,7 @@ void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int state)
        setPos(bv->painter(), x, y);
        selection_end_cursor = cursor;
        if (old != selection_end_cursor)
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
        ShowInsetCursor(bv);
     }
     no_selection = false;
@@ -602,7 +606,7 @@ InsetText::LocalDispatch(BufferView * bv,
            return result;
        else if (result == DISPATCHED) {
            the_locking_inset->ToggleInsetCursor(bv);
-           UpdateLocal(bv, false);
+           UpdateLocal(bv, false, false);
            the_locking_inset->ToggleInsetCursor(bv);
             return result;
         } else if (result == FINISHED) {
@@ -624,200 +628,140 @@ InsetText::LocalDispatch(BufferView * bv,
     switch (action) {
        // Normal chars
     case -1:
-       bv->text->SetUndo(bv->buffer(), Undo::INSERT, 
-           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
-           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       cutSelection(bv->buffer());
-       cursor = selection_start_cursor;
-       par->InsertChar(cursor.pos(), arg[0]);
-       SetCharFont(bv->buffer(), cursor.pos(), current_font);
-       cursor.pos(cursor.pos() + 1);
-       selection_start_cursor = selection_end_cursor = cursor;
-       UpdateLocal(bv, true);
+       if (bv->buffer()->isReadonly()) {
+           LyXBell();
+//         setErrorMessage(N_("Document is read only"));
+           break;
+       }
+       if (!arg.empty()) {
+           /* Automatically delete the currently selected
+            * text and replace it with what is being
+            * typed in now. Depends on lyxrc settings
+            * "auto_region_delete", which defaults to
+            * true (on). */
+
+           bv->text->SetUndo(bv->buffer(), Undo::INSERT, 
+                             bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
+                             bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
+           if (lyxrc.auto_region_delete) {
+               if (text->selection){
+                   text->CutSelection(bv, false);
+               }
+           }
+           text->ClearSelection();
+           for (string::size_type i = 0; i < arg.length(); ++i) {
+               bv->owner()->getIntl()->getTrans()->TranslateAndInsert(arg[i], text);
+           }
+       }
+       UpdateLocal(bv, true, true);
        break;
         // --- Cursor Movements ---------------------------------------------
     case LFUN_RIGHTSEL:
        bv->text->FinishUndo();
        moveRight(bv, false);
-       selection_end_cursor = cursor;
-       UpdateLocal(bv, false);
+       text->SetSelection();
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_RIGHT:
        bv->text->FinishUndo();
        result = moveRight(bv);
-       if (hasSelection()) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, false);
-       } else {
-           selection_start_cursor = selection_end_cursor = cursor;
-       }
+       text->sel_cursor = text->cursor;
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_LEFTSEL:
        bv->text->FinishUndo();
        moveLeft(bv, false);
-       selection_end_cursor = cursor;
-       UpdateLocal(bv, false);
+       text->SetSelection();
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_LEFT:
        bv->text->FinishUndo();
        result= moveLeft(bv);
-       if (hasSelection()) {
-               selection_start_cursor = selection_end_cursor = cursor;
-               UpdateLocal(bv, false);
-       } else {
-               selection_start_cursor = selection_end_cursor = cursor;
-       }
+       text->sel_cursor = text->cursor;
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_DOWNSEL:
        bv->text->FinishUndo();
        moveDown(bv);
        selection_end_cursor = cursor;
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_DOWN:
        bv->text->FinishUndo();
        result = moveDown(bv);
-       if (hasSelection()) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, false);
-       } else {
-           selection_start_cursor = selection_end_cursor = cursor;
-       }
+       text->sel_cursor = text->cursor;
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_UPSEL:
        bv->text->FinishUndo();
        moveUp(bv);
        selection_end_cursor = cursor;
-       UpdateLocal(bv, false);
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_UP:
        bv->text->FinishUndo();
        result = moveUp(bv);
-       if (hasSelection()) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, false);
-       } else {
-           selection_start_cursor = selection_end_cursor = cursor;
-       }
+       text->sel_cursor = text->cursor;
+       UpdateLocal(bv, false, false);
+       break;
+    case LFUN_HOME:
+       bv->text->FinishUndo();
+       text->CursorHome(bv);
+       text->sel_cursor = text->cursor;
+       UpdateLocal(bv, false, false);
+       break;
+    case LFUN_END:
+       text->CursorEnd(bv);
+       text->sel_cursor = text->cursor;
+       UpdateLocal(bv, false, false);
        break;
     case LFUN_BACKSPACE:
-       if (!cursor.pos()) {
-           if (hasSelection()) {
-               selection_start_cursor = selection_end_cursor = cursor;
-               UpdateLocal(bv, false);
-           }
-           break;
-       }
-       moveLeft(bv);
+       bv->text->SetUndo(bv->buffer(), Undo::DELETE, 
+         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
+         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
+       text->Backspace(bv);
+       UpdateLocal(bv, true, true);
+       break;
     case LFUN_DELETE:
-    {
-       bv->text->SetUndo(bv->buffer(), Undo::DELETE, 
-           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
-           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       bool ret = true;
-       if (hasSelection()) {
-           LyXParagraph::size_type i = selection_start_cursor.pos();
-           for (; i < selection_end_cursor.pos(); ++i) {
-               par->Erase(selection_start_cursor.pos());
-           }
-       } else
-           ret = Delete();
-       if (ret) { // we need update
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, true);
-       } else if (hasSelection()) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, false);
-       }
-    }
-    resetPos(bv->painter());
-    break;
+       bv->text->SetUndo(bv->buffer(), Undo::DELETE, 
+         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
+         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
+       text->Delete(bv);
+       UpdateLocal(bv, true, true);
+       break;
     case LFUN_CUT:
        bv->text->SetUndo(bv->buffer(), Undo::DELETE, 
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-
-       if (cutSelection(bv->buffer())) {
-           // we need update
-           cursor = selection_end_cursor = selection_start_cursor;
-           UpdateLocal(bv, true);
-       } else if (hasSelection()) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, false);
-       }
-       resetPos(bv->painter());
+       text->CutSelection(bv);
+       UpdateLocal(bv, true, true);
        break;
     case LFUN_COPY:
        bv->text->FinishUndo();
-       if (copySelection(bv->buffer())) {
-           // we need update
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, true);
-       } else if (hasSelection()) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, false);
-       }
+       text->CopySelection(bv);
+       UpdateLocal(bv, true, false);
        break;
     case LFUN_PASTE:
-    {
        bv->text->SetUndo(bv->buffer(), Undo::INSERT, 
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       if (pasteSelection(bv->buffer())) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, true);
-       }
-    }
-    resetPos(bv->painter());
-    break;
-    case LFUN_HOME:
-       bv->text->FinishUndo();
-       for(; cursor.pos() > rows[actrow].pos;) {
-               cursor.x(cursor.x() - SingleWidth(bv->painter(), par, cursor.pos()));
-               cursor.pos(cursor.pos() - 1);
-       }
-       
-       cursor.x(cursor.x() - SingleWidth(bv->painter(), par, cursor.pos()));
-       if (hasSelection()) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, false);
-       } else {
-           selection_start_cursor = selection_end_cursor = cursor;
-       }
-       resetPos(bv->painter());
+       text->PasteSelection(bv);
+       UpdateLocal(bv, true, true);
        break;
-    case LFUN_END:
-    {
-       bv->text->FinishUndo();
-       int checkpos = (int)rows[actrow + 1].pos;
-       if ((actrow + 2) < (int)rows.size())
-           --checkpos;
-       for(; cursor.pos() < checkpos;) {
-           cursor.x(cursor.x() + SingleWidth(bv->painter(), par, cursor.pos()));
-           cursor.pos(cursor.pos() + 1);
-       }
-       if (hasSelection()) {
-           selection_start_cursor = selection_end_cursor = cursor;
-           UpdateLocal(bv, false);
-       } else {
-           selection_start_cursor = selection_end_cursor = cursor;
-       }
-    }
-    resetPos(bv->painter());
-    break;
     case LFUN_BREAKPARAGRAPH:
+       if (!autoBreakRows)
+           return DISPATCHED;
+       text->BreakParagraph(bv, 0);
+       UpdateLocal(bv, true, true);
+       break;
     case LFUN_BREAKLINE:
        if (!autoBreakRows)
            return DISPATCHED;
        bv->text->SetUndo(bv->buffer(), Undo::INSERT, 
            bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
            bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       par->InsertChar(cursor.pos(),LyXParagraph::META_NEWLINE);
-       SetCharFont(bv->buffer(), cursor.pos(),current_font);
-       UpdateLocal(bv, true);
-       cursor.pos(cursor.pos() + 1);
-       selection_start_cursor = selection_end_cursor = cursor;
-       resetPos(bv->painter());
+       text->InsertChar(bv, LyXParagraph::META_NEWLINE);
+       UpdateLocal(bv, true, true);
        break;
     case LFUN_LAYOUT:
     {
@@ -850,7 +794,7 @@ InsetText::LocalDispatch(BufferView * bv,
            cur_layout = layout.second;
            text->SetLayout(bv, layout.second);
            bv->owner()->getToolbar()->combox->select(cursor.par()->GetLayout()+1);
-           UpdateLocal(bv, true);
+           UpdateLocal(bv, true, true);
        }
     }
     break;
@@ -1002,7 +946,7 @@ LyXFont InsetText::GetFont(Buffer const * buf, LyXParagraph * p, int pos) const
 // the font for drawing may be different from the real font
 LyXFont InsetText::GetDrawFont(Buffer const * buf, LyXParagraph * p, int pos) const
 {
-    return GetFont(buf, p, pos);
+    return text->GetFont(buf, p, pos);
 }
 
 
@@ -1039,17 +983,15 @@ void InsetText::ToggleInsetCursor(BufferView * bv)
         return;
     }
 
-    LyXFont font = GetDrawFont(bv->buffer(), par, text->cursor.pos());
+    LyXFont font = GetDrawFont(bv->buffer(), cpar(), cpos());
 
     int asc = lyxfont::maxAscent(font);
     int desc = lyxfont::maxDescent(font);
   
-    asc = text->cursor.row()->ascent_of_text();
-    desc = text->cursor.row()->height() - asc;
     if (cursor_visible)
         bv->hideLockedInsetCursor();
     else
-        bv->showLockedInsetCursor(text->cursor.x(), text->cursor.y(),
+        bv->showLockedInsetCursor(cx(), cy(),
                                  asc, desc);
     cursor_visible = !cursor_visible;
 }
@@ -1062,14 +1004,13 @@ void InsetText::ShowInsetCursor(BufferView * bv)
        return;
     }
     if (!cursor_visible) {
-       LyXFont font = GetDrawFont(bv->buffer(), par, cursor.pos());
+       LyXFont font = GetDrawFont(bv->buffer(), cpar(), cpos());
        
        int asc = lyxfont::maxAscent(font);
        int desc = lyxfont::maxDescent(font);
-       asc = text->cursor.row()->ascent_of_text();
-       desc = text->cursor.row()->height() - asc;
-       bv->fitLockedInsetCursor(text->cursor.x(), text->cursor.y(), asc, desc);
-       bv->showLockedInsetCursor(text->cursor.x(), text->cursor.y(), asc, desc);
+
+       bv->fitLockedInsetCursor(cx(), cy(), asc, desc);
+       bv->showLockedInsetCursor(cx(), cy(), asc, desc);
        cursor_visible = true;
     }
 }
@@ -1153,14 +1094,13 @@ void InsetText::resetPos(Painter & pain) const
 UpdatableInset::RESULT
 InsetText::moveRight(BufferView * bv, bool activate_inset)
 {
-    if (cursor.pos() >= par->Last())
+    if (!cpar()->next && (cpos() >= cpar()->Last()))
        return FINISHED;
     if (activate_inset && checkAndActivateInset(bv)) {
        return DISPATCHED;
     }
-    cursor.pos(cursor.pos() + 1);
-    resetPos(bv->painter());
-    real_current_font = current_font =GetFont(bv->buffer(), par, cursor.pos());
+    text->CursorRight(bv);
+//    real_current_font = current_font = GetFont(bv->buffer(), cpar(), cpos());
     return DISPATCHED_NOUPDATE;
 }
 
@@ -1168,10 +1108,9 @@ InsetText::moveRight(BufferView * bv, bool activate_inset)
 UpdatableInset::RESULT
 InsetText::moveLeft(BufferView * bv, bool activate_inset)
 {
-    if (cursor.pos() <= 0)
+    if (!cpar()->previous && (cpos() <= 0))
        return FINISHED;
-    cursor.pos(cursor.pos() - 1);
-    resetPos(bv->painter());
+    text->CursorLeft(bv);
     if (activate_inset)
        if (checkAndActivateInset(bv, -1, -1))
            return DISPATCHED;
@@ -1182,13 +1121,9 @@ InsetText::moveLeft(BufferView * bv, bool activate_inset)
 UpdatableInset::RESULT
 InsetText::moveUp(BufferView * bv)
 {
-    if (!actrow)
+    if (!crow()->previous())
        return FINISHED;
-    cursor.y(rows[actrow - 1].baseline - top_baseline);
-    if (cursor.x_fix() < 0)
-       cursor.x_fix(cursor.x());
-    setPos(bv->painter(),
-          cursor.x_fix() - top_x + drawTextXOffset, cursor.y());
+    text->CursorUp(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -1196,13 +1131,9 @@ InsetText::moveUp(BufferView * bv)
 UpdatableInset::RESULT
 InsetText::moveDown(BufferView * bv)
 {
-    if (actrow >= int(rows.size() - 2))
+    if (!crow()->next())
        return FINISHED;
-    cursor.y(rows[actrow + 1].baseline - top_baseline);
-    if (cursor.x_fix() < 0)
-       cursor.x_fix(cursor.x());
-    setPos(bv->painter(),
-          cursor.x_fix() - top_x + drawTextXOffset, cursor.y());
+    text->CursorDown(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -1239,7 +1170,7 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
     } else {
        selection_start_cursor = selection_end_cursor = cursor;
     }
-    UpdateLocal(bv, true);
+    UpdateLocal(bv, true, true);
     static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);
     return true;
 }
@@ -1263,74 +1194,7 @@ UpdatableInset * InsetText::GetFirstLockingInsetOfType(Inset::Code c)
 
 void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
 {
-    // if there is no selection just set the current_font
-    if (!hasSelection()) {
-       // Determine basis font
-       LyXFont layoutfont;
-       if (cursor.pos() < BeginningOfMainBody(bv->buffer(), par))
-           layoutfont = GetFont(bv->buffer(), par, -2);
-       else
-           layoutfont = GetFont(bv->buffer(), par, -1);
-       
-       // Update current font
-       real_current_font.update(font, bv->buffer()->params.language_info,
-                                toggleall);
-       
-       // Reduce to implicit settings
-       current_font = real_current_font;
-       current_font.reduce(layoutfont);
-       // And resolve it completely
-       real_current_font.realize(layoutfont);
-       return;
-    }
-    
-    int s_start, s_end;
-    if (selection_start_cursor.pos() > selection_end_cursor.pos()) {
-       s_start = selection_end_cursor.pos();
-       s_end = selection_start_cursor.pos();
-    } else {
-       s_start = selection_start_cursor.pos();
-       s_end = selection_end_cursor.pos();
-    }
-    LyXFont newfont;
-    while(s_start < s_end) {
-       newfont = GetFont(bv->buffer(), par,s_start);
-       newfont.update(font, bv->buffer()->params.language_info, toggleall);
-       SetCharFont(bv->buffer(), s_start, newfont);
-       ++s_start;
-    }
-    UpdateLocal(bv, true);
-}
-
-
-void InsetText::SetCharFont(Buffer const * buf, int pos, LyXFont const & f) // 
-{
-    /* let the insets convert their font */
-       LyXFont font(f);
-       
-    if (par->GetChar(pos) == LyXParagraph::META_INSET) {
-       if (par->GetInset(pos))
-           font = par->GetInset(pos)->ConvertFont(font);
-    }
-    LyXLayout const & layout =
-           textclasslist.Style(buf->params.textclass,par->GetLayout());
-
-    // Get concrete layout font to reduce against
-    LyXFont layoutfont;
-
-    if (pos < BeginningOfMainBody(buf, par))
-       layoutfont = layout.labelfont;
-    else
-       layoutfont = layout.font;
-
-
-    layoutfont.realize((textclasslist.TextClass(buf->params.textclass).
-                      defaultfont()));
-
-    // Now, reduce font against full layout font
-    font.reduce(layoutfont);
-
-    par->SetFont(pos, font);
+    text->SetFont(bv, font, toggleall);
 }
 
 
@@ -1503,17 +1367,18 @@ void InsetText::computeBaselines(int baseline) const
 }
 
 
-void InsetText::UpdateLocal(BufferView * bv, bool flag)
+void InsetText::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
 {
-    if (flag) {
+    if (what) {
        text->FullRebreak(bv);
-       computeTextRows(bv->painter());
-       computeBaselines(top_baseline);
     }
-    bv->updateInset(this, flag);
-    if (flag)
-       resetPos(bv->painter());
-    bv->owner()->getToolbar()->combox->select(cursor.par()->GetLayout()+1);
+    bv->updateInset(this, mark_dirty);
+//    if (flag)
+//     resetPos(bv->painter());
+    if (old_par != cpar()) {
+           bv->owner()->getToolbar()->combox->select(cpar()->GetLayout()+1);
+           old_par = cpar();
+    }
 }
 
 
@@ -1583,7 +1448,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
     if (par->GetChar(cursor.pos()) == LyXParagraph::META_INSET) {
        UpdatableInset * inset =
            static_cast<UpdatableInset*>(par->GetInset(cursor.pos()));
-       LyXFont font = GetFont(bv->buffer(), par, cursor.pos());
+       LyXFont font = text->GetFont(bv->buffer(), cpar(), cpos());
        if (x < 0)
            x = inset->width(bv->painter(), font);
        if (y < 0)
@@ -1593,7 +1458,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
        inset->Edit(bv, x - inset_x, y - inset_y, button);
        if (!the_locking_inset)
            return false;
-       UpdateLocal(bv, true);
+       UpdateLocal(bv, true, false);
        return true;
     }
     return false;
@@ -1639,3 +1504,30 @@ void InsetText::SetFrameColor(LColor::color col)
        init_inset = true;
     }
 }
+
+int InsetText::cx() const
+{
+    return text->cursor.x() + top_x + 1;
+}
+
+int InsetText::cy() const
+{
+    long int y_dummy = 0;
+    Row * tmprow = text->GetRowNearY(y_dummy);
+    return text->cursor.y() - tmprow->baseline();
+}
+
+int InsetText::cpos() const
+{
+    return text->cursor.pos();
+}
+
+LyXParagraph * InsetText::cpar() const
+{
+    return text->cursor.par();
+}
+
+Row * InsetText::crow() const
+{
+    return text->cursor.row();
+}
index e76ea919f0ca24bbc0b557612853542aa4d5070b..36a32ebd46d9e565ffb27c1d66c342991cc41224 100644 (file)
@@ -64,6 +64,8 @@ public:
     ///
     void draw(Painter & pain, LyXFont const &, int , float &) const;
     ///
+    void update(BufferView *, LyXFont const &) const;
+    ///
     char const * EditMessage() const;
     ///
     void Edit(BufferView *, int, int, unsigned int);
@@ -129,7 +131,7 @@ public:
 
 protected:
     ///
-    void UpdateLocal(BufferView *, bool);
+    void UpdateLocal(BufferView *, bool what, bool mark_dirty);
     ///
     void WriteParagraphData(Buffer const *, std::ostream &) const;
     ///
@@ -211,6 +213,11 @@ private:
     ///
     bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
                               int button = 0);
+    int cx() const;
+    int cy() const;
+    int cpos() const;
+    LyXParagraph * cpar() const;
+    Row * crow() const;
        
     /* Private structures and variables */
     ///
@@ -256,5 +263,7 @@ private:
     typedef std::vector<row_struct> RowList;
     ///
     mutable RowList rows;
+    ///
+    LyXParagraph * old_par;
 };
 #endif
index e6ecafbd90a5ba37330848e169c3f09a9e7dee2e..a4fe8ad2b9e373931f62cd89e979aa53ac031eb8 100644 (file)
@@ -117,6 +117,8 @@ public:
        ///
        virtual void draw(Painter &, LyXFont const &,
                          int baseline, float & x) const = 0;
+       /// update the inset representation
+       virtual void update(BufferView *, LyXFont const &) const {}
        ///
        virtual LyXFont ConvertFont(LyXFont font);
        /// what appears in the minibuffer when opening
index b2282715aaf694f83db4d2dbbf2ea272ff8e2a31..13c928b5b5905a15a1da17903251f092ccf264e8 100644 (file)
@@ -82,7 +82,7 @@ void SetSelectionOverLenChars(BufferView * bv, int len)
        bv->text->sel_cursor = bv->text->cursor;
        for (int i = 0; i < len; ++i)
                bv->text->CursorRight(bv);
-       bv->text->SetSelection(bv);
+       bv->text->SetSelection();
 }
 
 
index 94d671f8ade6853d8348f9514c5c80fb9458aba9..030c0d3a87f341d03c0354c0c5a10483c7638c4a 100644 (file)
@@ -163,7 +163,7 @@ inline
 void LyXFunc::moveCursorUpdate(bool selecting)
 {
        if (selecting || owner->view()->text->mark_set) {
-               owner->view()->text->SetSelection(owner->view());
+               owner->view()->text->SetSelection();
                owner->view()->toggleToggle();
        }
        owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
@@ -531,11 +531,10 @@ string LyXFunc::Dispatch(int ac,
        if (owner->view()->available() &&
            owner->view()->the_locking_inset) {
                UpdatableInset::RESULT result;
-               if (action > 1
-                   || (action == LFUN_UNKNOWN_ACTION
-                       && keyseq.length >= -1)) {
-                       if (action == LFUN_UNKNOWN_ACTION
-                           && argument.empty()) {
+               if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
+                                    (keyseq.length >= -1)))
+               {
+                       if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
                                argument = keyseq.getiso();
                        }
                        // Undo/Redo pre 0.13 is a bit tricky for insets.
index d2ea4a6a86273352b58e9aebcdcc4d98788216c3..eb91ea29cba0c03b317b1ff6a36b445650d56575 100644 (file)
@@ -189,6 +189,7 @@ public:
         */
        Row * GetRow(LyXParagraph * par,
                     LyXParagraph::size_type pos, long & y) const;
+
        /** returns the height of a default row, needed  for scrollbar
         */
        int DefaultHeight() const;
@@ -224,7 +225,7 @@ public:
        LyXCursor toggle_end_cursor;
    
        /// need the selection cursor:
-       void SetSelection(BufferView *);
+       void SetSelection();
        ///
        void ClearSelection() const;
        ///
index c16548a436cb1809d8fe4dd35f51fadad7c72f84..4f5519891b901c0a025e24ef45152db54a6aa489 100644 (file)
@@ -246,11 +246,11 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par,
                font.decSize();
                return lyxfont::width(fs, font);
        } else if (c == LyXParagraph::META_INSET) {
-               Inset * tmpinset= par->GetInset(pos);
-               if (tmpinset)
-                       return par->GetInset(pos)->width(bview->painter(),
-                                                        font);
-               else
+               Inset * tmpinset = par->GetInset(pos);
+               if (tmpinset) {
+                       tmpinset->update(bview, font);
+                       return tmpinset->width(bview->painter(), font);
+               else
                        return 0;
 
        } else if (IsSeparatorChar(c))
@@ -1424,25 +1424,26 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
    int maxdesc = int(lyxfont::maxDescent(font) *
                    layout.spacing.getValue() *
                    spacing_val);
-
    int pos_end = RowLast(row_ptr);
-   
    int labeladdon = 0;
+   int maxwidth = 0;
 
    // Check if any insets are larger
    for (pos = row_ptr->pos(); pos <= pos_end; ++pos) {
-      if (row_ptr->par()->GetChar(pos) == LyXParagraph::META_INSET) {
-        tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
-         tmpinset = row_ptr->par()->GetInset(pos);
-         if (tmpinset) {
-            asc = tmpinset->ascent(bview->painter(), tmpfont);
-            desc = tmpinset->descent(bview->painter(), tmpfont);
-           if (asc > maxasc) 
-             maxasc = asc;
-           if (desc > maxdesc)
-             maxdesc = desc;
-        }
-      }
+          if (row_ptr->par()->GetChar(pos) == LyXParagraph::META_INSET) {
+                  tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
+                  tmpinset = row_ptr->par()->GetInset(pos);
+                  if (tmpinset) {
+                          tmpinset->update(bview, tmpfont);
+                          asc = tmpinset->ascent(bview->painter(), tmpfont);
+                          desc = tmpinset->descent(bview->painter(), tmpfont);
+                          maxwidth += tmpinset->width(bview->painter(), tmpfont);
+                          maxasc = max(maxasc, asc);
+                          maxdesc = max(maxdesc, desc);
+                  }
+          } else {
+                  maxwidth += SingleWidth(bview, row_ptr->par(), pos);
+          }
    }
 
    // Check if any custom fonts are larger (Asger)
@@ -1678,6 +1679,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
    row_ptr->baseline(maxasc + labeladdon);
    
    height += row_ptr->height();
+   width = maxwidth;
 }
 
 
@@ -3147,7 +3149,7 @@ void LyXText::SelectWord(BufferView * bview)
        SetCursor(bview, cursor.par(), cursor.pos() );
        
        // finally set the selection
-       SetSelection(bview);
+       SetSelection();
 }
 
 
@@ -3282,7 +3284,7 @@ void LyXText::SelectSelectedWord(BufferView * bview)
        SetCursor(bview, cursor.par(), cursor.pos());
        
        // finally set the selection
-       SetSelection(bview);
+       SetSelection();
 }
 
 
@@ -3299,7 +3301,7 @@ void LyXText::DeleteWordForward(BufferView * bview)
                SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
                sel_cursor = cursor;
                cursor = tmpcursor;
-               SetSelection(bview); 
+               SetSelection(); 
                
                /* -----> Great, CutSelection() gets rid of multiple spaces. */
                CutSelection(bview);
@@ -3320,7 +3322,7 @@ void LyXText::DeleteWordBackward(BufferView * bview)
               SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
               sel_cursor = cursor;
               cursor = tmpcursor;
-              SetSelection(bview);
+              SetSelection();
               CutSelection(bview);
        }
 }
@@ -3342,7 +3344,7 @@ void LyXText::DeleteLineForward(BufferView * bview)
                SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
                sel_cursor = cursor;
                cursor = tmpcursor;
-               SetSelection(bview);
+               SetSelection();
                // What is this test for ??? (JMarc)
                if (!selection) {
                        DeleteWordForward(bview);
@@ -3814,7 +3816,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                                           LColor::selection);
                        } else if (sel_start_cursor.row() == row_ptr) {
                                if (is_rtl)
-                                       pain.fillRectangle(0, y_offset,
+                                       pain.fillRectangle(x_offset, y_offset,
                                                           sel_start_cursor.x(),
                                                           row_ptr->height(),
                                                           LColor::selection);
@@ -3830,13 +3832,13 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                                           row_ptr->height(),
                                                           LColor::selection);
                                else
-                                       pain.fillRectangle(0, y_offset,
+                                       pain.fillRectangle(x_offset, y_offset,
                                                           sel_end_cursor.x(),
                                                           row_ptr->height(),
                                                           LColor::selection);
                        } else if (y > long(sel_start_cursor.y())
                                   && y < long(sel_end_cursor.y())) {
-                               pain.fillRectangle(0, y_offset,
+                               pain.fillRectangle(x_offset, y_offset,
                                                   ww, row_ptr->height(),
                                                   LColor::selection);
                        }
@@ -3844,7 +3846,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                            sel_end_cursor.row() != row_ptr &&
                            y > long(sel_start_cursor.y())
                            && y < long(sel_end_cursor.y())) {
-                       pain.fillRectangle(0, y_offset, ww, row_ptr->height(),
+                       pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height(),
                                           LColor::selection);
                } else if (sel_start_cursor.row() == row_ptr ||
                           sel_end_cursor.row() == row_ptr) {
@@ -3858,7 +3860,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
 #endif
                        if ( (sel_start_cursor.row() != row_ptr && !is_rtl) ||
                             (sel_end_cursor.row() != row_ptr && is_rtl))
-                               pain.fillRectangle(0, y_offset,
+                               pain.fillRectangle(x_offset, y_offset,
                                                   int(tmpx),
                                                   row_ptr->height(),
                                                   LColor::selection);
@@ -4625,8 +4627,6 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
 #ifndef NEW_TABULAR
        }
 #endif
-       // Jürgen!!! FIX This! (NOW!!!) (please)
-       width = max(x - x_offset, float(width));
 }
 
 
index 6ab5764b58f079b239606741ab5bcaf7902d072a..778e1dd368533923a105ae602f094d20d74d82e9 100644 (file)
@@ -68,7 +68,7 @@ void LyXText::init()
        lastrow = 0;
        number_of_rows = 0;
        refresh_y = 0;
-       height = 0;
+       height = width = 0;
        status = LyXText::UNCHANGED;
        // set cursor at the very top position
        selection = true;           /* these setting is necessary 
@@ -132,6 +132,7 @@ void LyXText::init(BufferView * bview)
 #if 1
        // Dump all rowinformation:
        Row * tmprow = firstrow;
+       lyxerr << "Width = " << width << endl;
        lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
        while (tmprow) {
                lyxerr << tmprow->baseline() << '\t'
@@ -681,7 +682,7 @@ void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout)
                  false);
        UpdateCounters(bview, cursor.row());
        ClearSelection();
-       SetSelection(bview);
+       SetSelection();
        SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
 }
 
@@ -767,7 +768,7 @@ void  LyXText::IncDepth(BufferView * bview)
        SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
        UpdateCounters(bview, cursor.row());
        ClearSelection();
-       SetSelection(bview);
+       SetSelection();
        SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
 }
 
@@ -828,7 +829,7 @@ void  LyXText::DecDepth(BufferView * bview)
        SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
        UpdateCounters(bview, cursor.row());
        ClearSelection();
-       SetSelection(bview);
+       SetSelection();
        SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
 }
 
@@ -898,7 +899,7 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall)
        sel_cursor = cursor;
        SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
        ClearSelection();
-       SetSelection(bview);
+       SetSelection();
        SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
                  tmpcursor.boundary());
 }
@@ -1064,7 +1065,7 @@ bool LyXText::FullRebreak(BufferView * bview)
  * They also delete the corresponding row */
    
 // need the selection cursor:
-void LyXText::SetSelection(BufferView * bview)
+void LyXText::SetSelection()
 {
        if (!selection) {
                last_sel_cursor = sel_cursor;
@@ -1452,7 +1453,7 @@ void LyXText::SetParagraph(BufferView * bview,
        SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
        sel_cursor = cursor;
        SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
-       SetSelection(bview);
+       SetSelection();
        SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
 }
 
@@ -1517,7 +1518,7 @@ void LyXText::SetParagraphExtraOpt(BufferView * bview, int type,
        SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
        sel_cursor = cursor;
        SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
-       SetSelection(bview);
+       SetSelection();
        SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
 }
 
@@ -2020,26 +2021,6 @@ void LyXText::InsertInset(BufferView * bview, Inset *inset)
 }
 
 
-#ifdef USE_OLD_CUT_AND_PASTE
-// this is for the simple cut and paste mechanism
-static LyXParagraph * simple_cut_buffer = 0;
-static char simple_cut_buffer_textclass = 0;
-
-void DeleteSimpleCutBuffer()
-{
-       if (!simple_cut_buffer)
-               return;
-       LyXParagraph * tmppar;
-
-       while (simple_cut_buffer) {
-               tmppar =  simple_cut_buffer;
-               simple_cut_buffer = simple_cut_buffer()->next;
-               delete tmppar;
-       }
-       simple_cut_buffer = 0;
-}
-#endif
-
 void LyXText::copyEnvironmentType()
 {
        copylayouttype = cursor.par()->GetLayout();
@@ -2054,7 +2035,6 @@ void LyXText::pasteEnvironmentType(BufferView * bview)
 
 void LyXText::CutSelection(BufferView * bview, bool doclear)
 {
-
        // Stuff what we got on the clipboard. Even if there is no selection.
 
        // There is a problem with having the stuffing here in that the
@@ -2101,7 +2081,6 @@ void LyXText::CutSelection(BufferView * bview, bool doclear)
        }
        /* table stuff -- end */
 #endif
-    
        // make sure that the depth behind the selection are restored, too
        LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
        LyXParagraph * undoendpar = endpar;
@@ -2157,7 +2136,7 @@ void LyXText::CutSelection(BufferView * bview, bool doclear)
        sel_cursor = cursor;
        UpdateCounters(bview, cursor.row());
 }
-    
+
 
 void LyXText::CopySelection(BufferView * bview)
 {
@@ -2249,7 +2228,7 @@ void LyXText::PasteSelection(BufferView * bview)
    
        sel_cursor = cursor;
        SetCursor(bview, actpar, pos);
-       SetSelection(bview);
+       SetSelection();
        UpdateCounters(bview, cursor.row());
 }
 
@@ -2285,7 +2264,7 @@ void LyXText::SetSelectionOverString(BufferView * bview, char const * string)
        sel_cursor = cursor;
        for (int i = 0; string[i]; ++i)
                CursorRight(bview);
-       SetSelection(bview);
+       SetSelection();
 }
 
 
@@ -2496,7 +2475,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
        SetCursor(bview, cursor.par(), cursor.pos());
        sel_cursor = cursor;
        SetCursor(bview, par, pos);
-       SetSelection(bview);
+       SetSelection();
 }
 
 
@@ -3364,6 +3343,8 @@ LyXParagraph * LyXText::GetParFromID(int id)
 // undo functions
 bool LyXText::TextUndo(BufferView * bview)
 {
+       if (inset_owner)
+               return false;
        // returns false if no undo possible
        Undo * undo = bview->buffer()->undostack.pop();
        if (undo) {
@@ -3380,6 +3361,8 @@ bool LyXText::TextUndo(BufferView * bview)
 
 bool LyXText::TextRedo(BufferView * bview)
 {
+       if (inset_owner)
+               return false;
        // returns false if no redo possible
        Undo * undo = bview->buffer()->redostack.pop();
        if (undo) {
@@ -3396,6 +3379,8 @@ bool LyXText::TextRedo(BufferView * bview)
 
 bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo)
 {
+       if (inset_owner)
+               return false;
        // returns false if no undo possible
        bool result = false;
        if (undo) {
@@ -3514,6 +3499,8 @@ bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo)
 
 void LyXText::FinishUndo()
 {
+       if (inset_owner)
+               return;
        // makes sure the next operation will be stored
        undo_finished = true;
 }
@@ -3521,6 +3508,8 @@ void LyXText::FinishUndo()
 
 void LyXText::FreezeUndo()
 {
+       if (inset_owner)
+               return;
        // this is dangerous and for internal use only
        undo_frozen = true;
 }
@@ -3528,6 +3517,8 @@ void LyXText::FreezeUndo()
 
 void LyXText::UnFreezeUndo()
 {
+       if (inset_owner)
+               return;
        // this is dangerous and for internal use only
        undo_frozen = false;
 }
@@ -3537,6 +3528,8 @@ void LyXText::SetUndo(Buffer * buf, Undo::undo_kind kind,
                      LyXParagraph const * before,
                      LyXParagraph const * behind) const
 {
+       if (inset_owner)
+               return;
        if (!undo_frozen)
                buf->undostack.push(CreateUndo(buf, kind, before, behind));
        buf->redostack.clear();
@@ -3546,6 +3539,8 @@ void LyXText::SetUndo(Buffer * buf, Undo::undo_kind kind,
 void LyXText::SetRedo(Buffer * buf, Undo::undo_kind kind,
                      LyXParagraph const * before, LyXParagraph const * behind)
 {
+       if (inset_owner)
+               return;
        buf->redostack.push(CreateUndo(buf, kind, before, behind));
 }
 
@@ -3554,6 +3549,9 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
                           LyXParagraph const * before,
                           LyXParagraph const * behind) const
 {
+       if (inset_owner)
+               return 0;
+
        int before_number = -1;
        int behind_number = -1;
        if (before)
@@ -3567,8 +3565,7 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
        // appear one by one when undoing. 
        // EDIT is special since only layout information, not the
        // contents of a paragaph are stored.
-       if (!undo_finished && kind != Undo::EDIT && 
-           kind != Undo::FINISH){
+       if (!undo_finished && (kind != Undo::EDIT) && (kind != Undo::FINISH)){
                // check wether storing is needed
                if (!buf->undostack.empty() && 
                    buf->undostack.top()->kind == kind &&
@@ -3646,6 +3643,8 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
 
 void LyXText::SetCursorParUndo(Buffer * buf)
 {
+       if (inset_owner)
+               return;
        SetUndo(buf, Undo::FINISH, 
                cursor.par()->ParFromPos(cursor.pos())->previous, 
                cursor.par()->ParFromPos(cursor.pos())->next);