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"
23 using lyx::support::subst;
29 InsetUrl::InsetUrl(InsetCommandParams const & p)
34 // InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
35 // : InsetCommand(p, false)
41 InsetCommandMailer("url", *this).hideDialog();
45 dispatch_result InsetUrl::localDispatch(FuncRequest const & cmd)
49 InsetCommandMailer("url", *this).showDialog(cmd.view());
52 return InsetCommand::localDispatch(cmd);
57 string const InsetUrl::getScreenLabel(Buffer const &) const
60 if (getCmdName() == "url")
63 temp = _("HtmlUrl: ");
67 if (!getOptions().empty())
73 if (url.length() > 30) {
74 url = url.substr(0, 10) + "..."
75 + url.substr(url.length() - 17, url.length());
81 int InsetUrl::latex(Buffer const &, ostream & os,
82 LatexRunParams const & runparams) const
84 if (!getOptions().empty())
85 os << getOptions() + ' ';
86 if (runparams.moving_arg)
88 os << "\\url{" << getContents() << '}';
93 int InsetUrl::ascii(Buffer const &, ostream & os, int) const
95 if (getOptions().empty())
96 os << '[' << getContents() << ']';
98 os << '[' << getContents() << "||" << getOptions() << ']';
103 int InsetUrl::linuxdoc(Buffer const &, ostream & os) const
105 os << '<' << getCmdName()
106 << " url=\"" << getContents() << "\""
107 << " name=\"" << getOptions() << "\">";
113 int InsetUrl::docbook(Buffer const &, ostream & os, bool) const
115 os << "<ulink url=\"" << subst(getContents(),"&","&")
116 << "\">" << getOptions() << "</ulink>";
121 void InsetUrl::validate(LaTeXFeatures & features) const
123 features.require("url");