+2004-03-31 Angus Leeming <leeming@lyx.org>
+
+ * lyxfunc.C (dispatch): remove the cursor-manipulation code from
+ the LFUN_ALL_INSETS_TOGGLE code.
+
2004-03-30 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): the specialization Dialogs::showDocument
+2004-03-31 Angus Leeming <leeming@lyx.org>
+
+ * insetcollapsable.[Ch] (getOutOfInset): new function which pushes
+ the cursor out of an inset.
+
+ * insetbranch.C (priv_dispatch):
+ * insetcollapsable.C (priv_dispatch): in the LFUN_INSET_TOGGLE code,
+ use getOutOfInset to push the cursor out of the inset when
+ collapsing it.
+
2004-03-30 Angus Leeming <leeming@lyx.org>
* insetbase.[Ch] (translate): new static member function, returns
if (cmd.argument == "open")
setStatus(Open);
- else if (cmd.argument == "close")
+ else if (cmd.argument == "close") {
setStatus(Collapsed);
+ getOutOfInset(cur, *this);
// The branch inset specialises its behaviour on "toggle".
- else if (cmd.argument == "toggle"
- || cmd.argument.empty()) {
+ } else if (cmd.argument == "toggle"
+ || cmd.argument.empty()) {
BranchList const & branchlist =
cur.bv().buffer()->params().branchlist();
if (isBranchSelected(branchlist)) {
else
cur.undispatched();
} else {
- if (status() != Collapsed)
+ if (status() != Collapsed) {
setStatus(Collapsed);
- else
+ getOutOfInset(cur, *this);
+ } else
cur.undispatched();
}
}
using std::ostream;
+void getOutOfInset(LCursor & cur, InsetBase const & in)
+{
+ for (unsigned int i = 0; i != cur.size(); ++i) {
+ if (&cur[i].inset() == &in) {
+ cur.resize(i);
+ return;
+ }
+ }
+}
+
+
InsetCollapsable::InsetCollapsable(BufferParams const & bp,
CollapseStatus status)
: InsetText(bp), label("Label"), status_(status), openinlined_(false)
case LFUN_INSET_TOGGLE:
if (cmd.argument == "open")
setStatus(Open);
- else if (cmd.argument == "close")
+ else if (cmd.argument == "close") {
setStatus(Collapsed);
- else if (cmd.argument == "toggle"
- || cmd.argument.empty()) {
- if (isOpen())
+ getOutOfInset(cur, *this);
+ } else if (cmd.argument == "toggle"
+ || cmd.argument.empty()) {
+ if (isOpen()) {
setStatus(Collapsed);
- else
+ getOutOfInset(cur, *this);
+ } else
setStatus(Open);
}
cur.dispatched();
mutable Dimension textdim_;
};
+// A helper function that pushes the cursor out of the inset.
+void getOutOfInset(LCursor & cur, InsetBase const & in);
+
#endif
InsetIterator const end = inset_iterator_end(inset);
for (; it != end; ++it) {
if (inset_code == InsetBase::NO_CODE
- || inset_code == it->lyxCode()) {
+ || inset_code == it->lyxCode())
it->dispatch(cur, fr);
- if (&cur.inset() == &*it
- && cur.disp_.dispatched())
- cur.pop();
- }
}
break;
}