From 7cc431bd55c0df8acff679a2da72d85e74f3a8d7 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 28 Jun 2023 16:05:21 +0200 Subject: [PATCH] Add optional parameter 'local' to outline-in/out When this parameter is given, only the current paragraph is affected by the section promoting/demoting. Note that the new argument is not used yet. Update release notes and LFUNS documentation. Part of ticket #12417. --- lib/RELEASE-NOTES | 5 ++++- src/LyXAction.cpp | 6 ++++-- src/Text.cpp | 22 ++++++++++++---------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES index dda358c54e..9e9611b30d 100644 --- a/lib/RELEASE-NOTES +++ b/lib/RELEASE-NOTES @@ -173,7 +173,7 @@ * index-tag-all adds a copy of the index entry under cursor to after all occurrences of the word that precedes the index inset. - + * inset-insert-copy inserts the inset's content (in ToC pane) at the position of the cursor. * inset-split is a new convenience function that splits an inset into two at the given @@ -195,6 +195,9 @@ * info-insert buffer vcs-*: renamed to info-insert vcs * +* outline-in/out can now take argument "local", that restricts their + action to the current paragraph. + * set-graphics-group was renamed to graphics-set-group. * tabular-feature: added toggle parameters "toggle-all-lines", "toggle-border-lines" diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 5688c0962a..9ebf307d6e 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -3237,7 +3237,8 @@ void LyXAction::init() * \li Action: Moves the current group in the downward direction in the hierarchy of the document structure. * \li Notion: Part -> Chapter -> Section -> etc. - * \li Syntax: outline-in + * \li Syntax: outline-in [local] + * \li Params: local: if given, only the current paragraph will be affected. * \li Origin: Vermeer, 23 Mar 2006 * \endvar */ @@ -3248,7 +3249,8 @@ void LyXAction::init() * \li Action: Moves the current group in the upward direction in the hierarchy of the document structure. * \li Notion: Part <- Chapter <- Section <- etc. - * \li Syntax: outline-out + * \li Syntax: outline-out [local] + * \li Params: local: if given, only the current paragraph will be affected. * \li Origin: Vermeer, 23 Mar 2006 * \endvar */ diff --git a/src/Text.cpp b/src/Text.cpp index 3dae5c78ff..a61e32574a 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -3746,7 +3746,7 @@ void insertSeparator(Cursor const & cur, depth_type const depth) } -void outline(OutlineOp mode, Cursor & cur) +void outline(OutlineOp mode, Cursor & cur, bool local) { Buffer & buf = *cur.buffer(); Text & text = *cur.text(); @@ -3767,11 +3767,13 @@ void outline(OutlineOp mode, Cursor & cur) if (finish != end) ++finish; - // Seek the one (on same level) below - for (; finish != end; ++finish) { - toclevel = text.getTocLevel(distance(bgn, finish)); - if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel) - break; + if (!local || (mode != OutlineIn && mode != OutlineOut)) { + // Seek the one (on same level) below + for (; finish != end; ++finish) { + toclevel = text.getTocLevel(distance(bgn, finish)); + if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel) + break; + } } switch (mode) { @@ -6248,7 +6250,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_OUTLINE_UP: { pos_type const opos = cur.pos(); - outline(OutlineUp, cur); + outline(OutlineUp, cur, false); setCursor(cur, cur.pit(), opos); cur.forceBufferUpdate(); needsUpdate = true; @@ -6257,7 +6259,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_OUTLINE_DOWN: { pos_type const opos = cur.pos(); - outline(OutlineDown, cur); + outline(OutlineDown, cur, false); setCursor(cur, cur.pit(), opos); cur.forceBufferUpdate(); needsUpdate = true; @@ -6265,13 +6267,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_OUTLINE_IN: - outline(OutlineIn, cur); + outline(OutlineIn, cur, cmd.getArg(0) == "local"); cur.forceBufferUpdate(); needsUpdate = true; break; case LFUN_OUTLINE_OUT: - outline(OutlineOut, cur); + outline(OutlineOut, cur, cmd.getArg(0) == "local"); cur.forceBufferUpdate(); needsUpdate = true; break;