X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=70453620ac9251541b382b1614aa453fb365ed3e;hb=4db3e641ed6765e005343010cb90ee8af26f8f99;hp=b87cf2904a2133816e828be1a51b88269bad1283;hpb=c61ef8b205ee0fb6473af0f120c359e7d1ebe83c;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index b87cf2904a..70453620ac 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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; @@ -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(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; @@ -2772,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))