]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseturl.C
The markDirty() and fitCursor() changes
[lyx.git] / src / insets / inseturl.C
index a63a7ef4124146fef3f0c4d98d1bc52198498313..0c1c1f17aac7bc9d86c6b4ea156d1c219054ad3b 100644 (file)
@@ -1,48 +1,77 @@
+/**
+ * \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
+ */
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "inseturl.h"
 #include "BufferView.h"
 #include "LaTeXFeatures.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
 #include "debug.h"
 #include "frontends/Dialogs.h"
+#include "support/lstrings.h"
+#include "gettext.h"
 
 using std::ostream;
 
 
-InsetUrl::InsetUrl(InsetCommandParams const & p)
+InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
                : InsetCommand(p)
 {}
 
 
-void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
+InsetUrl::~InsetUrl()
 {
-       bv->owner()->getDialogs()->showUrl( this );
+       InsetCommandMailer mailer("url", *this);
+       mailer.hideDialog();
 }
 
 
-string InsetUrl::getScreenLabel() const
+void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state)
+{
+       InsetCommandMailer mailer("url", *this);
+       mailer.showDialog(bv);
+}
+
+
+void InsetUrl::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, mouse_button::none);
+}
+
+
+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,
+int InsetUrl::latex(Buffer const *, ostream & os,
                    bool fragile, bool /*free_spc*/) const
 {
        if (!getOptions().empty())
@@ -54,19 +83,19 @@ int InsetUrl::Latex(Buffer const *, ostream & os,
 }
 
 
-int InsetUrl::Ascii(Buffer const *, ostream & os) const
+int InsetUrl::ascii(Buffer const *, ostream & os, int) 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) const
 {
-       os << "<" << getCmdName()
+       os << '<' << getCmdName()
           << " url=\""  << getContents() << "\""
           << " name=\"" << getOptions() << "\">";
 
@@ -74,15 +103,15 @@ int InsetUrl::Linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetUrl::DocBook(Buffer const *, ostream & os) const
+int InsetUrl::docbook(Buffer const *, ostream & os, bool) const
 {
-       os << "<ulink url=\"" << getContents() << "\">"
-          << getOptions() << "</ulink>";
+       os << "<ulink url=\"" << subst(getContents(),"&","&amp;")
+          << "\">" << getOptions() << "</ulink>";
        return 0;
 }
 
 
-void InsetUrl::Validate(LaTeXFeatures & features) const
+void InsetUrl::validate(LaTeXFeatures & features) const
 {
-       features.url = true;
+       features.require("url");
 }