Paragraph & par = cur.paragraph();
bool start = !par.params().startOfAppendix();
-#ifdef WITH_WARNINGS
-#warning The code below only makes sense at top level.
+// FIXME: The code below only makes sense at top level.
// Should LFUN_APPENDIX be restricted to top-level paragraphs?
-#endif
// ensure that we have only one start_of_appendix in this document
// FIXME: this don't work for multipart document!
for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
case LFUN_DELETE_BACKWARD_SKIP:
// Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
if (!cur.selection()) {
-#ifdef WITH_WARNINGS
-#warning look here
-#endif
+ // FIXME: look here
//CursorSlice cur = cursor();
backspace(cur);
//anchor() = cur;
dispatch(cur, fr);
}
*/
+ if (cur.selection())
+ cutSelection(cur, true, false);
insertInset(cur, inset);
cur.posRight();
}
break;
}
- case LFUN_DATE_INSERT:
- if (cmd.argument().empty())
- lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
- formatted_time(current_time())));
- else
- lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
- formatted_time(current_time(), to_utf8(cmd.argument()))));
+ case LFUN_DATE_INSERT: {
+ string const format = cmd.argument().empty()
+ ? lyxrc.date_insert_format : to_utf8(cmd.argument());
+ string const time = formatted_time(current_time(), format);
+ lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, time));
break;
+ }
case LFUN_MOUSE_TRIPLE:
if (cmd.button() == mouse_button::button1) {
if (cmd.button() == mouse_button::button3)
cur.clearSelection();
- // Middle button press pastes if we have a selection
- // We do this here as if the selection was inside an inset
- // it could get cleared on the unlocking of the inset so
- // we have to check this first
- bool paste_internally = false;
- if (cmd.button() == mouse_button::button2 && cap::selection()) {
- // Copy the selection buffer to the clipboard
- // stack, because we want it to appear in the
- // "Edit->Paste recent" menu.
- cap::copySelectionToStack();
- paste_internally = true;
- }
+ // Set the cursor
+ bool update = bv->mouseSetCursor(cur);
// Insert primary selection with middle mouse
// if there is a local selection in the current buffer,
// insert this
if (cmd.button() == mouse_button::button2) {
- if (paste_internally) {
- cap::pasteSelection(cur, bv->buffer()->errorList("Paste"));
+ if (cap::selection()) {
+ // Copy the selection buffer to the clipboard
+ // stack, because we want it to appear in the
+ // "Edit->Paste recent" menu.
+ cap::copySelectionToStack();
+
+ cap::pasteSelection(bv->cursor(),
+ bv->buffer()->errorList("Paste"));
bv->buffer()->errors("Paste");
- cur.clearSelection(); // bug 393
bv->buffer()->markDirty();
finishUndo();
} else {
- bv->mouseSetCursor(cur);
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
}
}
- // we have to update after dePM triggered
- bool update = bv->mouseSetCursor(cur);
-
+ // we have to update after dEPM triggered
if (!update && cmd.button() == mouse_button::button1) {
needsUpdate = false;
cur.noUpdate();
case LFUN_URL_INSERT: {
InsetCommandParams p("url");
+ docstring content;
+ if (cur.selection()) {
+ content = cur.selectionAsString(false);
+ cutSelection(cur, true, false);
+ }
+ p["target"] = (cmd.argument().empty()) ?
+ content : cmd.argument();
string const data = InsetCommandMailer::params2string("url", p);
- bv->showInsetDialog("url", data, 0);
+ if (p["target"].empty()) {
+ bv->showInsetDialog("url", data, 0);
+ } else {
+ FuncRequest fr(LFUN_INSET_INSERT, data);
+ dispatch(cur, fr);
+ }
break;
}
case LFUN_HTML_INSERT: {
InsetCommandParams p("htmlurl");
+ docstring content;
+ if (cur.selection()) {
+ content = cur.selectionAsString(false);
+ cutSelection(cur, true, false);
+ }
+ p["target"] = (cmd.argument().empty()) ?
+ content : cmd.argument();
string const data = InsetCommandMailer::params2string("url", p);
- bv->showInsetDialog("url", data, 0);
+ if (p["target"].empty()) {
+ bv->showInsetDialog("url", data, 0);
+ } else {
+ FuncRequest fr(LFUN_INSET_INSERT, data);
+ dispatch(cur, fr);
+ }
break;
}
case LFUN_FLOAT_LIST: {
TextClass const & tclass = bv->buffer()->params().getTextClass();
if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
- // not quite sure if we want this...
recordUndo(cur);
- cur.clearSelection();
+ if (cur.selection())
+ cutSelection(cur, true, false);
breakParagraph(cur);
if (cur.lastpos() != 0) {