ControlDocument::apply has this little chestnut: // Open insets of selected branches, close deselected ones // Currently only top-level insets in buffer handled (bug). ParIterator pit = buffer()->par_iterator_begin(); ParIterator pend = buffer()->par_iterator_end(); for (; pit != pend; ++pit) { pit->insetlist.insetsOpenCloseBranch(*buffer()); }
It seems ridiculous to create an LFUN for this, but a more general LFUN_ALL_INSETS_TOGGLE seems like a good idea. How about: LFUN_ALL_INSETS_TOGGLE ("open" || "close" || "toggle") <name> Resulting in: string action; string const inset_name = split(argument, action, ' '); InsetBase::Code const inset_code = InsetBase::translate(inset_name); for (InsetIterator it(buffer()->inset()); it; ++it) { if (inset_code == InsetBase::NO_CODE || inset_code == it->inset->lyxCode()) it->dispatch(FuncRequest(LFUN_INSET_TOGGLE, action)); } Then it is up to the inset to deal with the action as it chooses. Presumably, if action == "toggle", the branch inset would do the equivalent of: void InsetList::insetsOpenCloseBranch(Buffer const & buf) { List::iterator it = list.begin(); List::iterator end = list.end(); for (; it != end; ++it) { if (!it->inset) continue; if (it->inset->lyxCode() != InsetBase::BRANCH_CODE) continue; InsetBranch * inset = static_cast<InsetBranch *>(it->inset); if (inset->isBranchSelected(buf.params().branchlist())) { inset->open(); } else { inset->close(); } } } Thoughts? -- Angus