]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
InsetArgument: Set ResetsFontEdit to false
[lyx.git] / src / Text3.cpp
index 2893e080f92800e49360e3af0bf3b8078cacb8b3..70453620ac9251541b382b1614aa453fb365ed3e 100644 (file)
@@ -148,7 +148,7 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
 #endif
                cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
 #ifdef ENABLE_ASSERTIONS
-               LASSERT(old_pos == cur.pos(), /**/);
+               LATTEST(old_pos == cur.pos());
 #endif
                cur.nextInset()->edit(cur, true);
                // don't do that also for LFUN_MATH_MODE
@@ -488,7 +488,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        // at the end?
        cur.noScreenUpdate();
 
-       LASSERT(cur.text() == this, /**/);
+       LBUFERR(this == cur.text());
        CursorSlice const oldTopSlice = cur.top();
        bool const oldBoundary = cur.boundary();
        bool const oldSelection = cur.selection();
@@ -648,12 +648,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                // provide it with two different cursors.
                                Cursor dummy = cur;
                                dummy.pos() = dummy.pit() = 0;
-                               if (cur.bv().checkDepm(dummy, cur)) {
+                               if (cur.bv().checkDepm(dummy, cur))
                                        cur.forceBufferUpdate();
-                                       // DEPM may have requested a screen update
-                                       cur.screenUpdateFlags(
-                                               cur.screenUpdate() | dummy.screenUpdate());
-                               }
                        }
                }
                break;
@@ -679,12 +675,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                Cursor dummy = cur;
                                dummy.pos() = cur.lastpos();
                                dummy.pit() = cur.lastpit();
-                               if (cur.bv().checkDepm(dummy, cur)) {
+                               if (cur.bv().checkDepm(dummy, cur))
                                        cur.forceBufferUpdate();
-                                       // DEPM may have requested a screen update
-                                       cur.screenUpdateFlags(
-                                               cur.screenUpdate() | dummy.screenUpdate());
-                               }
                        }
                }
                break;
@@ -867,12 +859,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                // provide it with two different cursors.
                                Cursor dummy = cur;
                                dummy.pos() = dummy.pit() = 0;
-                               if (cur.bv().checkDepm(dummy, cur)) {
+                               if (cur.bv().checkDepm(dummy, cur))
                                        cur.forceBufferUpdate();
-                                       // DEPM may have requested a screen update
-                                       cur.screenUpdateFlags(
-                                               cur.screenUpdate() | dummy.screenUpdate());
-                               }
                        }
                }
                break;
@@ -921,12 +909,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                Cursor dummy = cur;
                                dummy.pos() = cur.lastpos();
                                dummy.pit() = cur.lastpit();
-                               if (cur.bv().checkDepm(dummy, cur)) {
+                               if (cur.bv().checkDepm(dummy, cur))
                                        cur.forceBufferUpdate();
-                                       // DEPM may have requested a screen update
-                                       cur.screenUpdateFlags(
-                                               cur.screenUpdate() | dummy.screenUpdate());
-                               }
                        }
                }
                break;
@@ -1097,7 +1081,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        /*
                        Paragraph & par = pars_[cur.pit()];
                        if (inset->lyxCode() == LABEL_CODE
-                               && par.layout().labeltype == LABEL_COUNTER) {
+                               && !par.layout().counter.empty() {
                                // Go to the end of the paragraph
                                // Warning: Because of Change-Tracking, the last
                                // position is 'size()' and not 'size()-1':
@@ -1236,7 +1220,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_PASTE: {
                cur.message(_("Paste"));
-               LASSERT(cur.selBegin().idx() == cur.selEnd().idx(), /**/);
+               LASSERT(cur.selBegin().idx() == cur.selEnd().idx(), break);
                cap::replaceSelection(cur);
 
                // without argument?
@@ -1248,11 +1232,15 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                     && !theClipboard().hasTextContents())
                                pasteClipboardGraphics(cur, bv->buffer().errorList("Paste"));
                        else
-                               pasteClipboardText(cur, bv->buffer().errorList("Paste"));
+                               pasteClipboardText(cur, bv->buffer().errorList("Paste"), true);
                } else if (isStrUnsignedInt(arg)) {
                        // we have a numerical argument
                        pasteFromStack(cur, bv->buffer().errorList("Paste"),
                                       convert<unsigned int>(arg));
+               } else if (arg == "html" || arg == "latex") {
+                       Clipboard::TextType type = (arg == "html") ?
+                               Clipboard::HtmlTextType : Clipboard::LaTeXTextType;
+                       pasteClipboardText(cur, bv->buffer().errorList("Paste"), true, type);
                } else {
                        Clipboard::GraphicsType type = Clipboard::AnyGraphicsType;
                        if (arg == "pdf")
@@ -1267,9 +1255,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                type = Clipboard::EmfGraphicsType;
                        else if (arg == "wmf")
                                type = Clipboard::WmfGraphicsType;
-
                        else
-                               LASSERT(false, /**/);
+                               // We used to assert, but couldn't the argument come from, say, the
+                               // minibuffer and just be mistyped?
+                               LYXERR0("Unrecognized graphics type: " << arg);
 
                        pasteClipboardGraphics(cur, bv->buffer().errorList("Paste"), type);
                }
@@ -1921,7 +1910,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                cap::replaceSelection(cur);
                cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
                checkAndActivateInset(cur, true);
-               LASSERT(cur.inMathed(), /**/);
+               LASSERT(cur.inMathed(), break);
                cur.dispatch(cmd);
                break;
        }
@@ -2372,7 +2361,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                        FuncStatus & flag) const
 {
-       LASSERT(cur.text() == this, /**/);
+       LBUFERR(this == cur.text());
 
        FontInfo const & fontinfo = cur.real_current_font.fontInfo();
        bool enable = true;
@@ -2527,13 +2516,12 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        }
        case LFUN_CAPTION_INSERT: {
                code = CAPTION_CODE;
-               bool varia = true;
+               string arg = cmd.getArg(0);
+               bool varia = arg != "LongTableNoNumber";
                if (cur.depth() > 0) {
-                       if (&cur[cur.depth() - 1].inset()
-                           && !cur[cur.depth() - 1].inset().allowsCaptionVariation())
-                               varia = false;
+                       if (&cur[cur.depth() - 1].inset())
+                               varia = cur[cur.depth() - 1].inset().allowsCaptionVariation(arg);
                }
-               string arg = cmd.getArg(0);
                // not allowed in description items,
                // and in specific insets
                enable = !inDescriptionItem(cur)
@@ -2773,6 +2761,20 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                        break;
                }
 
+               // explicit text type?
+               if (arg == "html") {
+                       // Do not enable for PlainTextType, since some tidying in the
+                       // frontend is needed for HTML, which is too unsafe for plain text.
+                       enable = theClipboard().hasTextContents(Clipboard::HtmlTextType);
+                       break;
+               } else if (arg == "latex") {
+                       // LaTeX is usually not available on the clipboard with
+                       // the correct MIME type, but in plain text.
+                       enable = theClipboard().hasTextContents(Clipboard::PlainTextType) ||
+                                theClipboard().hasTextContents(Clipboard::LaTeXTextType);
+                       break;
+               }
+
                // explicit graphics type?
                Clipboard::GraphicsType type = Clipboard::AnyGraphicsType;
                if ((arg == "pdf" && (type = Clipboard::PdfGraphicsType))