InsetHyperlink::InsetHyperlink(Buffer * buf, InsetCommandParams const & p)
- : InsetCommand(buf, p, "href")
+ : InsetCommand(buf, p)
{}
{
switch (cmd.action()) {
case LFUN_INSET_EDIT:
- flag.setEnabled(getParam("type") == "file:");
+ flag.setEnabled(getParam("type").empty() || getParam("type") == "file:");
return true;
default:
void InsetHyperlink::viewTarget() const
{
- // FIXME implement viewer for web url
- if (getParam("type") != "file:")
- return;
- FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath());
- string format = formats.getFormatFromFile(url);
- formats.view(buffer(), url, format);
+ if (getParam("type") == "file:") {
+ FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath());
+ string const format = formats.getFormatFromFile(url);
+ formats.view(buffer(), url, format);
+ }
}
-int InsetHyperlink::latex(odocstream & os,
- OutputParams const & runparams) const
+void InsetHyperlink::latex(otexstream & os,
+ OutputParams const & runparams) const
{
docstring url = getParam("target");
docstring name = getParam("name");
// output the ready \href command
os << "\\href{" << getParam("type") << url << "}{" << name << '}';
-
- return 0;
}
docstring InsetHyperlink::xhtml(XHTMLStream & xs, OutputParams const &) const
{
- docstring const & target = getParam("target");
+ docstring const & target =
+ html::htmlize(getParam("target"), XHTMLStream::ESCAPE_AND);
docstring const & name = getParam("name");
xs << html::StartTag("a", to_utf8("href=\"" + target + "\""));
xs << (name.empty() ? target : name);
}
-void InsetHyperlink::tocString(odocstream & os) const
+void InsetHyperlink::toString(odocstream & os) const
{
plaintext(os, OutputParams(0));
}
+void InsetHyperlink::forToc(docstring & os, size_t) const
+{
+ docstring const & n = getParam("name");
+ if (!n.empty()) {
+ os += n;
+ return;
+ }
+ os += getParam("target");
+}
+
+
docstring InsetHyperlink::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const
{
docstring url = getParam("target");
}
-docstring InsetHyperlink::contextMenu(BufferView const &, int, int) const
+string InsetHyperlink::contextMenuName() const
{
- return from_ascii("context-hyperlink");
+ return "context-hyperlink";
}