mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
* doInsertInset(): cosmetics
* Text::dispatch(): call updateLabels() where it makes sense. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22972 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a235bd7115
commit
371ed5aff5
@ -182,12 +182,14 @@ static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind)
|
|||||||
static bool doInsertInset(Cursor & cur, Text * text,
|
static bool doInsertInset(Cursor & cur, Text * text,
|
||||||
FuncRequest const & cmd, bool edit, bool pastesel)
|
FuncRequest const & cmd, bool edit, bool pastesel)
|
||||||
{
|
{
|
||||||
Inset * inset = createInset(cur.bv().buffer(), cmd);
|
Buffer & buffer = cur.bv().buffer();
|
||||||
|
BufferParams const & bparams = buffer.params();
|
||||||
|
Inset * inset = createInset(buffer, cmd);
|
||||||
if (!inset)
|
if (!inset)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (InsetCollapsable * ci = inset->asInsetCollapsable())
|
if (InsetCollapsable * ci = inset->asInsetCollapsable())
|
||||||
ci->setLayout(cur.bv().buffer().params());
|
ci->setLayout(bparams);
|
||||||
|
|
||||||
cur.recordUndo();
|
cur.recordUndo();
|
||||||
if (cmd.action == LFUN_INDEX_INSERT) {
|
if (cmd.action == LFUN_INDEX_INSERT) {
|
||||||
@ -216,23 +218,21 @@ static bool doInsertInset(Cursor & cur, Text * text,
|
|||||||
lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));
|
lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));
|
||||||
InsetText * insetText = dynamic_cast<InsetText *>(inset);
|
InsetText * insetText = dynamic_cast<InsetText *>(inset);
|
||||||
if (insetText && !insetText->allowMultiPar() || cur.lastpit() == 0) {
|
if (insetText && !insetText->allowMultiPar() || cur.lastpit() == 0) {
|
||||||
// reset first par to default
|
// reset first par to default
|
||||||
LayoutPtr const layout = insetText->useEmptyLayout() ?
|
LayoutPtr const layout = insetText->useEmptyLayout()
|
||||||
cur.buffer().params().getTextClass().emptyLayout() :
|
? bparams.getTextClass().emptyLayout()
|
||||||
cur.buffer().params().getTextClass().defaultLayout();
|
: bparams.getTextClass().defaultLayout();
|
||||||
cur.text()->paragraphs().begin()->layout(layout);
|
cur.text()->paragraphs().begin()->layout(layout);
|
||||||
cur.pos() = 0;
|
cur.pos() = 0;
|
||||||
cur.pit() = 0;
|
cur.pit() = 0;
|
||||||
// Merge multiple paragraphs -- hack
|
// Merge multiple paragraphs -- hack
|
||||||
while (cur.lastpit() > 0) {
|
while (cur.lastpit() > 0)
|
||||||
mergeParagraph(cur.buffer().params(),
|
mergeParagraph(bparams, cur.text()->paragraphs(), 0);
|
||||||
cur.text()->paragraphs(), 0);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// reset surrounding par to default
|
// reset surrounding par to default
|
||||||
docstring const layoutname = insetText->useEmptyLayout() ?
|
docstring const layoutname = insetText->useEmptyLayout()
|
||||||
cur.buffer().params().getTextClass().emptyLayoutName() :
|
? bparams.getTextClass().emptyLayoutName()
|
||||||
cur.buffer().params().getTextClass().defaultLayoutName();
|
: bparams.getTextClass().defaultLayoutName();
|
||||||
cur.leaveInset(*inset);
|
cur.leaveInset(*inset);
|
||||||
text->setLayout(cur, layoutname);
|
text->setLayout(cur, layoutname);
|
||||||
}
|
}
|
||||||
@ -1354,13 +1354,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
#endif
|
#endif
|
||||||
case LFUN_CAPTION_INSERT:
|
case LFUN_CAPTION_INSERT:
|
||||||
case LFUN_FOOTNOTE_INSERT:
|
case LFUN_FOOTNOTE_INSERT:
|
||||||
// Open the inset, and move the current selection
|
|
||||||
// inside it.
|
|
||||||
doInsertInset(cur, this, cmd, true, true);
|
|
||||||
cur.posForward();
|
|
||||||
// These insets are numbered.
|
|
||||||
updateLabels(bv->buffer());
|
|
||||||
break;
|
|
||||||
case LFUN_NOTE_INSERT:
|
case LFUN_NOTE_INSERT:
|
||||||
case LFUN_FLEX_INSERT:
|
case LFUN_FLEX_INSERT:
|
||||||
case LFUN_BOX_INSERT:
|
case LFUN_BOX_INSERT:
|
||||||
@ -1371,10 +1364,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_MARGINALNOTE_INSERT:
|
case LFUN_MARGINALNOTE_INSERT:
|
||||||
case LFUN_OPTIONAL_INSERT:
|
case LFUN_OPTIONAL_INSERT:
|
||||||
case LFUN_ENVIRONMENT_INSERT:
|
case LFUN_ENVIRONMENT_INSERT:
|
||||||
|
case LFUN_INDEX_INSERT:
|
||||||
// Open the inset, and move the current selection
|
// Open the inset, and move the current selection
|
||||||
// inside it.
|
// inside it.
|
||||||
doInsertInset(cur, this, cmd, true, true);
|
doInsertInset(cur, this, cmd, true, true);
|
||||||
cur.posForward();
|
cur.posForward();
|
||||||
|
// Some insets are numbered, others are shown in the outline pane so
|
||||||
|
// let's update the labels and the toc backend.
|
||||||
|
updateLabels(bv->buffer());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_TABULAR_INSERT:
|
case LFUN_TABULAR_INSERT:
|
||||||
@ -1434,11 +1431,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INDEX_INSERT:
|
|
||||||
doInsertInset(cur, this, cmd, true, true);
|
|
||||||
cur.posForward();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LFUN_NOMENCL_INSERT: {
|
case LFUN_NOMENCL_INSERT: {
|
||||||
FuncRequest cmd1 = cmd;
|
FuncRequest cmd1 = cmd;
|
||||||
if (cmd.argument().empty())
|
if (cmd.argument().empty())
|
||||||
|
Loading…
Reference in New Issue
Block a user