* src/Text3.cpp (doDispatch):

- always replace selected text when inserting an inset (bug 672)
	- inset selected text in inserted URL inset (bug 683)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19231 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-07-30 10:33:43 +00:00
parent 606e4877d1
commit 6b87509156

View File

@ -755,6 +755,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
dispatch(cur, fr); dispatch(cur, fr);
} }
*/ */
if (cur.selection())
cutSelection(cur, true, false);
insertInset(cur, inset); insertInset(cur, inset);
cur.posRight(); cur.posRight();
} }
@ -1158,15 +1160,39 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_URL_INSERT: { case LFUN_URL_INSERT: {
InsetCommandParams p("url"); 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); 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; break;
} }
case LFUN_HTML_INSERT: { case LFUN_HTML_INSERT: {
InsetCommandParams p("htmlurl"); 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); 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; break;
} }
@ -1503,9 +1529,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_FLOAT_LIST: { case LFUN_FLOAT_LIST: {
TextClass const & tclass = bv->buffer()->params().getTextClass(); TextClass const & tclass = bv->buffer()->params().getTextClass();
if (tclass.floats().typeExist(to_utf8(cmd.argument()))) { if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
// not quite sure if we want this...
recordUndo(cur); recordUndo(cur);
cur.clearSelection(); if (cur.selection())
cutSelection(cur, true, false);
breakParagraph(cur); breakParagraph(cur);
if (cur.lastpos() != 0) { if (cur.lastpos() != 0) {