#include <config.h>
-#include <stdlib.h>
+#include <cstdlib>
#ifdef __GNUG__
#pragma implementation
#include "LaTeXFeatures.h"
#include "lyx_gui_misc.h" // CancelCloseBoxCB
-extern BufferView *current_view;
-extern void UpdateInset(Inset* inset, bool mark_dirty = true);
+using std::ostream;
+
InsetUrl::InsetUrl(string const & cmd)
: fd_form_url(0)
}
-InsetUrl::InsetUrl(InsetCommand const &inscmd)
+InsetUrl::InsetUrl(InsetCommand const & inscmd)
: fd_form_url(0)
{
setCmdName(inscmd.getCmdName());
}
-InsetUrl::InsetUrl(string const &ins_name,string const &ins_cont,
- string const &ins_opt)
+InsetUrl::InsetUrl(string const & ins_name, string const & ins_cont,
+ string const & ins_opt)
: fd_form_url(0)
{
setCmdName(ins_name);
}
-void InsetUrl::CloseUrlCB(FL_OBJECT *ob, long)
+void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
{
- InsetUrl *inset = (InsetUrl*) ob->u_vdata;
+ Holder * holder = static_cast<Holder*>(ob->u_vdata);
+
+ InsetUrl * inset = holder->inset;
+ BufferView * bv = holder->view;
+
string url = fl_get_input(inset->fd_form_url->url_name);
string name = fl_get_input(inset->fd_form_url->name_name);
string cmdname;
else
cmdname = "url";
- Buffer *buffer = current_view->currentBuffer();
+ Buffer * buffer = bv->buffer();
if ((url != inset->getContents() ||
name != inset->getOptions() ||
inset->flag = InsetUrl::URL;
else
inset->flag = InsetUrl::HTML_URL;
- UpdateInset(inset);
+ bv->updateInset(inset, true);
}
if (inset->fd_form_url) {
fl_hide_form(inset->fd_form_url->form_url);
+ fl_free_form(inset->fd_form_url->form_url);
inset->fd_form_url = 0;
}
}
-extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT *ob, long)
+
+extern "C"
+void C_InsetUrl_CloseUrlCB(FL_OBJECT * ob, long data)
+{
+ InsetUrl::CloseUrlCB(ob, data);
+}
+
+
+char const * InsetUrl::EditMessage() const
{
- InsetUrl::CloseUrlCB(ob,0);
+ return _("Opened Url");
}
-void InsetUrl::Edit(int, int)
+
+void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
{
static int ow = -1, oh;
- if(current_view->currentBuffer()->isReadonly())
- WarnReadonly();
+ if(bv->buffer()->isReadonly())
+ WarnReadonly(bv->buffer()->fileName());
if (!fd_form_url) {
fd_form_url = create_form_form_url();
- fd_form_url->button_close->u_vdata = this;
- fl_set_form_atclose(fd_form_url->form_url,CancelCloseBoxCB, 0);
+ holder.inset = this;
+ fd_form_url->button_close->u_vdata = &holder;
+ fl_set_form_atclose(fd_form_url->form_url,
+ CancelCloseBoxCB, 0);
}
+ holder.view = bv;
fl_set_input(fd_form_url->url_name, getContents().c_str());
fl_set_input(fd_form_url->name_name, getOptions().c_str());
switch(flag) {
temp += _("HtmlUrl: ");
else
temp += _("Url: ");
- temp += getContents();
if(!getOptions().empty()) {
- temp += "||";
temp += getOptions();
+ } else {
+ temp += getContents();
}
return temp;
}
-int InsetUrl::Latex(FILE *file, signed char fragile)
-{
- string latex_output;
- int res = Latex(latex_output, fragile);
- fprintf(file, "%s", latex_output.c_str());
-
- return res;
-}
-
-
-int InsetUrl::Latex(string &file, signed char fragile)
+int InsetUrl::Latex(Buffer const *, ostream & os,
+ bool fragile, bool /*free_spc*/) const
{
if (!getOptions().empty())
- file += getOptions() + ' ';
+ os << getOptions() + ' ';
if (fragile)
- file += "\\protect";
+ os << "\\protect";
+ os << "\\url{" << getContents() << '}';
+ return 0;
+}
- file += "\\url{" + getContents() + '}';
+int InsetUrl::Ascii(Buffer const *, ostream & os) const
+{
+ if (getOptions().empty())
+ os << "[" << getContents() << "]";
+ else
+ os << "[" << getContents() << "||" << getOptions() << "]";
return 0;
}
-int InsetUrl::Linuxdoc(string &file)
+int InsetUrl::Linuxdoc(Buffer const *, ostream & os) const
{
- file += "<"+ getCmdName() +
- " url=\"" + getContents()+"\"" +
- " name=\"" + getOptions() +"\">";
+ os << "<" << getCmdName()
+ << " url=\"" << getContents() << "\""
+ << " name=\"" << getOptions() << "\">";
return 0;
}
-int InsetUrl::DocBook(string &file)
+int InsetUrl::DocBook(Buffer const *, ostream & os) const
{
- file += "<ulink url=\"" + getContents() + "\">" +
- getOptions() +"</ulink>";
-
+ os << "<ulink url=\"" << getContents() << "\">"
+ << getOptions() << "</ulink>";
return 0;
}
-void InsetUrl::Validate(LaTeXFeatures& features) const
+void InsetUrl::Validate(LaTeXFeatures & features) const
{
features.url = true;
}