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 #include "support/std_ostream.h"
24 using lyx::support::subst;
30 InsetUrl::InsetUrl(InsetCommandParams const & p)
35 // InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
36 // : InsetCommand(p, false)
42 InsetCommandMailer("url", *this).hideDialog();
46 dispatch_result InsetUrl::localDispatch(FuncRequest const & cmd)
50 InsetCommandMailer("url", *this).showDialog(cmd.view());
53 return InsetCommand::localDispatch(cmd);
58 string const InsetUrl::getScreenLabel(Buffer const &) const
61 if (getCmdName() == "url")
64 temp = _("HtmlUrl: ");
68 if (!getOptions().empty())
74 if (url.length() > 30) {
75 url = url.substr(0, 10) + "..."
76 + url.substr(url.length() - 17, url.length());
82 int InsetUrl::latex(Buffer const &, ostream & os,
83 LatexRunParams const & runparams) const
85 if (!getOptions().empty())
86 os << getOptions() + ' ';
87 if (runparams.moving_arg)
89 os << "\\url{" << getContents() << '}';
94 int InsetUrl::ascii(Buffer const &, ostream & os, int) const
96 if (getOptions().empty())
97 os << '[' << getContents() << ']';
99 os << '[' << getContents() << "||" << getOptions() << ']';
104 int InsetUrl::linuxdoc(Buffer const &, ostream & os) const
106 os << '<' << getCmdName()
107 << " url=\"" << getContents() << "\""
108 << " name=\"" << getOptions() << "\">";
114 int InsetUrl::docbook(Buffer const &, ostream & os, bool) const
116 os << "<ulink url=\"" << subst(getContents(),"&","&")
117 << "\">" << getOptions() << "</ulink>";
122 void InsetUrl::validate(LaTeXFeatures & features) const
124 features.require("url");