]> git.lyx.org Git - lyx.git/blobdiff - src/Text2.cpp
avoid float-conversion warning and simplify size computation
[lyx.git] / src / Text2.cpp
index 4f6a975957e1e54a809a3269bfae49b76b008419..7b3d4da8c614a6c7372f77f3f5a690eb19dfae6e 100644 (file)
 #include "support/lassert.h"
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/lyxalgo.h"
 #include "support/textutils.h"
 
-#include <boost/next_prior.hpp>
-
 #include <sstream>
 
 using namespace std;
@@ -264,6 +263,11 @@ void Text::changeDepth(Cursor & cur, DEPTH_CHANGE type)
 void Text::setFont(Cursor & cur, Font const & font, bool toggleall)
 {
        LASSERT(this == cur.text(), return);
+
+       // If there is a selection, record undo before the cursor font is changed.
+       if (cur.selection())
+               cur.recordUndoSelection();
+
        // Set the current_font
        // Determine basis font
        FontInfo layoutfont;
@@ -289,7 +293,6 @@ void Text::setFont(Cursor & cur, Font const & font, bool toggleall)
                return;
 
        // Ok, we have a selection.
-       cur.recordUndoSelection();
        Font newfont = font;
 
        if (toggleall) {        
@@ -391,7 +394,7 @@ bool Text::cursorTop(Cursor & cur)
 bool Text::cursorBottom(Cursor & cur)
 {
        LBUFERR(this == cur.text());
-       return setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
+       return setCursor(cur, cur.lastpit(), prev(paragraphs().end(), 1)->size());
 }
 
 
@@ -498,7 +501,7 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
                // with same layout in a sequence.
                // Do this only once for a selected range of paragraphs
                // of the same layout and depth.
-               cur.recordUndo();
+               c.recordUndo();
                par.params().apply(params, par.layout());
                if (par.getDepth() != priordepth || par.layout() != priorlayout)
                        setLabelWidthStringToSequence(c, params.labelWidthString());
@@ -897,12 +900,11 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
        if (oldpar.empty() || (oldpar.size() == 1 && oldpar.isLineSeparator(0))) {
                // Delete old par.
-               old.recordUndo(ATOMIC_UNDO,
-                          max(old.pit() - 1, pit_type(0)),
-                          min(old.pit() + 1, old.lastpit()));
+               old.recordUndo(max(old.pit() - 1, pit_type(0)),
+                              min(old.pit() + 1, old.lastpit()));
                ParagraphList & plist = old.text()->paragraphs();
                bool const soa = oldpar.params().startOfAppendix();
-               plist.erase(boost::next(plist.begin(), old.pit()));
+               plist.erase(next(plist.begin(), old.pit()));
                // do not lose start of appendix marker (bug 4212)
                if (soa && old.pit() < pit_type(plist.size()))
                        plist[old.pit()].params().startOfAppendix(true);
@@ -966,7 +968,7 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool tra
                        continue;
 
                if (par.empty() || (par.size() == 1 && par.isLineSeparator(0))) {
-                       pars_.erase(boost::next(pars_.begin(), pit));
+                       pars_.erase(next(pars_.begin(), pit));
                        --pit;
                        --last;
                        continue;
@@ -977,15 +979,4 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool tra
 }
 
 
-void Text::recUndo(Cursor & cur, pit_type first, pit_type last) const
-{
-       cur.recordUndo(ATOMIC_UNDO, first, last);
-}
-
-
-void Text::recUndo(Cursor & cur, pit_type par) const
-{
-       cur.recordUndo(ATOMIC_UNDO, par, par);
-}
-
 } // namespace lyx