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
14 #include "funcrequest.h"
15 #include "BufferView.h"
16 #include "LaTeXFeatures.h"
17 #include "frontends/LyXView.h"
19 #include "frontends/Dialogs.h"
20 #include "support/lstrings.h"
26 InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
33 InsetCommandMailer("url", *this).hideDialog();
37 dispatch_result InsetUrl::localDispatch(FuncRequest const & cmd)
41 InsetCommandMailer("url", *this).showDialog(cmd.view());
44 return InsetCommand::localDispatch(cmd);
49 string const InsetUrl::getScreenLabel(Buffer const *) const
52 if (getCmdName() == "url")
55 temp = _("HtmlUrl: ");
59 if (!getOptions().empty())
65 if (url.length() > 30) {
66 url = url.substr(0, 10) + "..."
67 + url.substr(url.length() - 17, url.length());
73 int InsetUrl::latex(Buffer const *, ostream & os,
74 bool fragile, bool /*free_spc*/) const
76 if (!getOptions().empty())
77 os << getOptions() + ' ';
80 os << "\\url{" << getContents() << '}';
85 int InsetUrl::ascii(Buffer const *, ostream & os, int) const
87 if (getOptions().empty())
88 os << '[' << getContents() << ']';
90 os << '[' << getContents() << "||" << getOptions() << ']';
95 int InsetUrl::linuxdoc(Buffer const *, ostream & os) const
97 os << '<' << getCmdName()
98 << " url=\"" << getContents() << "\""
99 << " name=\"" << getOptions() << "\">";
105 int InsetUrl::docbook(Buffer const *, ostream & os, bool) const
107 os << "<ulink url=\"" << subst(getContents(),"&","&")
108 << "\">" << getOptions() << "</ulink>";
113 void InsetUrl::validate(LaTeXFeatures & features) const
115 features.require("url");