From 69841003a3f37f7935891d2fc5c0c82e9b1a8b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ram=C3=B6ller?= Date: Thu, 10 Sep 2020 12:38:41 -0400 Subject: [PATCH] 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 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index c5d097a37b..92f09630b3 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(); }