/**
* This breaks a paragraph at the specified position.
* The new paragraph will:
- * - Decrease depth by one (or change layout to default layout) when
- * keep_layout == false
- * - keep current depth and layout when keep_layout == true
+ * - change layout to default layout when keep_layout == false
+ * - keep layout when keep_layout == true
*/
static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
bool keep_layout)
// remember to set the inset_owner
tmp->setInsetOwner(&par.inInset());
- // without doing that we get a crash when typing <Return> at the
- // end of a paragraph
- tmp->setPlainOrDefaultLayout(bparams.documentClass());
+ tmp->params().depth(par.params().depth());
if (keep_layout) {
tmp->setLayout(par.layout());
tmp->setLabelWidthString(par.params().labelWidthString());
- tmp->params().depth(par.params().depth());
- } else if (par.params().depth() > 0) {
- Paragraph const & hook = pars[text.outerHook(par_offset)];
- tmp->setLayout(hook.layout());
- // not sure the line below is useful
- tmp->setLabelWidthString(par.params().labelWidthString());
- tmp->params().depth(hook.params().depth());
- }
+ } else
+ tmp->setPlainOrDefaultLayout(bparams.documentClass());
bool const isempty = (par.allowEmpty() && par.empty());
Layout priorlayout;
Cursor c(cur.bv());
c.setCursor(cur.selectionBegin());
- for ( ; c <= cur.selectionEnd() ; ++c.pit()) {
+ pit_type const last_pit = cur.selectionEnd().pit();
+ for ( ; c.pit() <= last_pit ; ++c.pit()) {
Paragraph & par = c.paragraph();
ParagraphParameters params = par.params();
params.read(argument, merge);
Layout priorlayout;
Cursor c(cur.bv());
c.setCursor(cur.selectionBegin());
- for ( ; c < cur.selectionEnd() ; ++c.pit()) {
+ pit_type const last_pit = cur.selectionEnd().pit();
+ for ( ; c.pit() <= last_pit ; ++c.pit()) {
Paragraph & par = c.paragraph();
// Changes to label width string apply to all paragraphs
// with same layout in a sequence.
}
-void outline(OutlineOp mode, Cursor & cur)
+void outline(OutlineOp mode, Cursor & cur, bool local)
{
Buffer & buf = *cur.buffer();
Text & text = *cur.text();
if (finish != end)
++finish;
- // Seek the one (on same level) below
- for (; finish != end; ++finish) {
- toclevel = text.getTocLevel(distance(bgn, finish));
- if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel)
- break;
+ if (!local || (mode != OutlineIn && mode != OutlineOut)) {
+ // Seek the one (on same level) below
+ for (; finish != end; ++finish) {
+ toclevel = text.getTocLevel(distance(bgn, finish));
+ if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel)
+ break;
+ }
}
switch (mode) {
case LFUN_OUTLINE_UP: {
pos_type const opos = cur.pos();
- outline(OutlineUp, cur);
+ outline(OutlineUp, cur, false);
setCursor(cur, cur.pit(), opos);
cur.forceBufferUpdate();
needsUpdate = true;
case LFUN_OUTLINE_DOWN: {
pos_type const opos = cur.pos();
- outline(OutlineDown, cur);
+ outline(OutlineDown, cur, false);
setCursor(cur, cur.pit(), opos);
cur.forceBufferUpdate();
needsUpdate = true;
}
case LFUN_OUTLINE_IN:
- outline(OutlineIn, cur);
+ outline(OutlineIn, cur, cmd.getArg(0) == "local");
cur.forceBufferUpdate();
needsUpdate = true;
break;
case LFUN_OUTLINE_OUT:
- outline(OutlineOut, cur);
+ outline(OutlineOut, cur, cmd.getArg(0) == "local");
cur.forceBufferUpdate();
needsUpdate = true;
break;
s = from_ascii("Flex:") + s;
if (!cur.buffer()->params().documentClass().hasInsetLayout(s))
enable = false;
+ else if (!cur.paragraph().allowedInContext(cur, cur.buffer()->params().documentClass().insetLayout(s)))
+ enable = false;
else {
InsetLyXType ilt =
cur.buffer()->params().documentClass().insetLayout(s).lyxtype();