[LyX/master] Improve includeonly context menu
Juergen Spitzmueller <[email protected]> Mon, 29 Jun 2026 06:37:23 +0000
| Newsgroups | gmane.editors.lyx.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 18653fb2993606e095205f4ccb3a957fd18bdf29 Author: Juergen Spitzmueller <[email protected]> Date: Mon Jun 29 08:36:29 2026 +0200 Improve includeonly context menu * Add option to include all * Allow to uninclude one if all are included --- lib/ui/stdcontext.inc | 6 ++++-- src/insets/InsetInclude.cpp | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index 7cd2cc55b6..855c76034d 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -342,7 +342,8 @@ Menuset Separator OptItem "Include this child only|u" "inset-modify includeonly" OptItem "Include this child|u" "inset-modify addincludeonly" - OptItem "Exclude this child|u" "inset-modify unincludeonly" + OptItem "Exclude this child|x" "inset-modify unincludeonly" + OptItem "Include all children|a" "inset-modify includeall" End # @@ -649,7 +650,8 @@ Menuset Separator OptItem "Include this child only|u" "inset-modify includeonly" OptItem "Include this child|u" "inset-modify addincludeonly" - OptItem "Exclude this child|u" "inset-modify unincludeonly" + OptItem "Exclude this child|x" "inset-modify unincludeonly" + OptItem "Include all children|a" "inset-modify includeall" End # diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 85d85c815f..2defd467bd 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -288,11 +288,26 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd) break; } else if (cmd.getArg(0) == "unincludeonly") { cur.recordUndoBufferParams(); - buffer().params().removeIncludedChildren(ltrim(to_utf8(params()["filename"]))); + if (buffer().params().getIncludedChildren().empty()) { + for (auto const & cb : buffer().getChildren()) { + string const name = + to_utf8(makeRelPath(from_utf8(cb->fileName().absFileName()), + from_utf8(buffer().filePath()))); + if (name == ltrim(to_utf8(params()["filename"]))) + continue; + buffer().params().addIncludedChildren(name); + } + } else + buffer().params().removeIncludedChildren(ltrim(to_utf8(params()["filename"]))); if (buffer().params().getIncludedChildren().empty()) buffer().params().addIncludedChildren("@none@"); cur.forceBufferUpdate(); break; + } else if (cmd.getArg(0) == "includeall") { + cur.recordUndoBufferParams(); + buffer().params().clearIncludedChildren(); + cur.forceBufferUpdate(); + break; } else InsetCommand::string2params(to_utf8(cmd.argument()), p); if (!p.getCmdName().empty()) { @@ -382,8 +397,10 @@ bool InsetInclude::getStatus(Cursor & cur, FuncRequest const & cmd, return type(params()) == INCLUDE && (!isChildIncluded()); else if (cmd.getArg(0) == "unincludeonly") - return type(params()) == INCLUDE && isChildIncluded() - && !buffer().params().getIncludedChildren().empty(); + return type(params()) == INCLUDE && isChildIncluded(); + else if (cmd.getArg(0) == "includeall") + return type(params()) == INCLUDE && + !buffer().params().getIncludedChildren().empty(); else flag.setEnabled(true); return true; -- lyx-cvs mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-cvs