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();
47 InsetUrl::priv_dispatch(FuncRequest const & cmd,
48 idx_type & idx, pos_type & pos)
52 InsetCommandMailer("url", *this).showDialog(cmd.view());
55 return InsetCommand::priv_dispatch(cmd, idx, pos);
60 string const InsetUrl::getScreenLabel(Buffer const &) const
63 if (getCmdName() == "url")
66 temp = _("HtmlUrl: ");
70 if (!getOptions().empty())
76 if (url.length() > 30) {
77 url = url.substr(0, 10) + "..."
78 + url.substr(url.length() - 17, url.length());
84 int InsetUrl::latex(Buffer const &, ostream & os,
85 LatexRunParams const & runparams) const
87 if (!getOptions().empty())
88 os << getOptions() + ' ';
89 if (runparams.moving_arg)
91 os << "\\url{" << getContents() << '}';
96 int InsetUrl::ascii(Buffer const &, ostream & os, int) const
98 if (getOptions().empty())
99 os << '[' << getContents() << ']';
101 os << '[' << getContents() << "||" << getOptions() << ']';
106 int InsetUrl::linuxdoc(Buffer const &, ostream & os) const
108 os << '<' << getCmdName()
109 << " url=\"" << getContents() << "\""
110 << " name=\"" << getOptions() << "\">";
116 int InsetUrl::docbook(Buffer const &, ostream & os, bool) const
118 os << "<ulink url=\"" << subst(getContents(),"&","&")
119 << "\">" << getOptions() << "</ulink>";
124 void InsetUrl::validate(LaTeXFeatures & features) const
126 features.require("url");