patch from Angus and patch from Kayvan

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@930 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-07-27 08:55:59 +00:00
parent bc6d7e361b
commit 338bca184c
28 changed files with 618 additions and 576 deletions

View File

@ -1,3 +1,45 @@
2000-07-26 Kayvan A. Sylvan <kayvan@sylvan.com>
* development/lyx.spec.in
* Makefile.am: Fix buglet for LyX RPM generation resulting from
file/directory re-organization.
2000-07-26 Angus Leeming <a.leeming@ic.ac.uk>
* src/insets/insetcommand.[Ch]: moved the string data and
associated manipulation methods into a new stand-alone class
InsetCommandParams. This class has two additional methods
getAsString() and setFromString() allowing the contents to be
moved around as a single string.
(addContents) method removed.
(setContents) method no longer virtual.
* src/buffer.C (readInset): made use of new InsetCitation,
InsetUrl constructors based on InsetCommandParams.
* src/commandtags.h: add LFUN_INSERT_URL
* src/lyxfunc.C (Dispatch): changed to accomadate GUI-
independent InsetUrl and use InsetCommandParams to extract
string info and create new Insets.
* src/frontends/Dialogs.h: add signals showUrl, createUrl.
* src/frontends/xforms/FormCitation.C (apply): uses
InsetCommandParams.
* src/frontends/xforms/form_url.C
* src/frontends/xforms/form_url.h
* src/frontends/xforms/FormUrl.h
* src/frontends/xforms/FormUrl.C
* src/frontends/xforms/forms/form_url.fd: new files
* src/insets/insetcite.[Ch]: removed unused constructors.
* src/insets/insetinclude.[Ch]: no longer store filename
* src/insets/inseturl.[Ch]: GUI-independent.
2000-07-26 Juergen Vigna <jug@sad.it> 2000-07-26 Juergen Vigna <jug@sad.it>
* renamed frontend from gtk to gnome as it is that what is realized * renamed frontend from gtk to gnome as it is that what is realized
and did the necessary changes in the files. and did the necessary changes in the files.

View File

@ -25,7 +25,7 @@ dist-hook:
rm -rf `find images -name \*CVS\*` rm -rf `find images -name \*CVS\*`
rpmdist: dist rpmdist: dist
ln -s images/lyx.xpm . ; \ ln -s lib/images/lyx.xpm . ; \
rpm -ta ${PACKAGE}-${VERSION}.tar.gz ; \ rpm -ta ${PACKAGE}-${VERSION}.tar.gz ; \
rm lyx.xpm rm lyx.xpm

View File

@ -38,8 +38,17 @@ place that the Redhat tetex package is installed and would see it.
%build %build
unset LINGUAS || true unset LINGUAS || true
CXXFLAGS="$RPM_OPT_FLAGS" CFLAGS="$RPM_OPT_FLAGS" \ CXXFLAGS="$RPM_OPT_FLAGS" CFLAGS="$RPM_OPT_FLAGS" \
./configure --prefix=/usr --without-warnings ./configure --prefix=/usr --without-warnings --with-included-string
make # The following check is to ensure that lyx RPMs generated on RH 6.X machines
# with gcc-2.95 still run against older Redhat OS/compiler combinations.
# It will eventually be ripped out.
if [ -r /usr/lib/libstdc++-libc6.1-1.so.2 ]
then
make CXX=gcc LYX_LIBS='/usr/lib/libstdc++-libc6.1-1.so.2 -lforms -lXpm'
else
make
fi
%install %install
unset LINGUAS || true unset LINGUAS || true
@ -59,7 +68,7 @@ cp -r ${RPM_BUILD_ROOT}/usr/share/lyx/tex \
# #
# Miscellaneous files # Miscellaneous files
# #
cp -a images/lyx.xpm ${RPM_BUILD_ROOT}/usr/share/lyx/images/ cp -a lib/images/lyx.xpm ${RPM_BUILD_ROOT}/usr/share/lyx/images/
cp lib/reLyX/README README.reLyX cp lib/reLyX/README README.reLyX
%clean %clean

View File

@ -1,250 +0,0 @@
Magic: 13000
Internal Form Definition File
(do not change)
Number of forms: 1
Unit of measure: FL_COORD_PIXEL
=============== FORM ===============
Name: citation_form
Width: 440
Height: 790
Number of Objects: 13
--------------------
class: FL_BOX
type: UP_BOX
box: 0 0 440 790
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: box
callback:
argument:
--------------------
class: FL_BROWSER
type: HOLD_BROWSER
box: 20 40 170 370
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Inset keys
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: citeBrsr
callback: citation_cb
argument: InsetCitation::CITEBRSR
--------------------
class: FL_BROWSER
type: HOLD_BROWSER
box: 250 40 170 370
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Bibliography keys
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 40 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @4->
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 40 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 90 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @9+
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 90 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 140 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @8->
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 140 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 190 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @2->
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 190 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BROWSER
type: NORMAL_BROWSER
box: 20 440 400 110
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Info
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: infoBrsr
callback:
argument:
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 160 570 130 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Citation style
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: style
callback:
argument:
==============================
--------------------

View File

