]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseturl.C
The speed patch: redraw only rows that have changed
[lyx.git] / src / insets / inseturl.C
index 161fe59fa9ca3ef5bec001c92026a10ad77d808b..4802f14eedd1f979fe2031c3df6ad4663f6603f9 100644 (file)
@@ -1,72 +1,89 @@
-#include <config.h>
+/**
+ * \file inseturl.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author José Matos
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
 #include "inseturl.h"
-#include "BufferView.h"
+
+#include "dispatchresult.h"
+#include "funcrequest.h"
 #include "LaTeXFeatures.h"
-#include "LyXView.h"
-#include "debug.h"
-#include "frontends/Dialogs.h"
+#include "gettext.h"
+#include "outputparams.h"
+
+#include "support/lstrings.h"
+
+#include "support/std_ostream.h"
 
+using lyx::support::subst;
+
+using std::string;
 using std::ostream;
 
 
 InsetUrl::InsetUrl(InsetCommandParams const & p)
-               : InsetCommand(p)
+       : InsetCommand(p, "url")
 {}
 
 
-void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
-{
-       bv->owner()->getDialogs()->showUrl( this );
-}
-
-
-string const InsetUrl::getScreenLabel() const
+string const InsetUrl::getScreenLabel(Buffer const &) const
 {
        string temp;
-       if( getCmdName() == "url" )
+       if (getCmdName() == "url")
                temp = _("Url: ");
-       else 
+       else
                temp = _("HtmlUrl: ");
 
-       if(!getOptions().empty())
-               temp += getOptions();
-       else
-               temp += getContents();
+       string url;
 
-       return temp;
+       if (!getOptions().empty())
+               url += getOptions();
+       else
+               url += getContents();
+
+       // elide if long
+       if (url.length() > 30) {
+               url = url.substr(0, 10) + "..."
+                       + url.substr(url.length() - 17, url.length());
+       }
+       return temp + url;
 }
 
 
-int InsetUrl::Latex(Buffer const *, ostream & os,
-                   bool fragile, bool /*free_spc*/) const
+int InsetUrl::latex(Buffer const &, ostream & os,
+                   OutputParams const & runparams) const
 {
        if (!getOptions().empty())
                os << getOptions() + ' ';
-       if (fragile)
+       if (runparams.moving_arg)
                os << "\\protect";
        os << "\\url{" << getContents() << '}';
        return 0;
 }
 
 
-int InsetUrl::Ascii(Buffer const *, ostream & os) const
+int InsetUrl::plaintext(Buffer const &, ostream & os,
+                   OutputParams const &) const
 {
        if (getOptions().empty())
-               os << "[" << getContents() << "]";
+               os << '[' << getContents() << ']';
        else
-               os << "[" << getContents() << "||" <<  getOptions() << "]";
+               os << '[' << getContents() << "||" <<  getOptions() << ']';
        return 0;
 }
 
 
-int InsetUrl::Linuxdoc(Buffer const *, ostream & os) const
+int InsetUrl::linuxdoc(Buffer const &, ostream & os,
+                      OutputParams const &) const
 {
-       os << "<" << getCmdName()
+       os << '<' << getCmdName()
           << " url=\""  << getContents() << "\""
           << " name=\"" << getOptions() << "\">";
 
@@ -74,15 +91,23 @@ int InsetUrl::Linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetUrl::DocBook(Buffer const *, ostream & os) const
+int InsetUrl::docbook(Buffer const &, ostream & os,
+                     OutputParams const &) const
 {
-       os << "<ulink url=\"" << getContents() << "\">"
-          << getOptions() << "</ulink>";
+       os << "<ulink url=\"" << subst(getContents(),"&","&amp;")
+          << "\">" << getOptions() << "</ulink>";
        return 0;
 }
 
 
-void InsetUrl::Validate(LaTeXFeatures & features) const
+int InsetUrl::textString(Buffer const & buf, ostream & os,
+                      OutputParams const & op) const
+{
+       return plaintext(buf, os, op);
+}
+
+
+void InsetUrl::validate(LaTeXFeatures & features) const
 {
-       features.url = true;
+       features.require("url");
 }