using cap::copySelection;
using cap::cutSelection;
using cap::pasteFromStack;
-using cap::pasteClipboard;
+using cap::pasteClipboardText;
+using cap::pasteClipboardGraphics;
using cap::replaceSelection;
// globals...
// somewhere, and an ordinary formula
// otherwise
if (sel.find(from_ascii("\\newcommand")) == string::npos
+ && sel.find(from_ascii("\\newlyxcommand")) == string::npos
&& sel.find(from_ascii("\\def")) == string::npos)
{
InsetMathHull * formula = new InsetMathHull;
} else {
cur.undispatched();
}
+ cur.updateFlags(Update::FitCursor);
break;
case LFUN_BUFFER_END:
} else {
cur.undispatched();
}
+ cur.updateFlags(Update::FitCursor);
break;
case LFUN_CHAR_FORWARD:
charsTranspose(cur);
break;
- case LFUN_PASTE:
+ case LFUN_PASTE: {
cur.message(_("Paste"));
cap::replaceSelection(cur);
- if (cmd.argument().empty() && !theClipboard().isInternal())
- pasteClipboard(cur, bv->buffer().errorList("Paste"));
- else {
- string const arg(to_utf8(cmd.argument()));
+
+ // without argument?
+ string const arg = to_utf8(cmd.argument());
+ if (arg.empty()) {
+ if (theClipboard().isInternal())
+ pasteFromStack(cur, bv->buffer().errorList("Paste"), 0);
+ else if (theClipboard().hasGraphicsContents())
+ pasteClipboardGraphics(cur, bv->buffer().errorList("Paste"));
+ else
+ pasteClipboardText(cur, bv->buffer().errorList("Paste"));
+ } else if (isStrUnsignedInt(arg)) {
+ // we have a numerical argument
pasteFromStack(cur, bv->buffer().errorList("Paste"),
- isStrUnsignedInt(arg) ?
- convert<unsigned int>(arg) :
- 0);
+ convert<unsigned int>(arg));
+ } else {
+ Clipboard::GraphicsType type;
+ if (arg == "pdf")
+ type = Clipboard::PdfGraphicsType;
+ else if (arg == "png")
+ type = Clipboard::PngGraphicsType;
+ else if (arg == "jpeg")
+ type = Clipboard::JpegGraphicsType;
+ else if (arg == "linkback")
+ type = Clipboard::LinkBackGraphicsType;
+ else
+ BOOST_ASSERT(false);
+
+ pasteClipboardGraphics(cur, bv->buffer().errorList("Paste"), type);
}
+
bv->buffer().errors("Paste");
cur.clearSelection(); // bug 393
cur.finishUndo();
break;
+ }
case LFUN_CUT:
cutSelection(cur, true, true);
case LFUN_CLIPBOARD_PASTE:
cur.clearSelection();
- pasteClipboard(cur, bv->buffer().errorList("Paste"),
+ pasteClipboardText(cur, bv->buffer().errorList("Paste"),
cmd.argument() == "paragraph");
bv->buffer().errors("Paste");
break;
docstring ds = cur.selectionAsString(false);
cutSelection(cur, true, false);
static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
+ static_cast<InsetInfo *>(inset)->updateInfo(cur.bv().buffer());
}
insertInset(cur, inset);
cur.posForward();
string const s1 = token(s, ' ', 1);
int const nargs = s1.empty() ? 0 : convert<int>(s1);
string const s2 = token(s, ' ', 2);
- string const type = s2.empty() ? "newcommand" : s2;
- cur.insert(new MathMacroTemplate(from_utf8(token(s, ' ', 0)), nargs, false, from_utf8(type)));
+ MacroType type = MacroTypeNewcommand;
+ if (s2 == "def")
+ type = MacroTypeDef;
+ cur.insert(new MathMacroTemplate(from_utf8(token(s, ' ', 0)), nargs, false, type));
//cur.nextInset()->edit(cur, true);
}
break;
case LFUN_MATH_MATRIX:
case LFUN_MATH_DELIM:
case LFUN_MATH_BIGDELIM: {
- if (cur.selection())
- cur.clearSelection();
- // FIXME: instead of the above, this one
- // should be used (but it asserts with Bidi enabled)
- // cf. http://bugzilla.lyx.org/show_bug.cgi?id=4055
- // cap::replaceSelection(cur);
+ cap::replaceSelection(cur);
cur.insert(new InsetMathHull(hullSimple));
checkAndActivateInset(cur, true);
BOOST_ASSERT(cur.inMathed());
enable = cur.selection();
break;
- case LFUN_PASTE:
+ case LFUN_PASTE: {
if (cmd.argument().empty()) {
if (theClipboard().isInternal())
enable = cap::numberOfSelections() > 0;
else
enable = !theClipboard().empty();
- } else {
- string const arg = to_utf8(cmd.argument());
- if (isStrUnsignedInt(arg)) {
- unsigned int n = convert<unsigned int>(arg);
- enable = cap::numberOfSelections() > n;
- } else
- // unknown argument
- enable = false;
+ break;
+ }
+
+ // we have an argument
+ string const arg = to_utf8(cmd.argument());
+ if (isStrUnsignedInt(arg)) {
+ // it's a number and therefore means the internal stack
+ unsigned int n = convert<unsigned int>(arg);
+ enable = cap::numberOfSelections() > n;
+ break;
+ }
+
+ // explicit graphics type?
+ if ((arg == "pdf" && theClipboard().hasGraphicsContents(Clipboard::PdfGraphicsType))
+ || (arg == "png" && theClipboard().hasGraphicsContents(Clipboard::PngGraphicsType))
+ || (arg == "jpeg" && theClipboard().hasGraphicsContents(Clipboard::JpegGraphicsType))
+ || (arg == "linkback" && theClipboard().hasGraphicsContents(Clipboard::LinkBackGraphicsType))) {
+ enable = true;
+ break;
}
+
+ // unknown argument
+ enable = false;
break;
+ }
case LFUN_CLIPBOARD_PASTE:
enable = !theClipboard().empty();