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 "BufferView.h"
15 #include "LaTeXFeatures.h"
16 #include "frontends/LyXView.h"
18 #include "frontends/Dialogs.h"
19 #include "support/lstrings.h"
25 InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
30 void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state)
32 bv->owner()->getDialogs().showUrl(this);
36 void InsetUrl::edit(BufferView * bv, bool)
38 edit(bv, 0, 0, mouse_button::none);
42 string const InsetUrl::getScreenLabel(Buffer const *) const
45 if (getCmdName() == "url")
48 temp = _("HtmlUrl: ");
52 if (!getOptions().empty())
58 if (url.length() > 30) {
59 url = url.substr(0, 10) + "..."
60 + url.substr(url.length() - 17, url.length());
66 int InsetUrl::latex(Buffer const *, ostream & os,
67 bool fragile, bool /*free_spc*/) const
69 if (!getOptions().empty())
70 os << getOptions() + ' ';
73 os << "\\url{" << getContents() << '}';
78 int InsetUrl::ascii(Buffer const *, ostream & os, int) const
80 if (getOptions().empty())
81 os << '[' << getContents() << ']';
83 os << '[' << getContents() << "||" << getOptions() << ']';
88 int InsetUrl::linuxdoc(Buffer const *, ostream & os) const
90 os << '<' << getCmdName()
91 << " url=\"" << getContents() << "\""
92 << " name=\"" << getOptions() << "\">";
98 int InsetUrl::docbook(Buffer const *, ostream & os, bool) const
100 os << "<ulink url=\"" << subst(getContents(),"&","&")
101 << "\">" << getOptions() << "</ulink>";
106 void InsetUrl::validate(LaTeXFeatures & features) const
108 features.require("url");