#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "TextMetrics.h"
-#include "Undo.h"
#include "VSpace.h"
#include "ParIterator.h"
static void finishChange(Cursor & cur, bool selecting)
{
- finishUndo();
+ cur.finishUndo();
moveCursor(cur, selecting);
}
static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
{
- recordUndo(cur);
+ cur.recordUndo();
docstring sel = cur.selectionAsString(false);
// It may happen that sel is empty but there is a selection
static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind)
{
- recordUndo(cur);
+ cur.recordUndo();
cap::replaceSelection(cur);
cur.insert(new InsetSpecialChar(kind));
cur.posRight();
if (!inset)
return false;
- recordUndo(cur);
+ cur.recordUndo();
if (cmd.action == LFUN_INDEX_INSERT) {
docstring ds = support::subst(text->getStringToIndex(cur), '\n', ' ');
text->insertInset(cur, inset);
if (gotsel && pastesel) {
lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));
- if (!static_cast<InsetText *>(inset)->allowMultiPar()
+ InsetText * insetText = dynamic_cast<InsetText *>(inset);
+ if (insetText && !insetText->allowMultiPar()
|| cur.lastpit() == 0) {
// reset first par to default
LayoutPtr const layout =
case LFUN_PARAGRAPH_MOVE_DOWN: {
pit_type const pit = cur.pit();
recUndo(cur, pit, pit + 1);
- finishUndo();
+ cur.finishUndo();
std::swap(pars_[pit], pars_[pit + 1]);
updateLabels(cur.buffer());
needsUpdate = true;
case LFUN_PARAGRAPH_MOVE_UP: {
pit_type const pit = cur.pit();
recUndo(cur, pit - 1, pit);
- finishUndo();
+ cur.finishUndo();
std::swap(pars_[pit], pars_[pit - 1]);
updateLabels(cur.buffer());
--cur.pit();
}
}
- recordUndo(cur);
+ cur.recordUndo();
par.params().startOfAppendix(start);
// we can set the refreshing parameters now
// this avoids a double undo
// FIXME: should not be needed, ideally
if (!cur.selection())
- recordUndo(cur);
+ cur.recordUndo();
cap::replaceSelection(cur);
cur.insert(new InsetNewline);
cur.posRight();
}
case LFUN_INSET_INSERT: {
- recordUndo(cur);
+ cur.recordUndo();
Inset * inset = createInset(bv, cmd);
if (inset) {
// FIXME (Abdel 01/02/2006):
}
bv->buffer().errors("Paste");
cur.clearSelection(); // bug 393
- finishUndo();
+ cur.finishUndo();
break;
case LFUN_CUT:
// this avoids a double undo
// FIXME: should not be needed, ideally
if (!cur.selection())
- recordUndo(cur);
+ cur.recordUndo();
cap::replaceSelection(cur);
pos = cur.pos();
char_type c;
bv->buffer().errorList("Paste"));
bv->buffer().errors("Paste");
bv->buffer().markDirty();
- finishUndo();
+ bv->cursor().finishUndo();
} else {
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
}
break;
}
- case LFUN_URL_INSERT: {
- InsetCommandParams p("url");
+ case LFUN_HYPERLINK_INSERT: {
+ InsetCommandParams p("href");
docstring content;
if (cur.selection()) {
content = cur.selectionAsString(false);
}
p["target"] = (cmd.argument().empty()) ?
content : cmd.argument();
- string const data = InsetCommandMailer::params2string("url", p);
+ string const data = InsetCommandMailer::params2string("href", p);
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);
- if (p["target"].empty()) {
- bv->showInsetDialog("url", data, 0);
+ bv->showInsetDialog("href", data, 0);
} else {
FuncRequest fr(LFUN_INSET_INSERT, data);
dispatch(cur, fr);
}
case LFUN_INFO_INSERT: {
- if (!cur.selection())
- break;
Inset * inset = createInset(&cur.bv(), cmd);
if (!inset)
break;
- // use selected text as info to avoid a separate UI
- docstring ds = cur.selectionAsString(false);
- cutSelection(cur, true, false);
+ // if an empty inset is created (cmd.argument() is empty)
+ // use current selection as parameter.
+ if (cmd.argument().empty() && cur.selection()) {
+ // use selected text as info to avoid a separate UI
+ docstring ds = cur.selectionAsString(false);
+ cutSelection(cur, true, false);
+ static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
+ }
insertInset(cur, inset);
- static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
cur.posRight();
break;
}
Inset * inset = createInset(&cur.bv(), cmd);
if (!inset)
break;
- recordUndo(cur);
+ cur.recordUndo();
cur.clearSelection();
insertInset(cur, inset);
// Show the dialog for the nomenclature entry, since the
case LFUN_FLOAT_LIST: {
TextClass const & tclass = bv->buffer().params().getTextClass();
if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
- recordUndo(cur);
+ cur.recordUndo();
if (cur.selection())
cutSelection(cur, true, false);
breakParagraph(cur);
code = FLOAT_CODE;
else if (cmd.argument() == "graphics")
code = GRAPHICS_CODE;
+ else if (cmd.argument() == "href")
+ code = HYPERLINK_CODE;
else if (cmd.argument() == "include")
code = INCLUDE_CODE;
else if (cmd.argument() == "index")
code = REF_CODE;
else if (cmd.argument() == "toc")
code = TOC_CODE;
- else if (cmd.argument() == "url")
- code = URL_CODE;
else if (cmd.argument() == "vspace")
code = VSPACE_CODE;
else if (cmd.argument() == "wrap")
case LFUN_TOC_INSERT:
code = TOC_CODE;
break;
- case LFUN_HTML_INSERT:
- case LFUN_URL_INSERT:
- code = URL_CODE;
+ case LFUN_HYPERLINK_INSERT:
+ code = HYPERLINK_CODE;
break;
case LFUN_QUOTE_INSERT:
// always allow this, since we will inset a raw quote
break;
case LFUN_INSET_DISSOLVE:
- enable = !isMainText(cur.bv().buffer()) && cur.inset().nargs() == 1;
+ if (!cmd.argument().empty()) {
+ InsetLayout il = cur.inset().getLayout(cur.buffer().params());
+ enable = (cur.inset().lyxCode() == FLEX_CODE)
+ && (il.lyxtype == to_utf8(cmd.argument()));
+ } else
+ enable = !isMainText(cur.bv().buffer())
+ && cur.inset().nargs() == 1;
break;
case LFUN_CHANGE_ACCEPT:
{
cur.clearSelection();
if (!clip.empty()) {
- recordUndo(cur);
+ cur.recordUndo();
if (asParagraphs)
insertStringAsParagraphs(cur, clip);
else