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 "funcrequest.h"
16 #include "latexrunparams.h"
17 #include "LaTeXFeatures.h"
20 #include "support/lstrings.h"
22 using lyx::support::subst;
27 InsetUrl::InsetUrl(InsetCommandParams const & p)
32 // InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
33 // : InsetCommand(p, false)
39 InsetCommandMailer("url", *this).hideDialog();
43 dispatch_result InsetUrl::localDispatch(FuncRequest const & cmd)
47 InsetCommandMailer("url", *this).showDialog(cmd.view());
50 return InsetCommand::localDispatch(cmd);
55 string const InsetUrl::getScreenLabel(Buffer const &) const
58 if (getCmdName() == "url")
61 temp = _("HtmlUrl: ");
65 if (!getOptions().empty())
71 if (url.length() > 30) {
72 url = url.substr(0, 10) + "..."
73 + url.substr(url.length() - 17, url.length());
79 int InsetUrl::latex(Buffer const &, ostream & os,
80 LatexRunParams const & runparams) const
82 if (!getOptions().empty())
83 os << getOptions() + ' ';
84 if (runparams.moving_arg)
86 os << "\\url{" << getContents() << '}';
91 int InsetUrl::ascii(Buffer const &, ostream & os, int) const
93 if (getOptions().empty())
94 os << '[' << getContents() << ']';
96 os << '[' << getContents() << "||" << getOptions() << ']';
101 int InsetUrl::linuxdoc(Buffer const &, ostream & os) const
103 os << '<' << getCmdName()
104 << " url=\"" << getContents() << "\""
105 << " name=\"" << getOptions() << "\">";
111 int InsetUrl::docbook(Buffer const &, ostream & os, bool) const
113 os << "<ulink url=\"" << subst(getContents(),"&","&")
114 << "\">" << getOptions() << "</ulink>";
119 void InsetUrl::validate(LaTeXFeatures & features) const
121 features.require("url");