Opening activated branch insets
Pavel Sanda
sanda at lyx.org
Fri Apr 15 15:21:46 UTC 2022
On Fri, Apr 15, 2022 at 02:41:53AM +0200, Pavel Sanda wrote:
> On Fri, Apr 15, 2022 at 12:01:04AM +0200, Jean-Marc Lasgouttes wrote:
> > Le 13/04/2022 ?? 14:39, Pavel Sanda a écrit :
> > >So changing the core of the patch to something like
> > >
> > >+ case LFUN_BRANCH_SYNC_ALL:
> > >+ lyx::dispatch(FuncRequest(LFUN_INSET_FORALL, "Branch:" + params_.branch + " inset-toggle auto"));
> > >+ break;
> > >
> > >would be acceptable for you?
> >
> > Sure, once the "auto" thing is implemented :)
>
> I thought that's only question of launching github copilot nowadays :)
> (Planned to look at that after your ack.)
It turned out to be even easier, because no one removed the old code
when this feature was killed, it's just called assign.
Patch attached. I'll strip context menu entry before commiting unless
someone does not activaly ask for it.
Pavel
-------------- next part --------------
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index ed9a9da9fa..1448ee533b 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -535,6 +535,7 @@ Menuset
OptItem "Deactivate Branch in Master|v" "branch-master-deactivate"
OptItem "Invert Inset|I" "branch-invert"
OptItem "Add Unknown Branch|w" "branch-add"
+ OptItem "Sync all|y" "branch-sync-all"
End
#
diff --git a/src/FuncCode.h b/src/FuncCode.h
index 20231eb164..8337c1f921 100644
--- a/src/FuncCode.h
+++ b/src/FuncCode.h
@@ -502,6 +502,7 @@ enum FuncCode
LFUN_SPELLING_REMOVE_LOCAL, // jspitzm 20210307
LFUN_FINISHED_DOWN, // lasgouttes 20210629
LFUN_FINISHED_UP, // lasgouttes 20210629
+ LFUN_BRANCH_SYNC_ALL, // sanda 20220415
LFUN_LASTACTION // end of the table
};
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index ea60f53754..c88c1b9873 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -452,6 +452,15 @@ void LyXAction::init()
*/
{ LFUN_BRANCH_INSERT, "branch-insert", Noop, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_BRANCH_SYNC_ALL
+ * \li Action: Open/close all insets of selected branch (depending on its selection status).
+ * \li Syntax: branch-toggle-all
+ * \li Origin: sanda, 15 April 2022
+ * \endvar
+ */
+ { LFUN_BRANCH_SYNC_ALL, "branch-sync-all", AtPoint, Buffer },
+
/*!
* \var lyx::FuncCode lyx::LFUN_BRANCH_INVERT
* \li Action: Toggles inversion status of branch inset.
diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp
index 7a102ceab6..1ff7f248b4 100644
--- a/src/insets/InsetBranch.cpp
+++ b/src/insets/InsetBranch.cpp
@@ -224,6 +224,9 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_BRANCH_ADD:
lyx::dispatch(FuncRequest(LFUN_BRANCH_ADD, params_.branch));
break;
+ case LFUN_BRANCH_SYNC_ALL:
+ lyx::dispatch(FuncRequest(LFUN_INSET_FORALL, "Branch:" + params_.branch + " inset-toggle assign"));
+ break;
case LFUN_INSET_TOGGLE:
if (cmd.argument() == "assign")
setStatus(cur, isBranchSelected() ? Open : Collapsed);
@@ -276,6 +279,10 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
flag.setEnabled(buffer().parent() && isBranchSelected());
break;
+ case LFUN_BRANCH_SYNC_ALL:
+ flag.setEnabled(known_branch);
+ break;
+
case LFUN_INSET_TOGGLE:
if (cmd.argument() == "assign")
flag.setEnabled(true);
More information about the lyx-devel
mailing list