[LyX/master] Add context menu support for \includeonly
Juergen Spitzmueller
spitz at lyx.org
Sun Jun 28 15:24:18 UTC 2026
commit b1e84861f8064f138530153cbed50ffd55f12996
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Sun Jun 28 17:23:58 2026 +0200
Add context menu support for \includeonly
---
lib/ui/stdcontext.inc | 8 ++++++++
src/BufferParams.h | 3 +++
src/insets/InsetInclude.cpp | 22 ++++++++++++++++++++++
3 files changed, 33 insertions(+)
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index 7af263fbc4..ea6ee5cc28 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -339,6 +339,10 @@ Menuset
Item "Settings...|S" "inset-settings"
Separator
Item "Edit Included File...|E" "inset-edit"
+ Separator
+ OptItem "Include this child only|u" "inset-modify includeonly"
+ OptItem "Included this child|u" "inset-modify addincludeonly"
+ OptItem "Exclude this child|u" "inset-modify unincludeonly"
End
#
@@ -642,6 +646,10 @@ Menuset
Item "Settings...|S" "inset-settings"
Separator
Item "Edit Included File...|E" "inset-edit"
+ Separator
+ OptItem "Include this child only|u" "inset-modify includeonly"
+ OptItem "Included this child|u" "inset-modify addincludeonly"
+ OptItem "Exclude this child|u" "inset-modify unincludeonly"
End
#
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 2b193cb24f..32ace1e2d5 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -227,6 +227,9 @@ public:
///
void addIncludedChildren(std::string const & child)
{ included_children_.push_back(child); }
+ ///
+ void removeIncludedChildren(std::string const & child)
+ { included_children_.remove(child); }
/// Clear the list of included children
void clearIncludedChildren() { included_children_.clear(); }
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index c3ea5adb06..85d85c815f 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -280,6 +280,19 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
cur.recordUndo();
InsetCommand::doDispatch(cur, cmd);
p = params();
+ } else if (cmd.getArg(0) == "includeonly" || cmd.getArg(0) == "addincludeonly") {
+ cur.recordUndoBufferParams();
+ buffer().params().removeIncludedChildren("@none@");
+ buffer().params().addIncludedChildren(ltrim(to_utf8(params()["filename"])));
+ cur.forceBufferUpdate();
+ break;
+ } else if (cmd.getArg(0) == "unincludeonly") {
+ cur.recordUndoBufferParams();
+ buffer().params().removeIncludedChildren(ltrim(to_utf8(params()["filename"])));
+ if (buffer().params().getIncludedChildren().empty())
+ buffer().params().addIncludedChildren("@none@");
+ cur.forceBufferUpdate();
+ break;
} else
InsetCommand::string2params(to_utf8(cmd.argument()), p);
if (!p.getCmdName().empty()) {
@@ -362,6 +375,15 @@ bool InsetInclude::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "changetype")
return InsetCommand::getStatus(cur, cmd, flag);
+ else if (cmd.getArg(0) == "includeonly")
+ return type(params()) == INCLUDE
+ && (buffer().params().getIncludedChildren().empty());
+ else if (cmd.getArg(0) == "addincludeonly")
+ return type(params()) == INCLUDE
+ && (!isChildIncluded());
+ else if (cmd.getArg(0) == "unincludeonly")
+ return type(params()) == INCLUDE && isChildIncluded()
+ && !buffer().params().getIncludedChildren().empty();
else
flag.setEnabled(true);
return true;
More information about the lyx-cvs
mailing list