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
13 #pragma implementation
17 #include "BufferView.h"
18 #include "LaTeXFeatures.h"
19 #include "frontends/LyXView.h"
21 #include "frontends/Dialogs.h"
22 #include "support/lstrings.h"
28 InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
33 void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state)
35 bv->owner()->getDialogs().showUrl(this);
39 void InsetUrl::edit(BufferView * bv, bool)
41 edit(bv, 0, 0, mouse_button::none);
45 string const InsetUrl::getScreenLabel(Buffer const *) const
48 if (getCmdName() == "url")
51 temp = _("HtmlUrl: ");
55 if (!getOptions().empty())
61 if (url.length() > 30) {
62 url = url.substr(0, 10) + "..."
63 + url.substr(url.length() - 17, url.length());
69 int InsetUrl::latex(Buffer const *, ostream & os,
70 bool fragile, bool /*free_spc*/) const
72 if (!getOptions().empty())
73 os << getOptions() + ' ';
76 os << "\\url{" << getContents() << '}';
81 int InsetUrl::ascii(Buffer const *, ostream & os, int) const
83 if (getOptions().empty())
84 os << '[' << getContents() << ']';
86 os << '[' << getContents() << "||" << getOptions() << ']';
91 int InsetUrl::linuxdoc(Buffer const *, ostream & os) const
93 os << '<' << getCmdName()
94 << " url=\"" << getContents() << "\""
95 << " name=\"" << getOptions() << "\">";
101 int InsetUrl::docbook(Buffer const *, ostream & os, bool) const
103 os << "<ulink url=\"" << subst(getContents(),"&","&")
104 << "\">" << getOptions() << "</ulink>";
109 void InsetUrl::validate(LaTeXFeatures & features) const
111 features.require("url");