#include "LaTeXFeatures.h"
#include "lyx_gui_misc.h" // CancelCloseBoxCB
-extern BufferView * current_view;
-extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
+using std::ostream;
InsetUrl::InsetUrl(string const & cmd)
: fd_form_url(0)
void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
{
- InsetUrl * inset = static_cast<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->buffer();
+ Buffer * buffer = bv->buffer();
if ((url != inset->getContents() ||
name != inset->getOptions() ||
inset->flag = InsetUrl::URL;
else
inset->flag = InsetUrl::HTML_URL;
- UpdateInset(current_view, inset);
+ bv->updateInset(inset, true);
}
if (inset->fd_form_url) {
}
-void InsetUrl::Edit(int, int)
+char const * InsetUrl::EditMessage() const
+{
+ return _("Opened Url");
+}
+
+
+void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
{
static int ow = -1, oh;
- if(current_view->buffer()->isReadonly())
- WarnReadonly(current_view->buffer()->fileName());
+ 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;
+ 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) {
}
-int InsetUrl::Latex(ostream & os, signed char fragile)
-{
- string latex_output;
- int res = Latex(latex_output, fragile);
- os << latex_output;
-
- return res;
-}
-
-
-int InsetUrl::Latex(string & file, signed char fragile)
+int InsetUrl::Latex(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(ostream & os) const
+{
+ if (getOptions().empty())
+ os << "[" << getContents() << "]";
+ else
+ os << "[" << getContents() << "||" << getOptions() << "]";
return 0;
}
-int InsetUrl::Linuxdoc(string & file)
+int InsetUrl::Linuxdoc(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(ostream & os) const
{
- file += "<ulink url=\"" + getContents() + "\">" +
- getOptions() +"</ulink>";
-
+ os << "<ulink url=\"" << getContents() << "\">"
+ << getOptions() << "</ulink>";
return 0;
}