X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetRef.cpp;h=9a3209f894df83ef646da71ef7e0ddb2d8029fbe;hb=c3a8b3a566e9e90f9ade72acbc723232d721d0b1;hp=515842e04e4a608dcea90b517d873be3671000a2;hpb=42123ab8a71080b6d15fca4e0c43ae76abf00a1e;p=lyx.git diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 515842e04e..9a3209f894 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -15,22 +15,20 @@ #include "Cursor.h" #include "DispatchResult.h" #include "FuncRequest.h" -#include "gettext.h" +#include "support/gettext.h" #include "LaTeXFeatures.h" #include "LyXFunc.h" #include "OutputParams.h" #include "sgml.h" +#include "support/docstream.h" #include "support/lstrings.h" +using namespace std; +using namespace lyx::support; namespace lyx { -using support::escape; - -using std::string; -using std::ostream; - InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf) : InsetCommand(p, "ref"), isLatex(buf.isLatex()) @@ -42,24 +40,41 @@ InsetRef::InsetRef(InsetRef const & ir) {} +bool InsetRef::isCompatibleCommand(string const & s) { + //FIXME This is likely not the best way to handle this. + //But this stuff is hardcoded elsewhere already. + return s == "ref" + || s == "pageref" + || s == "vref" + || s == "vpageref" + || s == "prettyref" + || s == "eqref"; +} + + +CommandInfo const * InsetRef::findInfo(string const & /* cmdName */) +{ + static const char * const paramnames[] = {"name", "reference", ""}; + static const bool isoptional[] = {true, false}; + static const CommandInfo info = {2, paramnames, isoptional}; + return &info; +} + + void InsetRef::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action) { - case LFUN_MOUSE_PRESS: + case LFUN_MOUSE_RELEASE: // Eventually trigger dialog with button 3 not 1 if (cmd.button() == mouse_button::button3) - lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getParam("reference"))); - else { - InsetCommandMailer("ref", *this).showDialog(&cur.bv()); - cur.undispatched(); - } - return; - - case LFUN_MOUSE_RELEASE: - return; + lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, + getParam("reference"))); + else + InsetCommand::doDispatch(cur, cmd); + break; default: - return InsetCommand::doDispatch(cur, cmd); + InsetCommand::doDispatch(cur, cmd); } } @@ -84,10 +99,11 @@ docstring const InsetRef::getScreenLabel(Buffer const &) const int InsetRef::latex(Buffer const &, odocstream & os, - OutputParams const &) const + OutputParams const &) const { - // Don't output p_["name"], this is only used in docbook - InsetCommandParams p(getCmdName()); + // We don't want to output p_["name"], since that is only used + // in docbook. So we construct new params, without it, and use that. + InsetCommandParams p(REF_CODE, getCmdName()); p["reference"] = getParam("reference"); os << escape(p.getCommand()); return 0; @@ -95,7 +111,7 @@ int InsetRef::latex(Buffer const &, odocstream & os, int InsetRef::plaintext(Buffer const &, odocstream & os, - OutputParams const &) const + OutputParams const &) const { docstring const str = getParam("reference"); os << '[' << str << ']'; @@ -104,23 +120,23 @@ int InsetRef::plaintext(Buffer const &, odocstream & os, int InsetRef::docbook(Buffer const & buf, odocstream & os, - OutputParams const & runparams) const + OutputParams const & runparams) const { docstring const & name = getParam("name"); if (name.empty()) { if (runparams.flavor == OutputParams::XML) { - os << ""; } else { - os << ""; } } else { - os << "" + << "\">" << getParam("name") << ""; } @@ -129,10 +145,9 @@ int InsetRef::docbook(Buffer const & buf, odocstream & os, } -int InsetRef::textString(Buffer const & buf, odocstream & os, - OutputParams const & op) const +void InsetRef::textString(Buffer const & buf, odocstream & os) const { - return plaintext(buf, os, op); + plaintext(buf, os, OutputParams(0)); }