@ -34,13 +34,9 @@ src/frontends/xforms/FormPreferences.C
src/frontends/xforms/form_preferences.C src/frontends/xforms/form_preferences.C
src/frontends/xforms/FormPrint.C src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_print.C src/frontends/xforms/form_print.C
src/frontends/xforms/forms/form_citation.C
src/frontends/xforms/forms/form_copyright.C
src/frontends/xforms/forms/form_preferences.C
src/frontends/xforms/forms/form_print.C
src/frontends/xforms/forms/form_tabular.C
src/frontends/xforms/FormTabular.C src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular.C src/frontends/xforms/form_tabular.C
src/frontends/xforms/FormUrl.C
src/frontends/xforms/Menubar_pimpl.C src/frontends/xforms/Menubar_pimpl.C
src/gettext.h src/gettext.h
src/insets/figinset.C src/insets/figinset.C

View File

@ -957,7 +957,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
inscmd.Read(this, lex); inscmd.Read(this, lex);
Inset * inset = 0; Inset * inset = 0;
if (inscmd.getCmdName() == "cite") { if (inscmd.getCmdName() == "cite") {
inset = new InsetCitation(inscmd.getContents(), inscmd.getOptions()); inset = new InsetCitation(inscmd.params());
} else if (inscmd.getCmdName() == "bibitem") { } else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem"); lex.printError("Wrong place for bibitem");
inset = inscmd.Clone(); inset = inscmd.Clone();
@ -971,7 +971,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
inset = new InsetLabel(inscmd.getCommand()); inset = new InsetLabel(inscmd.getCommand());
} else if (inscmd.getCmdName() == "url" } else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") { || inscmd.getCmdName() == "htmlurl") {
inset = new InsetUrl(inscmd.getCommand()); inset = new InsetUrl(inscmd.params());
} else if (inscmd.getCmdName() == "ref" } else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref" || inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref" || inscmd.getCmdName() == "vref"
@ -1190,8 +1190,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
inscmd.Read(this, lex); inscmd.Read(this, lex);
Inset * inset = 0; Inset * inset = 0;
if (inscmd.getCmdName() == "cite") { if (inscmd.getCmdName() == "cite") {
inset = new InsetCitation(inscmd.getContents(), inset = new InsetCitation(inscmd.params());
inscmd.getOptions());
} else if (inscmd.getCmdName() == "bibitem") { } else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem"); lex.printError("Wrong place for bibitem");
inset = inscmd.Clone(); inset = inscmd.Clone();
@ -1206,7 +1205,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
inset = new InsetLabel(inscmd.getCommand()); inset = new InsetLabel(inscmd.getCommand());
} else if (inscmd.getCmdName() == "url" } else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") { || inscmd.getCmdName() == "htmlurl") {
inset = new InsetUrl(inscmd.getCommand()); inset = new InsetUrl(inscmd.params());
} else if (inscmd.getCmdName() == "ref" } else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref" || inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref" || inscmd.getCmdName() == "vref"

View File

@ -267,15 +267,11 @@ enum kb_action {
LFUN_INSET_LIST, // Lgb 20000627 LFUN_INSET_LIST, // Lgb 20000627
LFUN_INSET_THEOREM, // Lgb 20000630 LFUN_INSET_THEOREM, // Lgb 20000630
LFUN_CREATE_CITATION, // Angus 20000705 LFUN_CREATE_CITATION, // Angus 20000705
LFUN_INSET_CAPTION, // Lgb 20000718 LFUN_INSET_CAPTION, // Lgb 20000718
LFUN_SWITCHBUFFER, // and where is this comming from? LFUN_SWITCHBUFFER, // and where is this comming from?
LFUN_INSERT_URL, // Angus 20000726
LFUN_LASTACTION /* this marks the end of the table */ LFUN_LASTACTION /* this marks the end of the table */
}; };
std::ostream & operator<<(std::ostream &, kb_action); std::ostream & operator<<(std::ostream &, kb_action);
#endif #endif

View File

@ -7,7 +7,6 @@ _("Options|O");
_("Documents|D"); _("Documents|D");
_("Help|H"); _("Help|H");
_("File|F"); _("File|F");
_("File|F");
_("Options|O"); _("Options|O");
_("Help|H"); _("Help|H");
_("New...|N"); _("New...|N");

View File

@ -35,13 +35,14 @@ class DialogBase;
// Maybe this should be a UIFunc modelled on LyXFunc // Maybe this should be a UIFunc modelled on LyXFunc
class LyXView; class LyXView;
class InsetBibKey;
class InsetBibtex;
class InsetCitation;
class InsetInclude; class InsetInclude;
class InsetIndex; class InsetIndex;
class InsetBibKey;
class InsetCitation;
class InsetBibtex;
class InsetInfo; class InsetInfo;
class InsetTabular; class InsetTabular;
class InsetUrl;
/** Container of all dialogs and signals a LyXView needs or uses to access them /** Container of all dialogs and signals a LyXView needs or uses to access them
The list of dialog signals isn't comprehensive but should be a good guide The list of dialog signals isn't comprehensive but should be a good guide
@ -113,6 +114,10 @@ public:
/// ///
Signal1<void, string const &> createCitation; Signal1<void, string const &> createCitation;
/// ///
Signal1<void, InsetUrl *> showUrl;
///
Signal1<void, string const &> createUrl;
///
Signal1<void, InsetBibtex *> showBibtex; Signal1<void, InsetBibtex *> showBibtex;
/// ///
Signal1<void, InsetInfo *> showInfo; Signal1<void, InsetInfo *> showInfo;

View File

@ -7,6 +7,7 @@
#include "FormPreferences.h" #include "FormPreferences.h"
#include "FormPrint.h" #include "FormPrint.h"
#include "FormTabular.h" #include "FormTabular.h"
#include "FormUrl.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
@ -20,6 +21,7 @@ Dialogs::Dialogs(LyXView * lv)
dialogs_.push_back(new FormPreferences(lv, this)); dialogs_.push_back(new FormPreferences(lv, this));
dialogs_.push_back(new FormPrint(lv, this)); dialogs_.push_back(new FormPrint(lv, this));
dialogs_.push_back(new FormTabular(lv, this)); dialogs_.push_back(new FormTabular(lv, this));
dialogs_.push_back(new FormUrl(lv, this));
// reduce the number of connections needed in // reduce the number of connections needed in
// dialogs by a simple connection here. // dialogs by a simple connection here.

View File

@ -10,19 +10,17 @@
*/ */
#include <config.h> #include <config.h>
#include <algorithm>
#include "gettext.h" #include "gettext.h"
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
#include "xform_macros.h"
#include "FormCitation.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "lyxfunc.h"
#include "insets/insetcite.h"
#include "form_citation.h"
#include "buffer.h"
#include "BufferView.h" #include "BufferView.h"
#include "Dialogs.h"
#include "FormCitation.h"
#include "LyXView.h"
#include "buffer.h"
#include "form_citation.h"
#include "lyxfunc.h"
#include "xform_macros.h"
#include "insets/insetcite.h"
#include "support/filetools.h" #include "support/filetools.h"
#ifdef __GNUG__ #ifdef __GNUG__
@ -41,7 +39,8 @@ C_GENERICCB(FormCitation, CancelCB)
C_GENERICCB(FormCitation, InputCB) C_GENERICCB(FormCitation, InputCB)
FormCitation::FormCitation(LyXView * lv, Dialogs * d) FormCitation::FormCitation(LyXView * lv, Dialogs * d)
: dialog_(0), lv_(lv), d_(d), h_(0), inset_(0), dialogIsOpen(false) : dialog_(0), lv_(lv), d_(d), u_(0), h_(0), ih_(0),
inset_(0), dialogIsOpen(false)
{ {
// let the dialog be shown // let the dialog be shown
// These are permanent connections so we won't bother // These are permanent connections so we won't bother
@ -59,7 +58,7 @@ FormCitation::~FormCitation()
void FormCitation::build() void FormCitation::build()
{ {
dialog_ = build_citation(); dialog_ = build_citation();
} }
@ -449,22 +448,23 @@ void FormCitation::apply()
{ {
if( lv_->buffer()->isReadonly() ) return; if( lv_->buffer()->isReadonly() ) return;
string tmp; string contents;
for( unsigned int i = 0; i < citekeys.size(); ++i ) { for( unsigned int i = 0; i < citekeys.size(); ++i ) {
if (i > 0) tmp += ", "; if (i > 0) contents += ", ";
tmp += citekeys[i]; contents += citekeys[i];
} }
textAfter = fl_get_input(dialog_->textAftr); textAfter = fl_get_input(dialog_->textAftr);
if( inset_ != 0 ) if( inset_ != 0 )
{ {
inset_->setContents( tmp ); inset_->setContents( contents );
inset_->setOptions( textAfter ); inset_->setOptions( textAfter );
lv_->view()->updateInset( inset_, true ); lv_->view()->updateInset( inset_, true );
} else { } else {
string arg = tmp + '|' + textAfter; InsetCommandParams p( "cite", contents, textAfter );
lv_->getLyXFunc()->Dispatch( LFUN_INSERT_CITATION, arg.c_str() ); lv_->getLyXFunc()->Dispatch( LFUN_INSERT_CITATION,
p.getAsString().c_str() );
} }
} }

View File

@ -67,7 +67,7 @@ private:
void show(); void show();
/// Hide the dialog. /// Hide the dialog.
void hide(); void hide();
/// Not used but we've got to implement it. ///
void update(); void update();
//@} //@}

View File

@ -0,0 +1,208 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*/
#include <config.h>
#include "gettext.h"
#include FORMS_H_LOCATION
#include "BufferView.h"
#include "Dialogs.h"
#include "FormUrl.h"
#include "LyXView.h"
#include "buffer.h"
#include "form_url.h"
#include "lyxfunc.h"
#include "xform_macros.h"
#include "insets/insetcommand.h"
#include "insets/inseturl.h"
#include "support/filetools.h"
#ifdef __GNUG__
#pragma implementation
#endif
C_RETURNCB(FormUrl, WMHideCB)
C_GENERICCB(FormUrl, OKCB)
C_GENERICCB(FormUrl, CancelCB)
FormUrl::FormUrl(LyXView * lv, Dialogs * d)
: dialog_(0), lv_(lv), d_(d), u_(0), h_(0), ih_(0),
inset_(0), dialogIsOpen(false)
{
// let the dialog be shown
// These are permanent connections so we won't bother
// storing a copy because we won't be disconnecting.
d->showUrl.connect(slot(this, &FormUrl::showInset));
d->createUrl.connect(slot(this, &FormUrl::createInset));
params = new InsetCommandParams();
}
FormUrl::~FormUrl()
{
free();
delete params;
}
void FormUrl::build()
{
dialog_ = build_url();
}
void FormUrl::showInset( InsetUrl * inset )
{
if( dialogIsOpen || inset == 0 ) return;
inset_ = inset;
ih_ = inset_->hide.connect(slot(this, &FormUrl::hide));
(*params) = inset->params();
show();
}
void FormUrl::createInset( string const & arg )
{
if( dialogIsOpen ) return;
params->setFromString( arg );
show();
}
void FormUrl::show()
{
if (!dialog_) {
build();
fl_set_form_atclose(dialog_->form_url,
C_FormUrlWMHideCB, 0);
}
update(); // make sure its up-to-date
dialogIsOpen = true;
if (dialog_->form_url->visible) {
fl_raise_form(dialog_->form_url);
} else {
fl_show_form(dialog_->form_url,
FL_PLACE_MOUSE | FL_FREE_SIZE,
FL_TRANSIENT,
_("Url"));
u_ = d_->updateBufferDependent.
connect(slot(this, &FormUrl::update));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormUrl::hide));
}
}
void FormUrl::update()
{
fl_set_input(dialog_->url, params->getContents().c_str());
fl_set_input(dialog_->name, params->getOptions().c_str());
if ( params->getCmdName() == "url" )
fl_set_button(dialog_->radio_html, 0);
else
fl_set_button(dialog_->radio_html, 1);
static int ow = -1, oh;
if (ow < 0) {
ow = dialog_->form_url->w;
oh = dialog_->form_url->h;
}
fl_set_form_minsize(dialog_->form_url, ow, oh);
fl_set_form_maxsize(dialog_->form_url, 2*ow, oh);
}
void FormUrl::apply()
{
if( lv_->buffer()->isReadonly() ) return;
params->setContents( fl_get_input(dialog_->url) );
params->setOptions( fl_get_input(dialog_->name) );
if (fl_get_button(dialog_->radio_html))
params->setCmdName("htmlurl");
else
params->setCmdName("url");
if( inset_ != 0 )
{
inset_->setParams( *params );
lv_->view()->updateInset( inset_, true );
} else {
lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
params->getAsString().c_str() );
}
}
void FormUrl::hide()
{
if (dialog_
&& dialog_->form_url
&& dialog_->form_url->visible) {
fl_hide_form(dialog_->form_url);
u_.disconnect();
h_.disconnect();
}
// free up the dialog for another inset
inset_ = 0;
ih_.disconnect();
dialogIsOpen = false;
}
void FormUrl::free()
{
// we don't need to delete u and h here because
// hide() does that after disconnecting.
if (dialog_) {
if (dialog_->form_url
&& dialog_->form_url->visible) {
hide();
}
fl_free_form(dialog_->form_url);
delete dialog_;
dialog_ = 0;
}
}
int FormUrl::WMHideCB(FL_FORM * form, void *)
{
// Ensure that the signals (u and h) are disconnected even if the
// window manager is used to close the dialog.
FormUrl * pre = static_cast<FormUrl*>(form->u_vdata);
pre->hide();
return FL_CANCEL;
}
void FormUrl::OKCB(FL_OBJECT * ob, long)
{
FormUrl * pre = static_cast<FormUrl*>(ob->form->u_vdata);
pre->apply();
pre->hide();
}
void FormUrl::CancelCB(FL_OBJECT * ob, long)
{
FormUrl * pre = static_cast<FormUrl*>(ob->form->u_vdata);
pre->hide();
}

View File

@ -0,0 +1,101 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*/
#ifndef FORMURL_H
#define FORMURL_H
#include "DialogBase.h"
#include "LString.h"
class Dialogs;
class LyXView;
class InsetCommandParams;
class InsetUrl;
struct FD_form_url;
/** This class provides an XForms implementation of the FormUrl Dialog.
*/
class FormUrl : public DialogBase {
public:
/**@name Constructors and Destructors */
//@{
///
FormUrl(LyXView *, Dialogs *);
///
~FormUrl();
//@}
/**@name Real per-instance Callback Methods */
//@{
static int WMHideCB(FL_FORM *, void *);
static void OKCB(FL_OBJECT *, long);
static void CancelCB(FL_OBJECT *, long);
//@}
private:
FormUrl() {}
FormUrl(FormUrl &) : DialogBase() {}
/**@name Slot Methods */
//@{
/// Create the dialog if necessary, update it and display it.
void createInset( string const & );
///
void showInset( InsetUrl * );
///
void show();
/// Hide the dialog.
void hide();
///
void update();
//@}
/**@name Dialog internal methods */
//@{
/// Apply from dialog
void apply();
/// Build the dialog
void build();
///
FD_form_url * build_url();
/// Explicitly free the dialog.
void free();
//@}
/**@name Private Data */
//@{
/// Real GUI implementation.
FD_form_url * dialog_;
/** Which LyXFunc do we use?
We could modify Dialogs to have a visible LyXFunc* instead and
save a couple of bytes per dialog.
*/
LyXView * lv_;
/** Which Dialogs do we belong to?
Used so we can get at the signals we have to connect to.
*/
Dialogs * d_;
/// Update connection.
Connection u_;
/// Hide connection.
Connection h_;
/// inset::hide connection.
Connection ih_;
///
InsetUrl * inset_;
///
bool dialogIsOpen;
///
InsetCommandParams * params;
//@}
};
#endif

View File

@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
Name: form_url Name: form_url
Width: 520 Width: 520
Height: 140 Height: 140
Number of Objects: 5 Number of Objects: 6
-------------------- --------------------
class: FL_BOX class: FL_BOX
@ -44,7 +44,7 @@ label: URL
shortcut: Url|#U shortcut: Url|#U
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: url_name name: url
callback: callback:
argument: argument:
@ -62,7 +62,7 @@ label: Name
shortcut: Name|#N shortcut: Name|#N
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: name_name name: name
callback: callback:
argument: argument:
@ -86,7 +86,7 @@ argument:
-------------------- --------------------
class: FL_BUTTON class: FL_BUTTON
type: RETURN_BUTTON type: NORMAL_BUTTON
box: 410 100 100 30 box: 410 100 100 30
boxtype: FL_UP_BOX boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1 colors: FL_COL1 FL_COL1
@ -94,12 +94,30 @@ alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE size: FL_NORMAL_SIZE
lcol: FL_BLACK lcol: FL_BLACK
label: Close|#C^[ label: Cancel
shortcut: ^M shortcut: ^[
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_close name: cancel
callback: C_InsetUrl_CloseUrlCB callback: C_FormUrlCancelCB
argument: 0
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 300 100 100 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: OK
shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast
name: ok
callback: C_FormUrlOKCB
argument: 0 argument: 0
============================== ==============================

View File

@ -23,7 +23,8 @@ SRCS := form_citation.fd \
form_copyright.fd \ form_copyright.fd \
form_preferences.fd \ form_preferences.fd \
form_print.fd \ form_print.fd \
form_tabular.fd form_tabular.fd \
form_url.fd
OBJS := $(SRCS:.fd=.c) OBJS := $(SRCS:.fd=.c)

View File

@ -14,8 +14,6 @@ libinsets_la_SOURCES = \
figinset.h \ figinset.h \
form_graphics.C \ form_graphics.C \
form_graphics.h \ form_graphics.h \
form_url.C \
form_url.h \
inset.C \ inset.C \
insetbib.C \ insetbib.C \
insetbib.h \ insetbib.h \

View File

@ -350,10 +350,11 @@ void InsetBibtex::Edit(BufferView * bv, int, int, unsigned int)
bool InsetBibtex::addDatabase(string const & db) bool InsetBibtex::addDatabase(string const & db)
{ {
if (!contains(getContents(), db.c_str())) { string contents(getContents());
if (!getContents().empty()) if (!contains(contents, db.c_str())) {
addContents(","); if (!contents.empty())
addContents(db); contents += ",";
setContents(contents + db);
return true; return true;
} }
return false; return false;

View File

@ -20,8 +20,8 @@
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "support/lstrings.h" #include "support/lstrings.h"
InsetCitation::InsetCitation(string const & key, string const & note) InsetCitation::InsetCitation(InsetCommandParams const & p)
: InsetCommand("cite", key, note) : InsetCommand(p)
{} {}
InsetCitation::~InsetCitation() InsetCitation::~InsetCitation()

View File

@ -18,26 +18,21 @@
#include "insetcommand.h" #include "insetcommand.h"
#include <sigc++/signal_system.h> #include <sigc++/signal_system.h>
class Dialogs;
#ifdef SIGC_CXX_NAMESPACES #ifdef SIGC_CXX_NAMESPACES
using SigC::Signal0; using SigC::Signal0;
#endif #endif
/** Used to insert citations /** Used to insert citations
*/ */
class InsetCitation : public InsetCommand { class InsetCitation : public InsetCommand {
public: public:
/// ///
explicit explicit
InsetCitation(string const & key, string const & note = string()); InsetCitation(InsetCommandParams const &);
/// ///
~InsetCitation(); ~InsetCitation();
/// ///
Inset * Clone() const { Inset * Clone() const { return new InsetCitation(params()); }
return new InsetCitation(getContents(), getOptions());
}
/// ///
string getScreenLabel() const; string getScreenLabel() const;
/// ///

View File

@ -22,16 +22,67 @@ using std::ostream;
using std::endl; using std::endl;
InsetCommandParams::InsetCommandParams()
{}
InsetCommandParams::InsetCommandParams( string const & n,
string const & c,
string const & o )
: cmdname(n), contents(c), options(o)
{}
string InsetCommandParams::getAsString() const
{
string b(cmdname);
b += "|++|" + options + "|++|" + contents;
return b;
}
void InsetCommandParams::setFromString( string const & b )
{
string::size_type idx = b.find("|++|");
if( idx == string::npos ) return;
cmdname = b.substr(0, idx);
string tmp = b.substr(idx+4);
idx = tmp.find("|++|");
if( idx == string::npos ) {
options = tmp;
} else {
options = tmp.substr(0, idx);
contents = tmp.substr(idx+4);
}
}
InsetCommand::InsetCommand() InsetCommand::InsetCommand()
{} {}
InsetCommand::InsetCommand(string const & cmd, string const & arg, InsetCommand::InsetCommand( string const & n,
string const & opt) string const & c,
: cmdname(cmd), options(opt), contents(arg) string const & o )
: p_(n, c, o)
{} {}
InsetCommand::InsetCommand( InsetCommandParams const & p )
: p_( p.getCmdName(), p.getContents(), p.getOptions() )
{}
void InsetCommand::setParams(InsetCommandParams const & p )
{
p_.setCmdName( p.getCmdName() );
p_.setContents( p.getContents() );
p_.setOptions( p.getOptions() );
}
// In lyxf3 this will be just LaTeX // In lyxf3 this will be just LaTeX
void InsetCommand::Write(Buffer const *, ostream & os) const void InsetCommand::Write(Buffer const *, ostream & os) const
{ {
@ -88,10 +139,9 @@ void InsetCommand::scanCommand(string const & cmd)
} }
// Don't mess with this. // Don't mess with this.
if (!tcmdname.empty()) cmdname = tcmdname; if (!tcmdname.empty()) setCmdName( tcmdname );
if (!toptions.empty()) options = toptions; if (!toptions.empty()) setOptions( toptions );
if (!tcontents.empty()) setContents(tcontents); if (!tcontents.empty()) setContents( tcontents );
// setContents is overloaded in InsetInclude
if (lyxerr.debugging(Debug::PARSER)) if (lyxerr.debugging(Debug::PARSER))
lyxerr << "Command <" << cmd lyxerr << "Command <" << cmd
@ -153,15 +203,15 @@ int InsetCommand::DocBook(Buffer const *, ostream &) const
Inset * InsetCommand::Clone() const Inset * InsetCommand::Clone() const
{ {
return new InsetCommand(cmdname, contents, options); return new InsetCommand(getCmdName(), getContents(), getOptions());
} }
string InsetCommand::getCommand() const string InsetCommand::getCommand() const
{ {
string s; string s;
if (!cmdname.empty()) s += "\\"+cmdname; if (!getCmdName().empty()) s += "\\"+getCmdName();
if (!options.empty()) s += "["+options+']'; if (!getOptions().empty()) s += "["+getOptions()+']';
s += "{"+contents+'}'; s += "{"+getContents()+'}';
return s; return s;
} }

View File

@ -24,14 +24,54 @@
* Similar to InsetLaTeX but having control of the basic structure of a * Similar to InsetLaTeX but having control of the basic structure of a
* LaTeX command: \name[options]{contents}. * LaTeX command: \name[options]{contents}.
*/ */
class InsetCommandParams {
public:
///
InsetCommandParams();
///
explicit
InsetCommandParams( string const & n,
string const & c = string(),
string const & o = string());
///
string const & getCmdName() const { return cmdname; }
///
string const & getOptions() const { return options; }
///
string const & getContents() const { return contents; }
///
void setCmdName( string const & n ) { cmdname = n; }
///
void setOptions(string const & o) { options = o; }
///
void setContents(string const & c) { contents = c; }
///
string getAsString() const;
///
void setFromString( string const & );
private:
///
string cmdname;
///
string contents;
///
string options;
};
class InsetCommand : public InsetButton { class InsetCommand : public InsetButton {
public: public:
/// ///
InsetCommand(); InsetCommand();
/// ///
explicit explicit
InsetCommand(string const & name, string const & arg = string(), InsetCommand(string const & n,
string const & opt = string()); string const & c = string(),
string const & o = string());
///
explicit
InsetCommand(InsetCommandParams const &);
/// ///
void Write(Buffer const *, std::ostream &) const; void Write(Buffer const *, std::ostream &) const;
@ -62,48 +102,28 @@ public:
confusion with lyxinset::getLabel(int), but I've seen that confusion with lyxinset::getLabel(int), but I've seen that
it wasn't. I hope you never confuse again both methods. (ale) it wasn't. I hope you never confuse again both methods. (ale)
*/ */
virtual string getScreenLabel() const virtual string getScreenLabel() const { return getCommand(); }
{
return getCommand();
}
/// Build the complete LaTeX command /// Build the complete LaTeX command
string getCommand() const; string getCommand() const;
/// ///
string const & getCmdName() const { string const & getCmdName() const { return p_.getCmdName(); }
return cmdname;
}
/// ///
string const & getOptions() const { string const & getOptions() const { return p_.getOptions(); }
return options;
}
/// ///
string const & getContents() const { string const & getContents() const { return p_.getContents(); }
return contents;
}
/// ///
void setCmdName(string const & n) { void setCmdName(string const & n) { p_.setCmdName(n); }
cmdname = n;
}
/// ///
void setOptions(string const & o) { void setOptions(string const & o) { p_.setOptions(o); }
options = o;
}
/// ///
virtual void setContents(string const & c) { void setContents(string const & c) { p_.setContents(c); }
contents = c;
}
/// ///
void addContents(string const & c) { InsetCommandParams const & params() const { return p_; }
contents += c; ///
} void setParams(InsetCommandParams const &);
private: private:
/// ///
string cmdname; InsetCommandParams p_;
///
string options;
///
string contents;
}; };
#endif #endif

View File

@ -1,3 +1,4 @@
#include <config.h> #include <config.h>
#include <cstdlib> #include <cstdlib>
@ -334,11 +335,16 @@ string InsetInclude::getScreenLabel() const
} }
void InsetInclude::setContents(string const & c) string InsetInclude::getFileName() const
{ {
InsetCommand::setContents(c); return MakeAbsPath(getContents(),
filename = MakeAbsPath(getContents(), OnlyPath(getMasterFilename()));
OnlyPath(getMasterFilename())); }
string InsetInclude::getMasterFilename() const
{
return master->fileName();
} }

View File

@ -16,9 +16,8 @@
#endif #endif
#include "insetcommand.h" #include "insetcommand.h"
#include "buffer.h"
#include "support/filetools.h"
class Buffer;
struct LaTeXFeatures; struct LaTeXFeatures;
// Created by AAS 970521 // Created by AAS 970521
@ -72,16 +71,11 @@ public:
bool display() const; bool display() const;
/// ///
string getScreenLabel() const; string getScreenLabel() const;
///
void setContents(string const & c);
/// ///
void setFilename(string const & n) { setContents(n); } string getMasterFilename() const;
/// ///
string getMasterFilename() const { return master->fileName(); } string getFileName() const;
///
string getFileName() const {
return filename;
}
/// In "input" mode uses \input instead of \include. /// In "input" mode uses \input instead of \include.
bool isInput() const { return flag == InsetInclude::INPUT; } bool isInput() const { return flag == InsetInclude::INPUT; }
/// If this is true, the child file shouldn't be loaded by lyx /// If this is true, the child file shouldn't be loaded by lyx
@ -129,8 +123,6 @@ private:
/// ///
Buffer * master; Buffer * master;
/// ///
string filename;
///
mutable string include_label; mutable string include_label;
}; };

View File

@ -1,115 +1,27 @@
#include <config.h> #include <config.h>
#include <cstdlib>
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
#endif #endif
#include FORMS_H_LOCATION
#include "inseturl.h" #include "inseturl.h"
#include "LString.h" #include "BufferView.h"
#include "commandtags.h"
#include "debug.h"
#include "gettext.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "lyx_gui_misc.h" // CancelCloseBoxCB #include "LyXView.h"
#include "debug.h"
#include "frontends/Dialogs.h"
using std::ostream; using std::ostream;
InsetUrl::InsetUrl(string const & cmd) InsetUrl::InsetUrl(InsetCommandParams const & p)
: fd_form_url(0) : InsetCommand(p)
{ {}
scanCommand(cmd);
if (getCmdName() == "url")
flag = InsetUrl::URL;
else
flag = InsetUrl::HTML_URL;
}
InsetUrl::InsetUrl(InsetCommand const & inscmd)
: fd_form_url(0)
{
setCmdName(inscmd.getCmdName());
setContents(inscmd.getContents());
setOptions(inscmd.getOptions());
if (getCmdName() == "url")
flag = InsetUrl::URL;
else
flag = InsetUrl::HTML_URL;
}
InsetUrl::InsetUrl(string const & ins_name, string const & ins_cont,
string const & ins_opt)
: fd_form_url(0)
{
setCmdName(ins_name);
setContents(ins_cont);
setOptions(ins_opt);
if (ins_name == "url")
flag = InsetUrl::URL;
else
flag = InsetUrl::HTML_URL;
}
InsetUrl::~InsetUrl() InsetUrl::~InsetUrl()
{ {
if (fd_form_url) { hide();
fl_hide_form(fd_form_url->form_url);
fl_free_form(fd_form_url->form_url);
fd_form_url = 0;
}
}
void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
{
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;
if (fl_get_button(inset->fd_form_url->radio_html))
cmdname = "htmlurl";
else
cmdname = "url";
Buffer * buffer = bv->buffer();
if ((url != inset->getContents() ||
name != inset->getOptions() ||
cmdname != inset->getCmdName())
&& !(buffer->isReadonly()) ) {
buffer->markDirty();
inset->setContents(url);
inset->setOptions(name);
inset->setCmdName(cmdname);
if (cmdname == "url")
inset->flag = InsetUrl::URL;
else
inset->flag = InsetUrl::HTML_URL;
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 data)
{
InsetUrl::CloseUrlCB(ob, data);
} }
@ -121,57 +33,23 @@ char const * InsetUrl::EditMessage() const
void InsetUrl::Edit(BufferView * bv, int, int, unsigned int) void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
{ {
static int ow = -1, oh; bv->owner()->getDialogs()->showUrl( this );
if(bv->buffer()->isReadonly())
WarnReadonly(bv->buffer()->fileName());
if (!fd_form_url) {
fd_form_url = create_form_form_url();
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) {
case InsetUrl::URL:
fl_set_button(fd_form_url->radio_html, 0);
break;
case InsetUrl::HTML_URL:
fl_set_button(fd_form_url->radio_html, 1);
break;
}
if (fd_form_url->form_url->visible) {
fl_raise_form(fd_form_url->form_url);
} else {
fl_show_form(fd_form_url->form_url,
FL_PLACE_MOUSE | FL_FREE_SIZE,
FL_FULLBORDER, _("Insert Url"));
if (ow < 0) {
ow = fd_form_url->form_url->w;
oh = fd_form_url->form_url->h;
}
fl_set_form_minsize(fd_form_url->form_url, ow, oh);
}
} }
string InsetUrl::getScreenLabel() const string InsetUrl::getScreenLabel() const
{ {
string temp; string temp;
if (flag == InsetUrl::HTML_URL) if( getCmdName() == "url" )
temp += _("HtmlUrl: "); temp = _("Url: ");
else else
temp += _("Url: "); temp = _("HtmlUrl: ");
if(!getOptions().empty()) {
if(!getOptions().empty())
temp += getOptions(); temp += getOptions();
} else { else
temp += getContents(); temp += getContents();
}
return temp; return temp;
} }

View File

@ -16,61 +16,39 @@
#endif #endif
#include "insetcommand.h" #include "insetcommand.h"
#include "buffer.h" #include <sigc++/signal_system.h>
#include "form_url.h"
struct LaTeXFeatures; struct LaTeXFeatures;
#ifdef SIGC_CXX_NAMESPACES
using SigC::Signal0;
#endif
/** The url inset /** The url inset
*/ */
class InsetUrl : public InsetCommand { class InsetUrl : public InsetCommand {
public: public:
///
enum Url_Flags {
///
URL,
///
HTML_URL
};
///
InsetUrl() : InsetCommand("url"), fd_form_url(0) {
flag = InsetUrl::URL;
}
/// ///
explicit explicit
InsetUrl(string const &); InsetUrl(InsetCommandParams const &);
///
explicit
InsetUrl(InsetCommand const &);
///
InsetUrl(string const &, string const &, string const &);
/// ///
~InsetUrl(); ~InsetUrl();
/// ///
Inset * Clone() const { return new InsetUrl(getCommand()); } Inset * Clone() const { return new InsetUrl(params()); }
/// ///
Inset::Code LyxCode() const { return Inset::URL_CODE; } Inset::Code LyxCode() const { return Inset::URL_CODE; }
/// ///
void Validate(LaTeXFeatures &) const; void Validate(LaTeXFeatures &) const;
/// ///
void Edit(BufferView *, int, int, unsigned int);
///
EDITABLE Editable() const {
return IS_EDITABLE;
}
///
char const * EditMessage() const;
///
bool display() const { return false; }
///
string getScreenLabel() const; string getScreenLabel() const;
/// ///
InsetUrl::Url_Flags getFlag() const { return flag; } EDITABLE Editable() const { return IS_EDITABLE; }
/// ///
void setFlag(InsetUrl::Url_Flags f) { flag = f; } char const * EditMessage() const;
///
void Edit(BufferView *, int, int, unsigned int);
/// ///
void gotoLabel(); bool display() const { return false; }
/// ///
int Latex(Buffer const *, std::ostream &, int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const; bool fragile, bool free_spc) const;
@ -81,20 +59,7 @@ public:
/// ///
int DocBook(Buffer const *, std::ostream &) const; int DocBook(Buffer const *, std::ostream &) const;
/// ///
static void CloseUrlCB(FL_OBJECT *, long data); Signal0<void> hide;
private:
///
struct Holder {
InsetUrl * inset;
BufferView * view;
};
///
Holder holder;
///
Url_Flags flag;
///
FD_form_url * fd_form_url;
}; };
#endif #endif

View File

@ -2071,18 +2071,28 @@ string LyXFunc::Dispatch(int ac,
case LFUN_HTMLURL: case LFUN_HTMLURL:
case LFUN_URL: case LFUN_URL:
{ {
InsetCommand * new_inset; InsetCommandParams p;
if (action == LFUN_HTMLURL) if (action == LFUN_HTMLURL)
new_inset = new InsetUrl("htmlurl", "", ""); p.setCmdName("htmlurl");
else else
new_inset = new InsetUrl("url", "", ""); p.setCmdName("url");
if (owner->view()->insertInset(new_inset)) owner->getDialogs()->createUrl( p.getAsString() );
new_inset->Edit(owner->view(), 0, 0, 0);
else
delete new_inset;
} }
break; break;
case LFUN_INSERT_URL:
{
InsetCommandParams p;
p.setFromString( argument );
InsetUrl * inset = new InsetUrl( p );
if (!owner->view()->insertInset(inset))
delete inset;
else
owner->view()->updateInset( inset, true );
}
break;
case LFUN_INSET_TEXT: case LFUN_INSET_TEXT:
{ {
InsetText * new_inset = new InsetText; InsetText * new_inset = new InsetText;
@ -2493,10 +2503,10 @@ string LyXFunc::Dispatch(int ac,
case LFUN_INSERT_CITATION: case LFUN_INSERT_CITATION:
{ {
string keys = token(argument, '|', 0); InsetCommandParams p;
string text = token(argument, '|', 1); p.setFromString( argument );
InsetCitation * inset = new InsetCitation( keys, text ); InsetCitation * inset = new InsetCitation( p );
if (!owner->view()->insertInset(inset)) if (!owner->view()->insertInset(inset))
delete inset; delete inset;
else else

View File

@ -23,6 +23,7 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "layout.h" #include "layout.h"
#include "tex-strings.h" #include "tex-strings.h"
#include "buffer.h"
#include "bufferparams.h" #include "bufferparams.h"
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "support/LAssert.h" #include "support/LAssert.h"