commit 701a3865968a5a4a0460864651b3d55dcd4f7e73
Author: Juergen Spitzmueller <[email protected]>
Date: Wed Apr 2 09:15:50 2025 +0200
Enhance LFUN_REFERENCE_TO_PARAGRAPH
This is in preparation to employ this feature in the ref dialog.
---
src/BufferView.cpp | 9 +++++++--
src/BufferView.h | 5 +++++
src/LyXAction.cpp | 8 ++++++--
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 500c359d65..9e4b9e6028 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1698,6 +1698,7 @@ void BufferView::dispatch(FuncRequest const & cmd,
DispatchResult & dr)
vector<string> const pids = getVectorFromString(cmd.getArg(0));
string const type = cmd.getArg(1);
int id = convert<int>(pids.back());
+ inserted_label_.clear();
if (id < 0)
break;
int i = 0;
@@ -1738,8 +1739,12 @@ void BufferView::dispatch(FuncRequest const & cmd,
DispatchResult & dr)
:
to_utf8(new_label) + " " + type;
// ... and go back to the original position
lyx::dispatch(FuncRequest(LFUN_BOOKMARK_GOTO,
"0"));
- // ... to insert the ref
-
lyx::dispatch(FuncRequest(LFUN_REFERENCE_INSERT, arg));
+ if (type == "forrefdialog")
+ // and save for the ref dialog to insert
+ inserted_label_ = arg;
+ else
+ // ... or insert the ref directly (from
outliner)
+
lyx::dispatch(FuncRequest(LFUN_REFERENCE_INSERT, arg));
break;
}
}
diff --git a/src/BufferView.h b/src/BufferView.h
index de735c1f9c..8652c5a6ed 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -412,6 +412,9 @@ public:
//signals need for update in gui
bool stats_update_trigger();
+ /// Inserted label from ref dialog
+ std::string insertedLabel() const { return inserted_label_; }
+
private:
/// noncopyable
BufferView(BufferView const &);
@@ -464,6 +467,8 @@ private:
///
bool full_screen_;
///
+ std::string inserted_label_;
+ ///
Buffer & buffer_;
struct Private;
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 814bf89b59..5121034879 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -3552,12 +3552,16 @@ void LyXAction::init()
/*!
* \var lyx::FuncCode lyx::LFUN_REFERENCE_TO_PARAGRAPH
* \li Action: Inserts a cross-reference to the paragraph with a given ID
- * \li Notion: The function checks of the paragraph already has a label.
+ * or saves the newly created label for insertion into the ref
dialog
+ * \li Notion: The function checks of the paragraph already has a label.\n
* If so, it uses that. Otherwise it inserts a label and uses this.
* \li Syntax: reference-to-paragraph <PAR_ID> [<TYPE>]
* \li Params: <PAR_IDs>: paragraph ids, might be a comma-separated list\n
* if it is in a nested inset\n
- * <TYPE>: cross-references type
+ * <TYPE>: cross-references type or "forrefdialog".\n
+ * The latter stores the label for further processing,\n
+ * all other immendiately insert a ref of the given type\n
+ * (e.g., eqref).
* \li Origin: spitz, 28 Jul 2024
* \endvar
*/
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs