X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finseturl.C;h=ae2c16a9fe1028ce8dfef62db6b4a6dfe2470875;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=c6904e8477bb1238a9d1f71d4e882ddb3c425135;hpb=9ce32d63e5ff1dbf4c04e3d8263b2649ef3ac595;p=lyx.git diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index c6904e8477..ae2c16a9fe 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -14,8 +14,7 @@ #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) @@ -67,7 +66,11 @@ InsetUrl::~InsetUrl() void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long) { - InsetUrl * inset = static_cast(ob->u_vdata); + Holder * holder = static_cast(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; @@ -76,7 +79,7 @@ void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long) else cmdname = "url"; - Buffer * buffer = current_view->buffer(); + Buffer * buffer = bv->buffer(); if ((url != inset->getContents() || name != inset->getOptions() || @@ -90,7 +93,7 @@ void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long) inset->flag = InsetUrl::URL; else inset->flag = InsetUrl::HTML_URL; - UpdateInset(current_view, inset); + bv->updateInset(inset, true); } if (inset->fd_form_url) { @@ -107,19 +110,27 @@ extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT * ob, long data) } -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) { @@ -162,44 +173,42 @@ string InsetUrl::getScreenLabel() const } -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 += "" + - getOptions() +""; - + os << "" + << getOptions() << ""; return 0; }