]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
Update Win installer for new dictionary links. Untested.
[lyx.git] / src / Text.cpp
index e1c8830dc3813800703269293de684c8671a98c1..1f9696de0db4b82f691e41d04e8294a4a3f84cca 100644 (file)
@@ -5720,12 +5720,27 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_NOMENCL_PRINT:
-       case LFUN_NEWPAGE_INSERT:
                // do nothing fancy
                doInsertInset(cur, this, cmd, false, false);
                cur.posForward();
                break;
 
+       case LFUN_NEWPAGE_INSERT: {
+               // When we are in a heading, put the page break in a standard
+               // paragraph before the heading (if cur.pos() == 0) or after
+               // (if cur.pos() == cur.lastpos())
+               if (cur.text()->getTocLevel(cur.pit()) != Layout::NOT_IN_TOC) {
+                       lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK));
+                       DocumentClass const & tc = bv->buffer().params().documentClass();
+                       lyx::dispatch(FuncRequest(LFUN_LAYOUT, from_ascii("\"") + tc.plainLayout().name()
+                                                 + from_ascii("\" ignoreautonests")));
+               }
+               // do nothing fancy
+               doInsertInset(cur, this, cmd, false, false);
+               cur.posForward();
+               break;
+       }
+
        case LFUN_SEPARATOR_INSERT: {
                doInsertInset(cur, this, cmd, false, false);
                cur.posForward();
@@ -5943,7 +5958,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                // Argument?
                if (!arg.empty()) {
                        if (isStrUnsignedInt(arg)) {
-                               num = convert<uint>(arg);
+                               num = convert<unsigned int>(arg);
                                if (num >= freeFonts.size()) {
                                        cur.message(_("Invalid argument (number exceeds stack size)!"));
                                        break;
@@ -6371,30 +6386,31 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
        // FIXME: the following code should go in favor of fine grained
        // update flag treatment.
-       if (singleParUpdate) {
+       if (singleParUpdate || cur.result().screenUpdate() & Update::SinglePar) {
                // Inserting characters does not change par height in general. So, try
                // to update _only_ this paragraph. BufferView will detect if a full
                // metrics update is needed anyway.
                cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
                return;
        }
-       if (!needsUpdate
-           && &oldTopSlice.inset() == &cur.inset()
-           && oldTopSlice.idx() == cur.idx()
-           && !oldSelection // oldSelection is a backup of cur.selection() at the beginning of the function.
-           && !cur.selection())
-               // FIXME: it would be better if we could just do this
-               //
-               //if (cur.result().update() != Update::FitCursor)
-               //      cur.noScreenUpdate();
-               //
-               // But some LFUNs do not set Update::FitCursor when needed, so we
-               // do it for all. This is not very harmfull as FitCursor will provoke
-               // a full redraw only if needed but still, a proper review of all LFUN
-               // should be done and this needsUpdate boolean can then be removed.
-               cur.screenUpdateFlags(Update::FitCursor);
-       else
+       if (needsUpdate)
                cur.screenUpdateFlags(Update::Force | Update::FitCursor);
+       else {
+               // oldSelection is a backup of cur.selection() at the beginning of the function.
+           if (!oldSelection && !cur.selection())
+                       // FIXME: it would be better if we could just do this
+                       //
+                       //if (cur.result().update() != Update::FitCursor)
+                       //      cur.noScreenUpdate();
+                       //
+                       // But some LFUNs do not set Update::FitCursor when needed, so we
+                       // do it for all. This is not very harmfull as FitCursor will provoke
+                       // a full redraw only if needed but still, a proper review of all LFUN
+                       // should be done and this needsUpdate boolean can then be removed.
+                       cur.screenUpdateFlags(Update::FitCursor);
+               else
+                       cur.screenUpdateFlags(Update::ForceDraw | Update::FitCursor);
+       }
 }
 
 
@@ -6956,9 +6972,11 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        }
 
        case LFUN_NEWPAGE_INSERT:
-               // not allowed in description items
+               // not allowed in description items and in the midst of sections
                code = NEWPAGE_CODE;
-               enable = !inDescriptionItem(cur);
+               enable = !inDescriptionItem(cur)
+                       && (cur.text()->getTocLevel(cur.pit()) == Layout::NOT_IN_TOC
+                           || cur.pos() == 0 || cur.pos() == cur.lastpos());
                break;
 
        case LFUN_LANGUAGE: