mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Extend the branch-(de)activate functions to work without a parameter. In
this case, when the cursor is on a branch inset (using the AtPoint mechanism) the branch to which the branch inset belongs will be (de)activated. This functionality can now be used through the branch inset context menu git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28987 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f5a3bd7c37
commit
6c422712e1
@ -398,4 +398,19 @@ Menuset
|
||||
Item "Settings...|S" "inset-settings info"
|
||||
End
|
||||
|
||||
#
|
||||
# InsetBranch context menu
|
||||
#
|
||||
|
||||
Menu "context-branch"
|
||||
OptItem "Open Inset|O" "inset-toggle open"
|
||||
OptItem "Close Inset|C" "inset-toggle close"
|
||||
Separator
|
||||
OptItem "Activate Branch|A" "branch-activate"
|
||||
OptItem "Deactivate Branch|e" "branch-deactivate"
|
||||
Separator
|
||||
Item "Dissolve Inset|D" "inset-dissolve"
|
||||
OptItem "Settings...|S" "inset-settings"
|
||||
End
|
||||
|
||||
End
|
||||
|
@ -1497,6 +1497,11 @@ bool Buffer::dispatch(FuncRequest const & func, bool * result)
|
||||
case LFUN_BRANCH_DEACTIVATE: {
|
||||
BranchList & branchList = params().branchlist();
|
||||
docstring const branchName = func.argument();
|
||||
// the case without a branch name is handled elsewhere
|
||||
if (branchName.empty()) {
|
||||
dispatched = false;
|
||||
break;
|
||||
}
|
||||
Branch * branch = branchList.find(branchName);
|
||||
if (!branch)
|
||||
LYXERR0("Branch " << branchName << " does not exist.");
|
||||
|
@ -1059,11 +1059,10 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
||||
|
||||
case LFUN_BRANCH_ACTIVATE:
|
||||
case LFUN_BRANCH_DEACTIVATE: {
|
||||
bool enable = false;
|
||||
BranchList const & branchList = buffer_.params().branchlist();
|
||||
docstring const branchName = cmd.argument();
|
||||
if (!branchName.empty())
|
||||
enable = buffer_.params().branchlist().find(branchName);
|
||||
flag.setEnabled(enable);
|
||||
flag.setEnabled(!branchName.empty()
|
||||
&& branchList.find(branchName));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1502,6 +1501,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
||||
|
||||
case LFUN_BRANCH_ACTIVATE:
|
||||
case LFUN_BRANCH_DEACTIVATE:
|
||||
if (cmd.argument().empty())
|
||||
return false;
|
||||
buffer_.dispatch(cmd);
|
||||
processUpdateFlags(Update::Force);
|
||||
break;
|
||||
|
@ -3184,7 +3184,7 @@ void LyXAction::init()
|
||||
* \li Origin: rgh, 27 May 2008
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_BRANCH_ACTIVATE, "branch-activate", Argument, Buffer },
|
||||
{ LFUN_BRANCH_ACTIVATE, "branch-activate", AtPoint, Buffer },
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_BRANCH_DEACTIVATE
|
||||
* \li Action: De-activate the branch
|
||||
@ -3193,7 +3193,7 @@ void LyXAction::init()
|
||||
* \li Origin: rgh, 27 May 2008
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_BRANCH_DEACTIVATE, "branch-deactivate", Argument, Buffer },
|
||||
{ LFUN_BRANCH_DEACTIVATE, "branch-deactivate", AtPoint, Buffer },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_COPY_LABEL_AS_REF
|
||||
|
@ -143,6 +143,18 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cur.bv().updateDialog("branch", params2string(params()));
|
||||
break;
|
||||
|
||||
case LFUN_BRANCH_ACTIVATE:
|
||||
case LFUN_BRANCH_DEACTIVATE: {
|
||||
// FIXME: I do not like this cast, but have no other idea...
|
||||
Buffer * realbuffer = const_cast<Buffer *>(buffer().masterBuffer());
|
||||
BranchList & branchlist = realbuffer->params().branchlist();
|
||||
Branch * ourBranch = branchlist.find(params_.branch);
|
||||
if (!ourBranch)
|
||||
break;
|
||||
ourBranch->setSelected(cmd.action == LFUN_BRANCH_ACTIVATE);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
if (cmd.argument() == "assign")
|
||||
setStatus(cur, isBranchSelected() ? Open : Collapsed);
|
||||
@ -166,12 +178,19 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
flag.setEnabled(true);
|
||||
break;
|
||||
|
||||
case LFUN_BRANCH_ACTIVATE:
|
||||
flag.setEnabled(!isBranchSelected());
|
||||
break;
|
||||
|
||||
case LFUN_BRANCH_DEACTIVATE:
|
||||
flag.setEnabled(isBranchSelected());
|
||||
break;
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
if (cmd.argument() == "assign") {
|
||||
if (cmd.argument() == "assign")
|
||||
flag.setEnabled(true);
|
||||
break;
|
||||
}
|
||||
//fall through to generic InsetCollapsable implmementation
|
||||
else
|
||||
return InsetCollapsable::getStatus(cur, cmd, flag);
|
||||
|
||||
default:
|
||||
return InsetCollapsable::getStatus(cur, cmd, flag);
|
||||
@ -232,6 +251,12 @@ void InsetBranch::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
docstring InsetBranch::contextMenu(BufferView const &, int, int) const
|
||||
{
|
||||
return from_ascii("context-branch");
|
||||
}
|
||||
|
||||
|
||||
bool InsetBranch::isMacroScope() const
|
||||
{
|
||||
// Its own scope if not selected by buffer
|
||||
|
@ -78,6 +78,8 @@ private:
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
docstring contextMenu(BufferView const &, int, int) const;
|
||||
///
|
||||
void addToToc(DocIterator const &);
|
||||
///
|
||||
InsetBranchParams const & params() const { return params_; }
|
||||
|
Loading…
Reference in New Issue
Block a user