End
+#
+# InsetMathRef context menu
+#
+ Menu "context-mathref"
+ Item "Next Cross-Reference|N" "reference-next"
+ Item "Go to Label|G" "label-goto"
+ Separator
+ Item "<Reference>|R" "inset-modify changetype ref"
+ Item "(<Reference>)|e" "inset-modify changetype eqref"
+ Item "<Page>|P" "inset-modify changetype pageref"
+ Item "On Page <Page>|O" "inset-modify changetype vpageref"
+ Item "<Reference> on Page <Page>|f" "inset-modify changetype vref"
+ Item "Formatted Reference|t" "inset-modify changetype formatted"
+ Item "Textual Reference|x" "inset-modify changetype nameref"
+ Item "Label Only|L" "inset-modify changetype labelonly"
+ Separator
+ Item "Settings...|S" "inset-settings"
+ End
+
+
#
# InsetRef context menu
#
#include "insets/InsetText.h"
#include "mathed/InsetMathNest.h"
+#include "mathed/InsetMathRef.h"
#include "mathed/MathData.h"
#include "mathed/MathRow.h"
case LFUN_LABEL_GOTO:
flag.setEnabled(!cmd.argument().empty()
- || getInsetByCode<InsetRef>(cur, REF_CODE));
+ || getInsetByCode<InsetRef>(cur, REF_CODE)
+ || getInsetByCode<InsetMathRef>(cur, MATH_REF_CODE));
break;
case LFUN_CHANGES_MERGE:
// eventually call LFUN_PARAGRAPH_GOTO, but it seems best
// to have it here.
dr.screenUpdate(Update::Force | Update::FitCursor);
+ } else {
+ InsetMathRef * minset =
+ getInsetByCode<InsetMathRef>(cur, MATH_REF_CODE);
+ if (minset)
+ lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO,
+ minset->getTarget()));
}
break;
}
void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
{
+ // Ctrl + click: go to label
+ if (cmd.action() == LFUN_MOUSE_RELEASE && cmd.modifier() == ControlModifier) {
+ LYXERR0("trying to goto ref '" << to_utf8(asString(cell(0))) << "'");
+ //FIXME: use DispatchResult argument
+ lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, asString(cell(0))));
+ return;
+ }
+
switch (cmd.action()) {
- case LFUN_INSET_MODIFY:
- if (cmd.getArg(0) == "ref") {
- if (cmd.getArg(1) == "changetarget") {
+ case LFUN_INSET_MODIFY: {
+ string const arg0 = cmd.getArg(0);
+ string const arg1 = cmd.getArg(1);
+ if (arg0 == "ref") {
+ if (arg1 == "changetarget") {
string const oldtarget = cmd.getArg(2);
string const newtarget = cmd.getArg(3);
if (!oldtarget.empty() && !newtarget.empty()
setBuffer(buf);
break;
}
+ } else if (arg0 == "changetype") {
+ docstring const data = from_ascii(createDialogStr(arg1));
+ MathData ar;
+ if (createInsetMath_fromDialogStr(data, ar)) {
+ cur.recordUndo();
+ Buffer & buf = buffer();
+ *this = *ar[0].nucleus()->asRefInset();
+ setBuffer(buf);
+ break;
+ }
}
cur.undispatched();
break;
+ }
case LFUN_INSET_DIALOG_UPDATE: {
string const data = createDialogStr();
break;
}
+ case LFUN_INSET_SETTINGS: {
+ string const data = createDialogStr();
+ cur.bv().showDialog("ref", data, this);
+ cur.dispatched();
+ break;
+ }
+
case LFUN_MOUSE_RELEASE:
if (cur.selection()) {
cur.undispatched();
break;
}
- if (cmd.button() == mouse_button::button3) {
- LYXERR0("trying to goto ref '" << to_utf8(asString(cell(0))) << "'");
- //FIXME: use DispatchResult argument
- lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, asString(cell(0))));
- break;
- }
if (cmd.button() == mouse_button::button1) {
- // Eventually trigger dialog with button 3, not 1
string const data = createDialogStr();
cur.bv().showDialog("ref", data, this);
break;
// we handle these
case LFUN_INSET_MODIFY:
case LFUN_INSET_DIALOG_UPDATE:
+ case LFUN_INSET_SETTINGS:
case LFUN_MOUSE_RELEASE:
case LFUN_MOUSE_PRESS:
case LFUN_MOUSE_DOUBLE:
}
-string const InsetMathRef::createDialogStr() const
+string const InsetMathRef::createDialogStr(string const & type) const
{
- InsetCommandParams icp(REF_CODE, to_ascii(commandname()));
+ InsetCommandParams icp(REF_CODE, (type.empty()
+ ? to_ascii(commandname()) : type));
icp["reference"] = asString(cell(0));
if (!cell(1).empty())
icp["name"] = asString(cell(1));
///
bool clickable(BufferView const &, int, int) const override { return true; }
///
- std::string contextMenuName() const override { return "context-ref"; }
+ std::string contextMenuName() const override { return "context-mathref"; }
///
mode_type currentMode() const override { return TEXT_MODE; }
///
/// docbook output
void docbook(XMLStream &, OutputParams const &) const override;
/// generate something that will be understood by the Dialogs.
- std::string const createDialogStr() const;
+ std::string const createDialogStr(std::string const & type = std::string()) const;
struct ref_type_info {
///