]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
More 'standard conformant blurb' nonsense.
[lyx.git] / src / text3.C
index 0cdf9f9b4563318ffa417e1afdc4e140c6f05081..29c8d568133ce15f93f89ed0aa858af383860f8a 100644 (file)
@@ -11,7 +11,6 @@
 #include <config.h>
 
 #include "lyxtext.h"
-#include "lyxrow.h"
 #include "paragraph.h"
 #include "BufferView.h"
 #include "funcrequest.h"
@@ -226,7 +225,7 @@ void LyXText::gotoInset(vector<InsetOld::Code> const & codes,
                        bv()->owner()->message(_("No more insets"));
                }
        }
-       update();
+       bv()->update();
        selection.cursor = cursor;
 }
 
@@ -241,19 +240,19 @@ void LyXText::cursorPrevious()
 {
        int y = top_y();
 
-       if (cursorRow() == rows().begin()) {
+       RowList::iterator rit = cursorRow();
+
+       if (rit == firstRow()) {
                if (y > 0)
                        bv()->updateScrollbar();
                return;
        }
 
-       RowList::iterator cursorrow = cursorRow();
-
        setCursorFromCoordinates(cursor.x_fix(), y);
        finishUndo();
 
        int new_y;
-       if (cursorrow == bv()->text->cursorRow()) {
+       if (rit == bv()->text->cursorRow()) {
                // we have a row which is taller than the workarea. The
                // simplest solution is to move to the previous row instead.
                cursorUp(true);
@@ -264,24 +263,22 @@ void LyXText::cursorPrevious()
                if (inset_owner) {
                        new_y = bv()->text->cursor.iy()
                                + bv()->theLockingInset()->insetInInsetY() + y
-                               + cursorRow()->height()
+                               + rit->height()
                                - bv()->workHeight() + 1;
                } else {
                        new_y = cursor.y()
-                               - cursorRow()->baseline()
-                               + cursorRow()->height()
+                               - rit->baseline()
+                               + rit->height()
                                - bv()->workHeight() + 1;
                }
        }
-       //bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
-       if (cursorRow() != rows().begin()) {
-               LyXCursor cur;
-               setCursor(cur, boost::prior(cursorRow())->par(),
-                         boost::prior(cursorRow())->pos(), false);
-               if (cur.y() > top_y()) {
-                       cursorUp(true);
-               }
-       }
+
+       LyXCursor cur;
+       ParagraphList::iterator pit = cursor.par();
+       previousRow(pit, rit);
+       setCursor(cur, pit, rit->pos(), false);
+       if (cur.y() > top_y())
+               cursorUp(true);
        bv()->updateScrollbar();
 }
 
@@ -290,13 +287,11 @@ void LyXText::cursorNext()
 {
        int topy = top_y();
 
-       if (boost::next(cursorRow()) == rows().end()) {
-               int y = cursor.y() - cursorRow()->baseline() +
-                       cursorRow()->height();
-               if (y > topy + bv()->workHeight()) {
-                       //bv()->screen().draw(bv()->text, bv(), bv()->text->top_y() + bv()->workHeight());
+       RowList::iterator rit = cursorRow();
+       if (rit == lastRow()) {
+               int y = cursor.y() - rit->baseline() + cursorRow()->height();
+               if (y > topy + bv()->workHeight())
                        bv()->updateScrollbar();
-               }
                return;
        }
 
@@ -307,15 +302,15 @@ void LyXText::cursorNext()
                          + bv()->theLockingInset()->insetInInsetY());
        }
 
-       getRowNearY(y);
+       ParagraphList::iterator dummypit;
+       getRowNearY(y, dummypit);
 
-       RowList::iterator cursorrow = cursorRow();
        setCursorFromCoordinates(cursor.x_fix(), y);
        // + bv->workHeight());
        finishUndo();
 
        int new_y;
-       if (cursorrow == bv()->text->cursorRow()) {
+       if (rit == bv()->text->cursorRow()) {
                // we have a row which is taller than the workarea. The
                // simplest solution is to move to the next row instead.
                cursorDown(true);
@@ -329,35 +324,27 @@ void LyXText::cursorNext()
                if (inset_owner) {
                        new_y = bv()->text->cursor.iy()
                                + bv()->theLockingInset()->insetInInsetY()
-                               + y - cursorRow()->baseline();
+                               + y - rit->baseline();
                } else {
-                       new_y =  cursor.y() - cursorRow()->baseline();
-               }
-       }
-       //bv()->screen().draw(bv()->text, bv(), new_y);
-
-       RowList::iterator next_row = boost::next(cursorRow());
-       if (next_row != rows().end()) {
-               LyXCursor cur;
-               setCursor(cur, next_row->par(), next_row->pos(), false);
-               if (cur.y() < top_y() + bv()->workHeight()) {
-                       cursorDown(true);
+                       new_y = cursor.y() - cursorRow()->baseline();
                }
        }
+
+       ParagraphList::iterator pit = cursor.par();
+       nextRow(pit, rit);      
+       LyXCursor cur;
+       setCursor(cur, pit, rit->pos(), false);
+       if (cur.y() < top_y() + bv()->workHeight())
+               cursorDown(true);
        bv()->updateScrollbar();
 }
 
 
-void LyXText::update()
-{
-       bv()->update();
-}
-
 namespace {
 
 void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
 {
-       lt->update();
+       bv->update();
        InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
        replaceSelection(lt);
        if (!bv->insertInset(new_inset))
@@ -415,8 +402,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        if (tmp->params().startOfAppendix()) {
                                recordUndo(bv, Undo::ATOMIC, tmp);
                                tmp->params().startOfAppendix(false);
-                               int tmpy;
-                               setHeightOfRow(getRow(tmp, 0, tmpy));
+                               setHeightOfRow(tmp, getRow(tmp, 0));
                                break;
                        }
                }
@@ -426,30 +412,27 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
                // we can set the refreshing parameters now
                updateCounters();
-               redoHeightOfParagraph();
+               redoParagraph(cursor.par());
                setCursor(cursor.par(), cursor.pos());
-               update();
+               bv->update();
                break;
        }
 
        case LFUN_DELETE_WORD_FORWARD:
                bv->beforeChange(this);
                deleteWordForward();
-               update();
                finishChange(bv);
                break;
 
        case LFUN_DELETE_WORD_BACKWARD:
                bv->beforeChange(this);
                deleteWordBackward();
-               update();
                finishChange(bv);
                break;
 
        case LFUN_DELETE_LINE_FORWARD:
                bv->beforeChange(this);
                deleteLineForward();
-               update();
                finishChange(bv);
                break;
 
@@ -461,7 +444,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                else
                        cursorRightOneWord();
                finishChange(bv);
-               update();
                break;
 
        case LFUN_WORDLEFT:
@@ -718,7 +700,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                }
                moveCursorUpdate(bv, false);
                bv->owner()->view_state_changed();
-               bv->switchKeyMap();
                break;
 
        case LFUN_DELETE_SKIP:
@@ -754,7 +735,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                } else {
                        cutSelection(true, false);
                }
