Conceptually, this is pretty straightforward, but can someone tell me if
this is the right place to implement these? LFUNs are implemented all
over, and I don't really understand the logic to what happens where.
Unfortunately, this doesn't seem to answer the 4341 request, since I
can't get something like:
lyx -e pdf2 -x "branch-activate answers" FinalExam.lyx
to work. I.e., to activate the branch before export. Should it work? Or
is providing that sort of facility a separate issue?
Richard
Index: LyXAction.cpp
===================================================================
--- LyXAction.cpp (revision 24968)
+++ LyXAction.cpp (working copy)
@@ -2168,6 +2168,24 @@
* \endvar
*/
{ LFUN_COMPLETION_COMPLETE, "complete", SingleParUpdate, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_BRANCH_ACTIVATE
+ * \li Action: Activate the branch
+ * \li Syntax: branch-activate <BRANCH>
+ * \li Params: <BRANCH>: The branch to activate
+ * \li Origin: rgh, 27 May 2008
+ * \endvar
+ */
+ { LFUN_BRANCH_ACTIVATE, "branch-activate", Argument, Buffer },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_BRANCH_ACTIVATE
+ * \li Action: De-activate the branch
+ * \li Syntax: branch-deactivate <BRANCH>
+ * \li Params: <BRANCH>: The branch to deactivate
+ * \li Origin: rgh, 27 May 2008
+ * \endvar
+ */
+ { LFUN_BRANCH_DEACTIVATE, "branch-deactivate", Argument, Buffer
},
{ LFUN_NOACTION, "", Noop, Hidden }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
Index: Text3.cpp
===================================================================
--- Text3.cpp (revision 24968)
+++ Text3.cpp (working copy)
@@ -1837,6 +1837,32 @@
needsUpdate = true;
break;
+ case LFUN_BRANCH_ACTIVATE: {
+ BranchList & branchList = cur.buffer().params().branchlist();
+ docstring const branchName = cmd.argument();
+ Branch * branch = branchList.find(branchName);
+ if (!branch)
+ LYXERR0("Branch " << branchName << " does not exist.");
+ else if (branch->setSelected(true)) {
+ updateLabels(cur.buffer());
+ needsUpdate = true;
+ }
+ break;
+ }
+
+ case LFUN_BRANCH_DEACTIVATE: {
+ BranchList & branchList = cur.buffer().params().branchlist();
+ docstring const branchName = cmd.argument();
+ Branch * branch = branchList.find(branchName);
+ if (!branch)
+ LYXERR0("Branch " << branchName << " does not exist.");
+ else if (branch->setSelected(false)) {
+ updateLabels(cur.buffer());
+ needsUpdate = true;
+ }
+ break;
+ }
+
default:
LYXERR(Debug::ACTION, "Command " << cmd << " not DISPATCHED by
Text");
cur.undispatched();
@@ -2191,6 +2217,18 @@
break;
}
+ case LFUN_BRANCH_ACTIVATE:
+ case LFUN_BRANCH_DEACTIVATE: {
+ docstring const branchName = cmd.argument();
+ if (branchName.empty())
+ enable = false;
+ else {
+ BranchList const & branchList =
cur.buffer().params().branchlist();
+ enable = branchList.find(branchName);
+ }
+ break;
+ }
+
case LFUN_WORD_DELETE_FORWARD:
case LFUN_WORD_DELETE_BACKWARD:
case LFUN_LINE_DELETE:
Index: FuncCode.h
===================================================================
--- FuncCode.h (revision 24968)
+++ FuncCode.h (working copy)
@@ -410,6 +410,8 @@
// 315
LFUN_GRAPHICS_GROUPS_UNIFY,
LFUN_SET_GRAPHICS_GROUP,
+ LFUN_BRANCH_ACTIVATE,
+ LFUN_BRANCH_DEACTIVATE,
LFUN_LASTACTION // end of the table
};