+2003-04-03 John Levon <levon@movementarian.org>
+
+ * bufferview_funcs.h:
+ * bufferview_funcs.C:
+ * lyxfunc.C:
+ * lyxtext.h:
+ * text2.C: make getStatus work for the env depth lfuns
+
2003-04-03 John Levon <levon@movementarian.org>
* bufferview_funcs.h:
}
-void changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type)
+bool changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type, bool test_only)
{
if (!bv->available() || !text)
- return;
+ return false;
+
+ if (test_only)
+ return text->changeDepth(type, true);
bv->hideCursor();
bv->update(BufferView::SELECT);
- text->changeDepth(type);
+ bool const changed = text->changeDepth(type, false);
if (text->inset_owner)
bv->updateInset((Inset *)text->inset_owner);
bv->update(BufferView::SELECT);
+ return changed;
}
DEC_DEPTH
};
-/// change the nesting depth of the selection
-extern void changeDepth(BufferView *, LyXText *, DEPTH_CHANGE);
+/**
+ * Increase or decrease the nesting depth of the selected paragraph(s)
+ * if test_only, don't change any depths. Returns whether something
+ * (would have) changed
+ */
+extern bool changeDepth(BufferView *, LyXText *, DEPTH_CHANGE, bool test_only);
///
extern void emph(BufferView *);
&& !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
break;
+ case LFUN_DEPTH_MIN:
+ disable = !changeDepth(view(), TEXT(false), DEC_DEPTH, true);
+ break;
+
+ case LFUN_DEPTH_PLUS:
+ disable = !changeDepth(view(), TEXT(false), INC_DEPTH, true);
+ break;
+
case LFUN_LAYOUT:
case LFUN_LAYOUT_PARAGRAPH: {
Inset * inset = TEXT(false)->cursor.par()->inInset();
break;
case LFUN_DEPTH_MIN:
- changeDepth(view(), TEXT(false), bv_funcs::DEC_DEPTH);
+ changeDepth(view(), TEXT(false), DEC_DEPTH, false);
break;
case LFUN_DEPTH_PLUS:
- changeDepth(view(), TEXT(false), bv_funcs::INC_DEPTH);
+ changeDepth(view(), TEXT(false), INC_DEPTH, false);
break;
case LFUN_FREEFONT_APPLY:
///
void setLayout(string const & layout);
- /// increase or decrease the nesting depth of the selected paragraph(s)
- void changeDepth(bv_funcs::DEPTH_CHANGE type);
+ /**
+ * Increase or decrease the nesting depth of the selected paragraph(s)
+ * if test_only, don't change any depths. Returns whether something
+ * (would have) changed
+ */
+ bool changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only);
/// get the depth at current cursor position
int getDepth() const;
}
-void LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type)
+bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
{
ParagraphList::iterator pit(cursor.par());
ParagraphList::iterator end(cursor.par());
++pastend;
setUndo(bv(), Undo::EDIT, &(*start), &(*pastend));
+ bool changed = false;
+
int prev_after_depth = 0;
#warning parlist ... could be nicer ?
if (start != ownerParagraphs().begin())
if (type == bv_funcs::INC_DEPTH) {
if (depth < prev_after_depth
&& pit->layout()->labeltype != LABEL_BIBLIO) {
- pit->params().depth(depth + 1);
+ changed = true;
+ if (!test_only)
+ pit->params().depth(depth + 1);
}
- } else {
- if (depth)
+ } else if (depth) {
+ changed = true;
+ if (!test_only)
pit->params().depth(depth - 1);
}
++pit;
}
+ if (test_only)
+ return changed;
+
// Wow, redoParagraphs is stupid.
LyXCursor tmpcursor;
setCursor(tmpcursor, &(*start), 0);
updateCounters();
setSelection();
setCursor(tmpcursor.par(), tmpcursor.pos());
+
+ return changed;
}