]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
cosmetic fix
[lyx.git] / src / text2.C
index 0a3f6c0c93989fba4a1ca8970360ba19ef7d06e7..0231873fdba58e52a297de778a16b46248ce909c 100644 (file)
@@ -206,7 +206,7 @@ void LyXText::setCharFont(ParagraphList::iterator pit,
        font.update(fnt, buf->params.language, toggleall);
        // Let the insets convert their font
        if (pit->isInset(pos)) {
-               Inset * inset = pit->getInset(pos);
+               InsetOld * inset = pit->getInset(pos);
                if (isEditableInset(inset)) {
                        UpdatableInset * uinset =
                                static_cast<UpdatableInset *>(inset);
@@ -302,7 +302,7 @@ void LyXText::insertParagraph(ParagraphList::iterator pit,
 }
 
 
-Inset * LyXText::getInset() const
+InsetOld * LyXText::getInset() const
 {
        ParagraphList::iterator pit = cursor.par();
        pos_type const pos = cursor.pos();
@@ -316,7 +316,7 @@ Inset * LyXText::getInset() const
 
 void LyXText::toggleInset()
 {
-       Inset * inset = getInset();
+       InsetOld * inset = getInset();
        // is there an editable inset at cursor position?
        if (!isEditableInset(inset)) {
                // No, try to see if we are inside a collapsable inset
@@ -332,7 +332,7 @@ void LyXText::toggleInset()
 
        // do we want to keep this?? (JMarc)
        if (!isHighlyEditableInset(inset))
-               setCursorParUndo(bv());
+               recordUndo(bv(), Undo::ATOMIC);
 
        if (inset->isOpen()) {
                inset->close(bv());
@@ -385,7 +385,7 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
                ++endpit;
        }
 
-       setUndo(bv(), Undo::EDIT, sstart_cur.par(), boost::prior(undoendpit));
+       recordUndo(bv(), Undo::ATOMIC, sstart_cur.par(), boost::prior(undoendpit));
 
        // ok we have a selection. This is always between sstart_cur
        // and sel_end cursor
@@ -437,7 +437,7 @@ void LyXText::setLayout(string const & layout)
                bv()->owner()->dispatch(FuncRequest(LFUN_HOME));
                bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
                bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
-               Inset * inset = new InsetEnvironment(params, layout);
+               InsetOld * inset = new InsetEnvironment(params, layout);
                if (bv()->insertInset(inset)) {
                        //inset->edit(bv());
                        //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
@@ -478,7 +478,7 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
        ParagraphList::iterator pastend = boost::next(end);
 
        if (!test_only)
-               setUndo(bv(), Undo::EDIT, start, end);
+               recordUndo(bv(), Undo::ATOMIC, start, end);
 
        bool changed = false;
 
@@ -579,7 +579,7 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
        // ok we have a selection. This is always between sel_start_cursor
        // and sel_end cursor
 
-       setUndo(bv(), Undo::EDIT, selection.start.par(), selection.end.par());
+       recordUndo(bv(), Undo::ATOMIC, selection.start.par(), selection.end.par());
        freezeUndo();
        cursor = selection.start;
        while (cursor.par() != selection.end.par() ||
@@ -711,13 +711,12 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
        ParagraphList::iterator end = ownerParagraphs().end();
 
        for (; pit != end; ++pit) {
-               // compute inset metrics
-               for (int pos = 0; pos != pit->size(); ++pos) {
-                       if (pit->isInset(pos)) {
-                               Dimension dim;
-                               MetricsInfo m = mi;
-                               pit->getInset(pos)->metrics(m, dim);
-                       }
+               InsetList::iterator ii = pit->insetlist.begin();
+               InsetList::iterator iend = pit->insetlist.end();
+               for (; ii != iend; ++ii) {
+                       Dimension dim;
+                       MetricsInfo m = mi;
+                       ii->inset->metrics(m, dim);
                }
 
                // insert a new row, starting at position 0
@@ -929,7 +928,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
                ++endpit;
        }
 
-       setUndo(bv(), Undo::EDIT, selection.start.par(),
+       recordUndo(bv(), Undo::ATOMIC, selection.start.par(),
                boost::prior(undoendpit));
 
 
@@ -1119,14 +1118,14 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
                // the caption hack:
                if (layout->labeltype == LABEL_SENSITIVE) {
                        ParagraphList::iterator tmppit = pit;
-                       Inset * in = 0;
+                       InsetOld * in = 0;
                        bool isOK = false;
                        while (tmppit != ownerParagraphs().end() &&
                               tmppit->inInset()
                               // the single '=' is intended below
                               && (in = tmppit->inInset()->owner())) {
-                               if (in->lyxCode() == Inset::FLOAT_CODE ||
-                                   in->lyxCode() == Inset::WRAP_CODE) {
+                               if (in->lyxCode() == InsetOld::FLOAT_CODE ||
+                                   in->lyxCode() == InsetOld::WRAP_CODE) {
                                        isOK = true;
                                        break;
                                } else {
@@ -1137,9 +1136,9 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
                        if (isOK) {
                                string type;
 
-                               if (in->lyxCode() == Inset::FLOAT_CODE)
+                               if (in->lyxCode() == InsetOld::FLOAT_CODE)
                                        type = static_cast<InsetFloat*>(in)->params().type;
-                               else if (in->lyxCode() == Inset::WRAP_CODE)
+                               else if (in->lyxCode() == InsetOld::WRAP_CODE)
                                        type = static_cast<InsetWrap*>(in)->params().type;
                                else
                                        Assert(0);
@@ -1213,11 +1212,11 @@ void LyXText::updateCounters()
 }
 
 
-void LyXText::insertInset(Inset * inset)
+void LyXText::insertInset(InsetOld * inset)
 {
        if (!cursor.par()->insetAllowed(inset->lyxCode()))
                return;
-       setUndo(bv(), Undo::FINISH, cursor.par());
+       recordUndo(bv(), Undo::ATOMIC, cursor.par());
        freezeUndo();
        cursor.par()->insertInset(cursor.pos(), inset);
        // Just to rebreak and refresh correctly.
@@ -1269,7 +1268,7 @@ void LyXText::cutSelection(bool doclear, bool realcut)
                ++endpit;
        }
 
-       setUndo(bv(), Undo::DELETE, selection.start.par(),
+       recordUndo(bv(), Undo::DELETE, selection.start.par(),
                boost::prior(undoendpit));
 
 
@@ -1344,7 +1343,7 @@ void LyXText::pasteSelection(size_t sel_index)
        if (!CutAndPaste::checkPastePossible())
                return;
 
-       setUndo(bv(), Undo::INSERT, cursor.par());
+       recordUndo(bv(), Undo::INSERT, cursor.par());
 
        ParagraphList::iterator endpit;
        PitPosPair ppp;
@@ -1387,7 +1386,7 @@ void LyXText::setSelectionRange(lyx::pos_type length)
 // simple replacing. The font of the first selected character is used
 void LyXText::replaceSelectionWithString(string const & str)
 {
-       setCursorParUndo(bv());
+       recordUndo(bv(), Undo::ATOMIC);
        freezeUndo();
 
        if (!selection.set()) { // create a dummy selection
@@ -1423,7 +1422,7 @@ void LyXText::insertStringAsLines(string const & str)
        pos_type pos = cursor.pos();
        ParagraphList::iterator endpit = boost::next(cursor.par());
 
-       setCursorParUndo(bv());
+       recordUndo(bv(), Undo::ATOMIC);
 
        // only to be sure, should not be neccessary
        clearSelection();
@@ -1523,7 +1522,7 @@ void LyXText::checkParagraph(ParagraphList::iterator pit, pos_type pos)
 
 
 // returns false if inset wasn't found
-bool LyXText::updateInset(Inset * inset)
+bool LyXText::updateInset(InsetOld * inset)
 {
        // first check the current paragraph
        int pos = cursor.par()->getPositionOfInset(inset);
@@ -1584,7 +1583,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
            boost::prior(row)->par() == row->par() &&
            pos < pit->size() &&
            pit->getChar(pos) == Paragraph::META_INSET) {
-               Inset * ins = pit->getInset(pos);
+               InsetOld * ins = pit->getInset(pos);
                if (ins && (ins->needFullRow() || ins->display())) {
                        --row;
                        y -= row->height();
@@ -1921,7 +1920,7 @@ namespace {
                    || !cur.par()->isInset(cur.pos()))
                        return false;
 
-               Inset const * inset = cur.par()->getInset(cur.pos());
+               InsetOld const * inset = cur.par()->getInset(cur.pos());
                if (inset->needFullRow() || inset->display())
                        return true;
 
@@ -2001,7 +2000,7 @@ void LyXText::cursorUp(bool selecting)
                int y1 = cursor.iy() - topy;
                int y2 = y1;
                y -= topy;
-               Inset * inset_hit = checkInsetHit(x, y1);
+               InsetOld * inset_hit = checkInsetHit(x, y1);
                if (inset_hit && isHighlyEditableInset(inset_hit)) {
                        inset_hit->localDispatch(
                                FuncRequest(bv(), LFUN_INSET_EDIT, x, y - (y2 - y1), mouse_button::none));
@@ -2025,7 +2024,7 @@ void LyXText::cursorDown(bool selecting)
                int y1 = cursor.iy() - topy;
                int y2 = y1;
                y -= topy;
-               Inset * inset_hit = checkInsetHit(x, y1);
+               InsetOld * inset_hit = checkInsetHit(x, y1);
                if (inset_hit && isHighlyEditableInset(inset_hit)) {
                        FuncRequest cmd(bv(), LFUN_INSET_EDIT, x, y - (y2 - y1), mouse_button::none);
                        inset_hit->localDispatch(cmd);
@@ -2196,7 +2195,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
                                ++endpit;
                        }
 
-                       setUndo(bv(), Undo::DELETE, old_cursor.par(),
+                       recordUndo(bv(), Undo::DELETE, old_cursor.par(),
                                boost::prior(endpit));
                        cursor = tmpcursor;
 
@@ -2228,7 +2227,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
                                ++endpit;
                        }
 
-                       setUndo(bv(), Undo::DELETE, old_cursor.par(), boost::prior(endpit));
+                       recordUndo(bv(), Undo::DELETE, old_cursor.par(), boost::prior(endpit));
                        cursor = tmpcursor;
 
                        // delete old row