-               update();
+               bv->update();
                break;
 
 
@@ -771,7 +752,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                }
                bv->owner()->view_state_changed();
                bv->switchKeyMap();
-               update();
+               bv->update();
                break;
 
        case LFUN_BACKSPACE_SKIP:
@@ -795,16 +776,15 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                                selection.cursor = cur;
                        }
                } else {
-                       update();
                        cutSelection(true, false);
                }
-               update();
+               bv->update();
                break;
 
        case LFUN_BREAKPARAGRAPH:
                replaceSelection(bv->getLyXText());
                breakParagraph(bv->buffer()->paragraphs, 0);
-               update();
+               bv->update();
                selection.cursor = cursor;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -813,7 +793,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
                replaceSelection(bv->getLyXText());
                breakParagraph(bv->buffer()->paragraphs, 1);
-               update();
+               bv->update();
                selection.cursor = cursor;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -841,7 +821,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                else {
                        breakParagraph(bv->buffer()->paragraphs, 0);
                }
-               update();
+               bv->update();
                selection.cursor = cur;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
@@ -885,7 +865,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                if (cur_spacing != new_spacing || cur_value != new_value) {
                        pit->params().spacing(Spacing(new_spacing, new_value));
                        redoParagraph();
-                       update();
+                       bv->update();
                }
                break;
        }
@@ -897,19 +877,16 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
        case LFUN_INSET_TOGGLE:
                bv->beforeChange(this);
-               update();
                toggleInset();
-               update();
+               bv->update();
                bv->switchKeyMap();
                break;
 
        case LFUN_SPACE_INSERT:
-               if (cursor.par()->layout()->free_spacing) {
+               if (cursor.par()->layout()->free_spacing)
                        insertChar(' ');
-                       update();
-               } else {
+               else
                        doInsertInset(this, cmd, false, false);
-               }
                moveCursorUpdate(bv, false);
                break;
 
@@ -935,7 +912,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
        case LFUN_MARK_OFF:
                bv->beforeChange(this);
-               update();
+               bv->update();
                selection.cursor = cursor;
                cmd.message(N_("Mark off"));
                break;
@@ -943,7 +920,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_MARK_ON:
                bv->beforeChange(this);
                selection.mark(true);
-               update();
+               bv->update();
                selection.cursor = cursor;
                cmd.message(N_("Mark on"));
                break;
@@ -957,38 +934,28 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        cmd.message(N_("Mark set"));
                }
                selection.cursor = cursor;
-               update();
+               bv->update();
                break;
 
        case LFUN_UPCASE_WORD:
-               update();
                changeCase(LyXText::text_uppercase);
-               if (inset_owner)
-                       bv->updateInset();
-               update();
+               bv->update();
                break;
 
        case LFUN_LOWCASE_WORD:
                changeCase(LyXText::text_lowercase);
-               if (inset_owner)
-                       bv->updateInset();
-               update();
+               bv->update();
                break;
 
        case LFUN_CAPITALIZE_WORD:
                changeCase(LyXText::text_capitalization);
-               if (inset_owner)
-                       bv->updateInset();
-               update();
+               bv->update();
                break;
 
        case LFUN_TRANSPOSE_CHARS:
                recordUndo(bv, Undo::ATOMIC, cursor.par());
-               if (transposeChars(cursor))
-                       checkParagraph(cursor.par(), cursor.pos());
-               if (inset_owner)
-                       bv->updateInset();
-               update();
+               redoParagraph();
+               bv->update();
                break;
 
        case LFUN_PASTE: {
@@ -1003,7 +970,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                }
                pasteSelection(sel_index);
                clearSelection(); // bug 393
-               update();
+               bv->update();
                bv->switchKeyMap();
                break;
        }
@@ -1011,7 +978,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_CUT:
                cutSelection(true, true);
                cmd.message(_("Cut"));
-               update();
+               bv->update();
                break;
 
        case LFUN_COPY:
@@ -1024,7 +991,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        return UNDISPATCHED;
                cursorTop();
                finishChange(bv, true);
-               update();
                break;
 
        case LFUN_ENDBUFSEL:
@@ -1032,7 +998,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        return UNDISPATCHED;
                cursorBottom();
                finishChange(bv, true);
-               update();
                break;
 
        case LFUN_GETXY:
@@ -1118,7 +1083,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        current_layout = layout;
                        setLayout(layout);
                        bv->owner()->setLayout(layout);
-                       update();
+                       bv->update();
                        bv->switchKeyMap();
                }
                break;
@@ -1135,7 +1100,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        else
                                insertStringAsLines(clip);
                        clearSelection();
-                       update();
+                       bv->update();
                }
                break;
        }
@@ -1193,10 +1158,9 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                int const datetmp_len =
                        ::strftime(datetmp, 32, arg.c_str(), now_tm);
 
-               for (int i = 0; i < datetmp_len; i++) {
+               for (int i = 0; i < datetmp_len; i++)
                        insertChar(datetmp[i]);
-                       update();
-               }
+
                selection.cursor = cursor;
                moveCursorUpdate(bv, false);
                break;
@@ -1208,15 +1172,11 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                if (!isInInset() && bv->theLockingInset())
                        break;
                if (cmd.button() == mouse_button::button1) {
-                       if (!isInInset())
-                               bv->screen().toggleSelection(this, bv);
                        cursorHome();
                        selection.cursor = cursor;
                        cursorEnd();
                        setSelection();
-                       if (!isInInset())
-                               bv->screen().toggleSelection(this, bv, false);
-                       update();
+                       bv->update();
                        bv->haveSelection(selection.set());
                }
                break;
@@ -1227,14 +1187,8 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                if (!isInInset() && bv->theLockingInset())
                        break;
                if (cmd.button() == mouse_button::button1) {
-                       if (!isInInset()) {
-                               bv->screen().toggleSelection(this, bv);
-                               selectWord(lyx::WHOLE_WORD_STRICT);
-                               bv->screen().toggleSelection(this, bv, false);
-                       } else {
-                               selectWord(lyx::WHOLE_WORD_STRICT);
-                       }
-                       update();
+                       selectWord(lyx::WHOLE_WORD_STRICT);
+                       bv->update();
                        bv->haveSelection(selection.set());
                }
                break;
@@ -1294,7 +1248,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
                bv->text->setSelection();
                bv->update();
-               bv->fitCursor();
                break;
        }
 
@@ -1350,7 +1303,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        selection_possible = true;
 
                // Clear the selection
-               bv->screen().toggleSelection(bv->text, bv);
                bv->text->clearSelection();
                bv->update();
                bv->updateScrollbar();
@@ -1471,7 +1423,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        // stack. They don't *have* to
                        // alter the document...
                        // (Joacim)
-                       // ...or maybe the SetCursorParUndo()
+                       // ...or maybe the recordUndo()
                        // below isn't necessary at all anylonger?
                        if (inset_hit->lyxCode() == InsetOld::REF_CODE)
                                recordUndo(bv, Undo::ATOMIC);
@@ -1510,7 +1462,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->owner()->getIntl().getTransManager().
                                TranslateAndInsert(*cit, this);
 
-               update();
                selection.cursor = cursor;
                moveCursorUpdate(bv, false);
 
@@ -1542,6 +1493,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_INSET_CAPTION:
 #endif
        case LFUN_INSERT_NOTE:
+       case LFUN_INSERT_BRANCH:
        case LFUN_INSERT_BIBITEM:
        case LFUN_INSET_ERT:
        case LFUN_INSET_FLOAT: