3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
15 #include "dispatchresult.h"
16 #include "funcrequest.h"
17 #include "LaTeXFeatures.h"
19 #include "outputparams.h"
21 #include "support/lstrings.h"
23 #include "support/std_ostream.h"
25 using lyx::support::subst;
31 InsetUrl::InsetUrl(InsetCommandParams const & p)
36 // InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
37 // : InsetCommand(p, false)
43 InsetCommandMailer("url", *this).hideDialog();
48 InsetUrl::priv_dispatch(FuncRequest const & cmd,
49 idx_type & idx, pos_type & pos)
52 case LFUN_MOUSE_PRESS:
53 InsetCommandMailer("url", *this).showDialog(cmd.view());
54 return DispatchResult(true, true);
56 return InsetCommand::priv_dispatch(cmd, idx, pos);
61 string const InsetUrl::getScreenLabel(Buffer const &) const
64 if (getCmdName() == "url")
67 temp = _("HtmlUrl: ");
71 if (!getOptions().empty())
77 if (url.length() > 30) {
78 url = url.substr(0, 10) + "..."
79 + url.substr(url.length() - 17, url.length());
85 int InsetUrl::latex(Buffer const &, ostream & os,
86 OutputParams const & runparams) const
88 if (!getOptions().empty())
89 os << getOptions() + ' ';
90 if (runparams.moving_arg)
92 os << "\\url{" << getContents() << '}';
97 int InsetUrl::plaintext(Buffer const &, ostream & os,
98 OutputParams const &) const
100 if (getOptions().empty())
101 os << '[' << getContents() << ']';
103 os << '[' << getContents() << "||" << getOptions() << ']';
108 int InsetUrl::linuxdoc(Buffer const &, ostream & os,
109 OutputParams const &) const
111 os << '<' << getCmdName()
112 << " url=\"" << getContents() << "\""
113 << " name=\"" << getOptions() << "\">";
119 int InsetUrl::docbook(Buffer const &, ostream & os,
120 OutputParams const &) const
122 os << "<ulink url=\"" << subst(getContents(),"&","&")
123 << "\">" << getOptions() << "</ulink>";
128 void InsetUrl::validate(LaTeXFeatures & features) const
130 features.require("url");