[LyX/master] Let Ctrl-Click on a reference jump to the corresponding label.
Richard Kimberly Heck
rikiheck at lyx.org
Thu Sep 10 16:12:56 UTC 2020
commit 69841003a3f37f7935891d2fc5c0c82e9b1a8b42
Author: Daniel Ramöller <d.lyx at web.de>
Date: Thu Sep 10 12:38:41 2020 -0400
Let Ctrl-Click on a reference jump to the corresponding label.
Fix some warnings while we're at it. (That part by RKH.)
---
src/insets/InsetRef.cpp | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index c5d097a..92f0963 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -124,6 +124,14 @@ void InsetRef::doDispatch(Cursor & cur, FuncRequest & cmd)
return;
}
}
+
+ // Ctrl + click: go to label
+ if (cmd.action() == LFUN_MOUSE_RELEASE && cmd.modifier() == ControlModifier) {
+ lyx::dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
+ lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getParam("reference")));
+ return;
+ }
+
// otherwise not for us
if (pstring.empty())
return InsetCommand::doDispatch(cur, cmd);
@@ -220,8 +228,8 @@ docstring InsetRef::getFormattedCmd(docstring const & ref,
}
// make sure the prefix is legal for a latex command
- int const len = prefix.size();
- for (int i = 0; i < len; i++) {
+ size_t const len = prefix.size();
+ for (size_t i = 0; i < len; i++) {
char_type const c = prefix[i];
if (!isAlphaASCII(c)) {
LYXERR0("Prefix `" << prefix << "' is invalid for LaTeX.");
@@ -303,7 +311,7 @@ int InsetRef::plaintext(odocstringstream & os,
{
docstring const str = getParam("reference");
os << '[' << str << ']';
- return 2 + str.size();
+ return 2 + int(str.size());
}
@@ -415,7 +423,7 @@ docstring InsetRef::xhtml(XMLStream & xs, OutputParams const & op) const
void InsetRef::toString(odocstream & os) const
{
odocstringstream ods;
- plaintext(ods, OutputParams(0));
+ plaintext(ods, OutputParams(nullptr));
os << ods.str();
}
More information about the lyx-cvs
mailing list