]> git.lyx.org Git - lyx.git/blobdiff - src/Text2.cpp
adjust
[lyx.git] / src / Text2.cpp
index 4cac71b48739663ea1729b90c5216d717fccf916..bd7effb23f36ced85b42935a167e2c8170271782 100644 (file)
@@ -37,6 +37,7 @@
 #include "FuncRequest.h"
 #include "gettext.h"
 #include "Language.h"
+#include "Layout.h"
 #include "Lexer.h"
 #include "LyXFunc.h"
 #include "LyXRC.h"
@@ -46,6 +47,7 @@
 #include "ParIterator.h"
 #include "Server.h"
 #include "ServerSocket.h"
+#include "TextMetrics.h"
 #include "Undo.h"
 #include "VSpace.h"
 
@@ -58,6 +60,7 @@
 #include "support/textutils.h"
 
 #include <boost/current_function.hpp>
+#include <boost/next_prior.hpp>
 
 #include <sstream>
 
@@ -367,7 +370,7 @@ void Text::setFont(BufferView const & bv, CursorSlice const & begin,
                                // of noFontChange in Inset.h
                                setInsetFont(bv, pit, pos, font, toggleall);
                        TextMetrics const & tm = bv.textMetrics(this);
-                       Font f = tm.getDisplayFont(dit.paragraph(), pos);
+                       Font f = tm.getDisplayFont(pit, pos);
                        f.update(font, language, toggleall);
                        setCharFont(buffer, pit, pos, f, tm.font_);
                }
@@ -583,7 +586,7 @@ bool Text::checkAndActivateInset(Cursor & cur, bool front)
        if (!front && cur.pos() == 0)
                return false;
        Inset * inset = front ? cur.nextInset() : cur.prevInset();
-       if (!isHighlyEditableInset(inset))
+       if (!inset || inset->editable() != Inset::HIGHLY_EDITABLE)
                return false;
        /*
         * Apparently, when entering an inset we are expected to be positioned
@@ -636,7 +639,7 @@ bool Text::cursorLeft(Cursor & cur)
 
        // move to the previous paragraph or do nothing
        if (cur.pit() > 0)
-               return setCursor(cur, cur.pit() - 1, getPar(cur.pit() - 1).size());
+               return setCursor(cur, cur.pit() - 1, getPar(cur.pit() - 1).size(), true, false);
        return false;
 }
 
@@ -655,7 +658,7 @@ bool Text::cursorRight(Cursor & cur)
                TextMetrics const & tm = cur.bv().textMetrics(this);
                // if left of boundary -> just jump to right side
                // but for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
-               if (cur.boundary() && !tm.isRTLBoundary(cur.paragraph(), cur.pos()))
+               if (cur.boundary() && !tm.isRTLBoundary(cur.pit(), cur.pos()))
                        return setCursor(cur, cur.pit(), cur.pos(), true, false);
 
                // next position is left of boundary, 
@@ -684,7 +687,7 @@ bool Text::cursorRight(Cursor & cur)
                
                // in front of RTL boundary? Stay on this side of the boundary because:
                //   ab|cDDEEFFghi -> abc|DDEEFFghi
-               if (tm.isRTLBoundary(cur.paragraph(), cur.pos() + 1))
+               if (tm.isRTLBoundary(cur.pit(), cur.pos() + 1))
                        return setCursor(cur, cur.pit(), cur.pos() + 1, true, true);
                
                // move right
@@ -693,7 +696,7 @@ bool Text::cursorRight(Cursor & cur)
 
        // move to next paragraph
        if (cur.pit() != cur.lastpit())
-               return setCursor(cur, cur.pit() + 1, 0);
+               return setCursor(cur, cur.pit() + 1, 0, true, false);
        return false;
 }
 
@@ -813,7 +816,11 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
                           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()));
+               // do not lose start of appendix marker (bug 4212)
+               if (soa)
+                       plist[old.pit()].params().startOfAppendix(true);
 
                // see #warning (FIXME?) above 
                if (cur.depth() >= old.depth()) {