]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
Alfredo's second patch
[lyx.git] / src / text3.C
index 13e494e48886c6e7cd6d3e1d65ab77c6d1511924..3aa80b5bbdf3dd98cea6f4ed2102a5ed3faceda2 100644 (file)
@@ -35,6 +35,7 @@
 #include "insets/insetcommand.h"
 #include "insets/insetnewline.h"
 #include "undo_funcs.h"
+#include "text_funcs.h"
 
 #include <ctime>
 #include <clocale>
@@ -42,6 +43,7 @@
 using std::endl;
 using std::find;
 using std::vector;
+using lyx::pos_type;
 
 extern string current_layout;
 extern int bibitemMaxWidth(BufferView *, LyXFont const &);
@@ -60,19 +62,16 @@ namespace {
                if (selecting || lt->selection.mark()) {
                        lt->setSelection();
                        if (lt->isInInset())
-                               bv->updateInset(lt->inset_owner, false);
+                               bv->updateInset(lt->inset_owner);
                        else
                                bv->toggleToggle();
                }
                if (!lt->isInInset()) {
-                       //if (fitcur)
-                       //      bv->update(lt, BufferView::SELECT|BufferView::FITCUR);
-                       //else
-                       bv->update(lt, BufferView::SELECT|BufferView::FITCUR);
+                       bv->update(lt, BufferView::SELECT);
                        bv->showCursor();
-               } else if (bv->text->status() != LyXText::UNCHANGED) {
+               } else if (bv->text->refreshStatus() != LyXText::REFRESH_NONE) {
                        bv->theLockingInset()->hideInsetCursor(bv);
-                       bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
+                       bv->update(BufferView::SELECT);
                        bv->showCursor();
                }
 
@@ -172,28 +171,29 @@ Inset * LyXText::checkInsetHit(int & x, int & y)
 bool LyXText::gotoNextInset(vector<Inset::Code> const & codes,
                            string const & contents)
 {
-       LyXCursor res = cursor;
+       ParagraphList::iterator end = ownerParagraphs().end();
+       ParagraphList::iterator pit = cursor.par();
+       pos_type pos = cursor.pos();
+
        Inset * inset;
        do {
-               if (res.pos() < res.par()->size() - 1) {
-                       res.pos(res.pos() + 1);
+               if (pos + 1 < pit->size()) {
+                       ++pos;
                } else  {
-                       res.par(res.par()->next());
-                       res.pos(0);
+                       ++pit;
+                       pos = 0;
                }
 
-       } while (res.par() &&
-                !(res.par()->isInset(res.pos())
-                  && (inset = res.par()->getInset(res.pos())) != 0
-                  && find(codes.begin(), codes.end(), inset->lyxCode())
-                  != codes.end()
-                  && (contents.empty() ||
-                      static_cast<InsetCommand *>(
-                                                       res.par()->getInset(res.pos()))->getContents()
-                      == contents)));
-
-       if (res.par()) {
-               setCursor(res.par(), res.pos(), false);
+       } while (pit != end &&
+                !(pit->isInset(pos) &&
+                  (inset = pit->getInset(pos)) != 0 &&
+                  find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() &&
+                  (contents.empty() ||
+                   static_cast<InsetCommand *>(pit->getInset(pos))->getContents()
+                   == contents)));
+
+       if (pit != end) {
+               setCursor(pit, pos, false);
                return true;
        }
        return false;
@@ -201,14 +201,15 @@ bool LyXText::gotoNextInset(vector<Inset::Code> const & codes,
 
 
 void LyXText::gotoInset(vector<Inset::Code> const & codes,
-                                 bool same_content)
+                       bool same_content)
 {
        bv()->hideCursor();
        bv()->beforeChange(this);
-       update(false);
+       update();
 
        string contents;
-       if (same_content && cursor.par()->isInset(cursor.pos())) {
+       if (same_content && cursor.pos() < cursor.par()->size()
+           && cursor.par()->isInset(cursor.pos())) {
                Inset const * inset = cursor.par()->getInset(cursor.pos());
                if (find(codes.begin(), codes.end(), inset->lyxCode())
                    != codes.end())
@@ -216,9 +217,9 @@ void LyXText::gotoInset(vector<Inset::Code> const & codes,
        }
 
        if (!gotoNextInset(codes, contents)) {
-               if (cursor.pos() || cursor.par() != ownerParagraph()) {
+               if (cursor.pos() || cursor.par() != ownerParagraphs().begin()) {
                        LyXCursor tmp = cursor;
-                       cursor.par(ownerParagraph());
+                       cursor.par(ownerParagraphs().begin());
                        cursor.pos(0);
                        if (!gotoNextInset(codes, contents)) {
                                cursor = tmp;
@@ -228,7 +229,7 @@ void LyXText::gotoInset(vector<Inset::Code> const & codes,
                        bv()->owner()->message(_("No more insets"));
                }
        }
-       update(false);
+       update();
        selection.cursor = cursor;
 }
 
@@ -241,8 +242,10 @@ void LyXText::gotoInset(Inset::Code code, bool same_content)
 
 void LyXText::cursorPrevious()
 {
-       if (!cursor.row()->previous()) {
-               if (top_y() > 0) {
+       int y = top_y();
+
+       if (cursor.row() == rows().begin()) {
+               if (y > 0) {
                        int new_y = bv()->text->top_y() - bv()->workHeight();
                        bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
                        bv()->updateScrollbar();
@@ -250,8 +253,7 @@ void LyXText::cursorPrevious()
                return;
        }
 
-       int y = top_y();
-       Row * cursorrow = cursor.row();
+       RowList::iterator cursorrow = cursor.row();
 
        setCursorFromCoordinates(cursor.x_fix(), y);
        finishUndo();
@@ -281,10 +283,10 @@ void LyXText::cursorPrevious()
                }
        }
        bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
-       if (cursor.row()->previous()) {
+       if (cursor.row() != rows().begin()) {
                LyXCursor cur;
-               setCursor(cur, cursor.row()->previous()->par(),
-                         cursor.row()->previous()->pos(), false);
+               setCursor(cur, boost::prior(cursor.row())->par(),
+                         boost::prior(cursor.row())->pos(), false);
                if (cur.y() > top_y()) {
                        cursorUp(true);
                }
@@ -295,18 +297,20 @@ void LyXText::cursorPrevious()
 
 void LyXText::cursorNext()
 {
-       if (!cursor.row()->next()) {
+       int topy = top_y();
+
+       if (boost::next(cursor.row()) == rows().end()) {
                int y = cursor.y() - cursor.row()->baseline() +
                        cursor.row()->height();
-               if (y > top_y() + bv()->workHeight()) {
+               if (y > topy + bv()->workHeight()) {
                        bv()->screen().draw(bv()->text, bv(), bv()->text->top_y() + bv()->workHeight());
                        bv()->updateScrollbar();
                }
                return;
        }
 
-       int y = top_y() + bv()->workHeight();
-       if (inset_owner && !top_y()) {
+       int y = topy + bv()->workHeight();
+       if (inset_owner && !topy) {
                y -= (bv()->text->cursor.iy()
                          - bv()->text->top_y()
                          + bv()->theLockingInset()->insetInInsetY());
@@ -314,7 +318,7 @@ void LyXText::cursorNext()
 
        getRowNearY(y);
 
-       Row * cursorrow = cursor.row();
+       RowList::iterator cursorrow = cursor.row();
        setCursorFromCoordinates(cursor.x_fix(), y);
        // + bv->workHeight());
        finishUndo();
@@ -340,10 +344,10 @@ void LyXText::cursorNext()
                }
        }
        bv()->screen().draw(bv()->text, bv(), new_y);
-       if (cursor.row()->next()) {
+       if (boost::next(cursor.row()) != rows().end()) {
                LyXCursor cur;
-               setCursor(cur, cursor.row()->next()->par(),
-                                               cursor.row()->next()->pos(), false);
+               setCursor(cur, boost::next(cursor.row())->par(),
+                         boost::next(cursor.row())->pos(), false);
                if (cur.y() < top_y() + bv()->workHeight()) {
                        cursorDown(true);
                }
@@ -352,13 +356,9 @@ void LyXText::cursorNext()
 }
 
 
-void LyXText::update(bool changed)
+void LyXText::update()
 {
-       BufferView::UpdateCodes c = BufferView::SELECT | BufferView::FITCUR;
-       if (changed)
-               bv()->update(this, c | BufferView::CHANGE);
-       else
-               bv()->update(this, c);
+       bv()->update(this, BufferView::SELECT);
 }
 
 namespace {
@@ -366,12 +366,12 @@ namespace {
 void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
 {
        bv->hideCursor();
-       lt->update(bv);
+       lt->update();
        InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
        if (!bv->insertInset(new_inset))
                delete new_inset;
        else
-               bv->updateInset(new_inset, true);
+               bv->updateInset(new_inset);
 }
 
 
@@ -410,14 +410,16 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        switch (cmd.action) {
 
        case LFUN_APPENDIX: {
-               Paragraph * par = cursor.par();
-               bool start = !par->params().startOfAppendix();
+               ParagraphList::iterator pit = cursor.par();
+               bool start = !pit->params().startOfAppendix();
 
                // ensure that we have only one start_of_appendix in this document
-               Paragraph * tmp = ownerParagraph();
-               for (; tmp; tmp = tmp->next()) {
+               ParagraphList::iterator tmp = ownerParagraphs().begin();
+               ParagraphList::iterator end = ownerParagraphs().end();
+
+               for (; tmp != end; ++tmp) {
                        if (tmp->params().startOfAppendix()) {
-                               setUndo(bv, Undo::EDIT, tmp, tmp->next());
+                               setUndo(bv, Undo::EDIT, tmp, boost::next(tmp));
                                tmp->params().startOfAppendix(false);
                                int tmpy;
                                setHeightOfRow(getRow(tmp, 0, tmpy));
@@ -425,55 +427,46 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        }
                }
 
-               setUndo(bv, Undo::EDIT, par, par->next());
-               par->params().startOfAppendix(start);
+               setUndo(bv, Undo::EDIT, pit, boost::next(pit));
+               pit->params().startOfAppendix(start);
 
                // we can set the refreshing parameters now
                updateCounters();
                redoHeightOfParagraph();
                postPaint(0);
                setCursor(cursor.par(), cursor.pos());
-               update(bv);
+               update();
                break;
        }
 
        case LFUN_DELETE_WORD_FORWARD:
                bv->beforeChange(this);
-               update(false);
+               update();
                deleteWordForward();
-               update(bv);
+               update();
                finishChange(bv);
                break;
 
        case LFUN_DELETE_WORD_BACKWARD:
                bv->beforeChange(this);
-               update(false);
+               update();
                deleteWordBackward();
-               update(true);
+               update();
                finishChange(bv);
                break;
 
        case LFUN_DELETE_LINE_FORWARD:
                bv->beforeChange(this);
-               update(false);
+               update();
                deleteLineForward();
                update();
                finishChange(bv);
                break;
 
-       case LFUN_SHIFT_TAB:
-       case LFUN_TAB:
-               if (!selection.mark())
-                       bv->beforeChange(this);
-               update(false);
-               cursorTab();
-               finishChange(bv);
-               break;
-
        case LFUN_WORDRIGHT:
                if (!selection.mark())
                        bv->beforeChange(this);
-               update(false);
+               update();
                if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
                        cursorLeftOneWord();
                else
@@ -484,7 +477,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_WORDLEFT:
                if (!selection.mark())
                        bv->beforeChange(this);
-               update(false);
+               update();
                if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
                        cursorRightOneWord();
                else
@@ -495,7 +488,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_BEGINNINGBUF:
                if (!selection.mark())
                        bv->beforeChange(this);
-               update(false);
+               update();
                cursorTop();
                finishChange(bv);
                break;
@@ -503,13 +496,13 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_ENDBUF:
                if (selection.mark())
                        bv->beforeChange(this);
-               update(false);
+               update();
                cursorBottom();
                finishChange(bv);
                break;
 
        case LFUN_RIGHTSEL:
-               update(false);
+               update();
                if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
                        cursorLeft(bv);
                else
@@ -518,7 +511,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_LEFTSEL:
-               update(false);
+               update();
                if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
                        cursorRight(bv);
                else
@@ -527,55 +520,55 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_UPSEL:
-               update(false);
+               update();
                cursorUp(true);
                finishChange(bv, true);
                break;
 
        case LFUN_DOWNSEL:
-               update(false);
+               update();
                cursorDown(true);
                finishChange(bv, true);
                break;
 
        case LFUN_UP_PARAGRAPHSEL:
-               update(false);
+               update();
                cursorUpParagraph();
                finishChange(bv, true);
                break;
 
        case LFUN_DOWN_PARAGRAPHSEL:
-               update(false);
+               update();
                cursorDownParagraph();
                finishChange(bv, true);
                break;
 
        case LFUN_PRIORSEL:
-               update(false);
+               update();
                cursorPrevious();
                finishChange(bv, true);
                break;
 
        case LFUN_NEXTSEL:
-               update(false);
+               update();
                cursorNext();
                finishChange(bv, true);
                break;
 
        case LFUN_HOMESEL:
-               update(false);
+               update();
                cursorHome();
                finishChange(bv, true);
                break;
 
        case LFUN_ENDSEL:
-               update(false);
+               update();
                cursorEnd();
                finishChange(bv, true);
                break;
 
        case LFUN_WORDRIGHTSEL:
-               update(false);
+               update();
                if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
                        cursorLeftOneWord();
                else
@@ -584,7 +577,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_WORDLEFTSEL:
-               update(false);
+               update();
                if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
                        cursorRightOneWord();
                else
@@ -593,7 +586,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_WORDSEL: {
-               update(false);
+               update();
                LyXCursor cur1;
                LyXCursor cur2;
                getWord(cur1, cur2, WHOLE_WORD);
@@ -608,7 +601,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                bool is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params);
                if (!selection.mark())
                        bv->beforeChange(this);
-               update(false);
+               update();
                if (is_rtl)
                        cursorLeft(false);
                if (cursor.pos() < cursor.par()->size()
@@ -631,7 +624,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                bool const is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params);
                if (!selection.mark())
                        bv->beforeChange(this);
-               update(false);
+               update();
                LyXCursor const cur = cursor;
                if (!is_rtl)
                        cursorLeft(false);
@@ -705,7 +698,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_HOME:
                if (!selection.mark())
                        bv->beforeChange(this);
-               update(bv);
+               update();
                cursorHome();
                finishChange(bv, false);
                break;
@@ -713,7 +706,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_END:
                if (!selection.mark())
                        bv->beforeChange(this);
-               update(bv);
+               update();
                cursorEnd();
                finishChange(bv, false);
                break;
@@ -727,7 +720,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
                bv->beforeChange(this);
                insertInset(new InsetNewline);
-               update(true);
+               update();
                setCursor(cursor.par(), cursor.pos());
                moveCursorUpdate(bv, false);
                break;
@@ -737,14 +730,14 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                if (!selection.set()) {
                        Delete();
                        selection.cursor = cursor;
-                       update(bv);
+                       update();
                        // It is possible to make it a lot faster still
                        // just comment out the line below...
                        bv->showCursor();
                } else {
-                       update(false);
+                       update();
                        cutSelection(bv, true);
-                       update(bv);
+                       update();
                }
                moveCursorUpdate(bv, false);
                bv->owner()->view_state_changed();
@@ -772,7 +765,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                                                 cur.par()->params().align(),
                                                 cur.par()->params().labelWidthString(), 0);
                                        cursorLeft(bv);
-                                       update(bv);
+                                       update();
                                } else {
                                        cursorLeft(bv);
                                        Delete();
@@ -783,10 +776,10 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                                selection.cursor = cursor;
                        }
                } else {
-                       update(false);
+                       update();
                        cutSelection(bv, true);
                }
-               update(bv);
+               update();
                break;
 
 
@@ -795,15 +788,15 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        if (bv->owner()->getIntl().getTransManager().backspace()) {
                                backspace();
                                selection.cursor = cursor;
-                               update(bv);
+                               update();
                                // It is possible to make it a lot faster still
                                // just comment out the line below...
                                bv->showCursor();
                        }
                } else {
-                       update(false);
+                       update();
                        cutSelection(bv, true);
-                       update(bv);
+                       update();
                }
                bv->owner()->view_state_changed();
                bv->switchKeyMap();
@@ -830,16 +823,16 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                                selection.cursor = cur;
                        }
                } else {
-                       update(false);
+                       update();
                        cutSelection(bv, true);
                }
-               update(bv);
+               update();
                break;
 
        case LFUN_BREAKPARAGRAPH:
                bv->beforeChange(this);
                breakParagraph(bv->buffer()->paragraphs, 0);
-               update(bv);
+               update();
                selection.cursor = cursor;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -848,7 +841,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
                bv->beforeChange(this);
                breakParagraph(bv->buffer()->paragraphs, 1);
-               update(bv);
+               update();
                selection.cursor = cursor;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -871,14 +864,12 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                                         cur.par()->params().spacing(),
                                         cur.par()->params().align(),
                                         cur.par()->params().labelWidthString(), 1);
-                               //update(bv);
                        }
                }
                else {
                        breakParagraph(bv->buffer()->paragraphs, 0);
-                       //update(bv);
                }
-               update(bv);
+               update();
                selection.cursor = cur;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -886,11 +877,11 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_PARAGRAPH_SPACING: {
-               Paragraph * par = cursor.par();
-               Spacing::Space cur_spacing = par->params().spacing().getSpace();
+               ParagraphList::iterator pit = cursor.par();
+               Spacing::Space cur_spacing = pit->params().spacing().getSpace();
                float cur_value = 1.0;
                if (cur_spacing == Spacing::Other)
-                       cur_value = par->params().spacing().getValue();
+                       cur_value = pit->params().spacing().getValue();
 
                istringstream is(cmd.argument.c_str());
                string tmp;
@@ -920,26 +911,31 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                               << cmd.argument << endl;
                }
                if (cur_spacing != new_spacing || cur_value != new_value) {
-                       par->params().spacing(Spacing(new_spacing, new_value));
+                       pit->params().spacing(Spacing(new_spacing, new_value));
                        redoParagraph();
-                       update(bv);
+                       update();
                }
                break;
        }
 
+       case LFUN_INSET_SETTINGS:
+               lyx::Assert(bv->theLockingInset());
+               bv->theLockingInset()->getLockingInset()->showInsetDialog(bv);
+               break;
+
        case LFUN_INSET_TOGGLE:
                bv->hideCursor();
                bv->beforeChange(this);
-               update(false);
+               update();
                toggleInset();
-               update(false);
+               update();
                bv->switchKeyMap();
                break;
 
        case LFUN_PROTECTEDSPACE:
                if (cursor.par()->layout()->free_spacing) {
                        insertChar(' ');
-                       update(bv);
+                       update();
                } else {
                        specialChar(this, bv, InsetSpecialChar::PROTECTED_SEPARATOR);
                }
@@ -968,7 +964,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
        case LFUN_MARK_OFF:
                bv->beforeChange(this);
-               update(false);
+               update();
                selection.cursor = cursor;
                cmd.message(N_("Mark off"));
                break;
@@ -976,7 +972,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_MARK_ON:
                bv->beforeChange(this);
                selection.mark(true);
-               update(false);
+               update();
                selection.cursor = cursor;
                cmd.message(N_("Mark on"));
                break;
@@ -984,46 +980,46 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_SETMARK:
                bv->beforeChange(this);
                if (selection.mark()) {
-                       update(bv);
+                       update();
                        cmd.message(N_("Mark removed"));
                } else {
                        selection.mark(true);
-                       update(bv);
+                       update();
                        cmd.message(N_("Mark set"));
                }
                selection.cursor = cursor;
                break;
 
        case LFUN_UPCASE_WORD:
-               update(false);
+               update();
                changeCase(LyXText::text_uppercase);
                if (inset_owner)
-                       bv->updateInset(inset_owner, true);
-               update(bv);
+                       bv->updateInset(inset_owner);
+               update();
                break;
 
        case LFUN_LOWCASE_WORD:
-               update(false);
+               update();
                changeCase(LyXText::text_lowercase);
                if (inset_owner)
-                       bv->updateInset(inset_owner, true);
+                       bv->updateInset(inset_owner);
                update();
                break;
 
        case LFUN_CAPITALIZE_WORD:
-               update(false);
+               update();
                changeCase(LyXText::text_capitalization);
                if (inset_owner)
-                       bv->updateInset(inset_owner, true);
-               update(bv);
+                       bv->updateInset(inset_owner);
+               update();
                break;
 
        case LFUN_TRANSPOSE_CHARS:
-               update(false);
-               transposeChars();
+               update();
+               transposeChars(*this, cursor);
                if (inset_owner)
-                       bv->updateInset(inset_owner, true);
-               update(bv);
+                       bv->updateInset(inset_owner);
+               update();
                break;
 
        case LFUN_PASTE:
@@ -1032,19 +1028,18 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                // clear the selection
                bv->toggleSelection();
                clearSelection();
-               update(false);
+               update();
                pasteSelection();
                clearSelection(); // bug 393
-               update(false);
-               update(bv);
+               update();
                bv->switchKeyMap();
                break;
 
        case LFUN_CUT:
                bv->hideCursor();
-               update(false);
+               update();
                cutSelection(bv, true);
-               update(bv);
+               update();
                cmd.message(_("Cut"));
                break;
 
@@ -1056,7 +1051,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_BEGINNINGBUFSEL:
                if (inset_owner)
                        return UNDISPATCHED;
-               update(false);
+               update();
                cursorTop();
                finishChange(bv, true);
                break;
@@ -1064,7 +1059,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_ENDBUFSEL:
                if (inset_owner)
                        return UNDISPATCHED;
-               update(false);
+               update();
                cursorBottom();
                finishChange(bv, true);
                break;
@@ -1136,23 +1131,23 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                if (!change_layout && selection.set() &&
                        selection.start.par() != selection.end.par())
                {
-                       Paragraph * spar = selection.start.par();
-                       Paragraph * epar = selection.end.par()->next();
-                       while (spar != epar) {
-                               if (spar->layout()->name() != current_layout) {
+                       ParagraphList::iterator spit = selection.start.par();
+                       ParagraphList::iterator epit = boost::next(selection.end.par());
+                       while (spit != epit) {
+                               if (spit->layout()->name() != current_layout) {
                                        change_layout = true;
                                        break;
                                }
-                               spar = spar->next();
+                               ++spit;
                        }
                }
                if (change_layout) {
                        bv->hideCursor();
                        current_layout = layout;
-                       update(false);
+                       update();
                        setLayout(layout);
                        bv->owner()->setLayout(layout);
-                       update(bv);
+                       update();
                        bv->switchKeyMap();
                }
                break;
@@ -1172,7 +1167,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        else
                                insertStringAsLines(clip);
                        clearSelection();
-                       update(bv);
+                       update();
                }
                break;
        }
@@ -1195,21 +1190,21 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_QUOTE: {
-               Paragraph const * par = cursor.par();
+               ParagraphList::iterator pit = cursor.par();
                lyx::pos_type pos = cursor.pos();
                char c;
                if (!pos)
                        c = ' ';
-               else if (par->isInset(pos - 1) && par->getInset(pos - 1)->isSpace())
+               else if (pit->isInset(pos - 1) && pit->getInset(pos - 1)->isSpace())
                        c = ' ';
                else
-                       c = par->getChar(pos - 1);
+                       c = pit->getChar(pos - 1);
 
                bv->hideCursor();
-               LyXLayout_ptr const & style = par->layout();
+               LyXLayout_ptr const & style = pit->layout();
 
                if (style->pass_thru ||
-                               par->getFontSettings(bv->buffer()->params,
+                               pit->getFontSettings(bv->buffer()->params,
                                         pos).language()->lang() == "hebrew" ||
                        (!bv->insertInset(new InsetQuotes(c, bv->buffer()->params))))
                        bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
@@ -1231,7 +1226,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
                for (int i = 0; i < datetmp_len; i++) {
                        insertChar(datetmp[i]);
-                       update(true);
+                       update();
                }
                selection.cursor = cursor;
                moveCursorUpdate(bv, false);
@@ -1254,7 +1249,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        setSelection();
                        if (!isInInset())
                                bv->screen().toggleSelection(this, bv, false);
-                       update(false);
+                       update();
                        bv->haveSelection(selection.set());
                }
                break;
@@ -1273,7 +1268,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        } else {
                                selectWord(LyXText::WHOLE_WORD_STRICT);
                        }
-                       update(false);
+                       update();
                        bv->haveSelection(selection.set());
                }
                break;
@@ -1292,7 +1287,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        Inset * tli = bv->theLockingInset();
                        LyXCursor cursor = bv->text->cursor;
                        LyXFont font = bv->text->getFont(bv->buffer(),
-                                                               cursor.par(), cursor.pos());
+                                                        cursor.par(), cursor.pos());
                        int width = tli->width(bv, font);
                        int inset_x = font.isVisibleRightToLeft()
                                ? cursor.ix() - width : cursor.ix();
@@ -1315,7 +1310,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
                bv->screen().hideCursor();
 
-               Row * cursorrow = bv->text->cursor.row();
+               RowList::iterator cursorrow = bv->text->cursor.row();
                bv->text->setCursorFromCoordinates(cmd.x, cmd.y + bv->text->top_y());
        #if 0
                // sorry for this but I have a strange error that the y value jumps at
@@ -1336,7 +1331,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
                // Maybe an empty line was deleted
                if (!bv->text->selection.set())
-                       bv->update(bv->text, BufferView::UPDATE);
+                       bv->update(BufferView::UPDATE);
                bv->text->setSelection();
                bv->screen().toggleToggle(bv->text, bv);
                bv->fitCursor();
@@ -1409,9 +1404,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        UpdatableInset * inset = static_cast<UpdatableInset *>(inset_hit);
                        selection_possible = false;
                        bv->owner()->message(inset->editMessage());
-                       //inset->edit(bv, x, y, cmd.button());
                        // We just have to lock the inset before calling a PressEvent on it!
-                       // we don't need the edit() call here! (Jug20020329)
                        if (!bv->lockInset(inset))
                                lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
                        FuncRequest cmd1(bv, LFUN_MOUSE_PRESS, x, y, cmd.button());
@@ -1548,7 +1541,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                if (lyxrc.auto_region_delete) {
                        if (selection.set()) {
                                cutSelection(false, false);
-                               update(bv);
+                               update();
                        }
                        bv->haveSelection(false);
                }
@@ -1562,7 +1555,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->owner()->getIntl().getTransManager().
                                TranslateAndInsert(*cit, this);
 
-               update(bv);
+               update();
                selection.cursor = cursor;
                moveCursorUpdate(bv, false);