+2000-08-04 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
+
+ * src/support/strerror.c: remove C++ comment.
+
+2000-08-04 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * src/commandtags.h: LFUN_INDEX_CREATE_LAST reverts to
+ LFUN_INDEX_INSERT_LAST
+
+ * src/texrow.C (getIdFromRow): changed from const_iterator to
+ iterator, allowing code to compile with DEC cxx
+
+ * src/frontends/xforms/FormCitation.[Ch]: made vector<string>
+ stores part of the class, as suggested by Allan. Will allow
+ multiple LyXViews.
+ (apply): test to apply uses InsetCommandParams operator!=
+
+ * src/frontends/xforms/FormIndex.C: moved set_minsize into build
+ (apply): test to apply uses InsetCommandParams operator!=
+
+ * src/frontends/xforms/FormToc.[Ch]: made vector<string>
+ stores part of the class.
+ (update): removed limits on min/max size.
+
+ * src/frontends/xforms/FormUrl.C: moved set_minsize into build
+ (apply): test to apply uses InsetCommandParams operator!=
+
+ * src/insets/insetcommand.[Ch] InsetCommand made noncopyable
+ (Read, Write, scanCommand, getCommand): moved functionality
+ into InsetCommandParams.
+ (Clone): removed
+ (getScreenLabel): made pure virtual
+ new InsetCommandParams operators== and !=
+
+ * src/insets/insetbib.[Ch] (InsetBibKey, InsetBibtex): new
+ c-tors based on InsetCommandParams. Removed others.
+ * src/insets/insetinclude.[Ch]: ditto
+ * src/insets/insetlabel.[Ch]: ditto
+ * src/insets/insetparent.[Ch]: ditto
+ * src/insets/insetref.[Ch]: ditto. Also moved gotoLabel into .C
+
+ * src/buffer.C (parseSingleLyXformat2Token, readInset): all
+ insets derived from InsetCommand created using similar c-tors
+ based on InsetCommandParams
+ * src/lyx_cb.C (MenuInsertLabel, RefSelectCB): ditto
+ * src/menus.C (ShowRefsMenu): ditto
+ * src/paragraph.C (Clone): ditto
+ * src/text2.C (SetCounter): ditto
+ * src/lyxfunc.C (Dispatch) ditto
+ Also recreated old InsetIndex behaviour exactly. Can now
+ index-insert at the start of a paragraph and index-insert-last
+ without launching the pop-up.
+
2000-08-03 Lars Gullik Bjønnes <larsbj@lyx.org>
* lib/lyxrc.example: mark te pdf options as non functional.
in some private place and running it. In particular, check the
output of `ldd lyx' to know which libraries are really needed.
- o Upload your binary file to ftp.lyx.org:/pub/lyx/uploads.
+ o Upload your binary file to ftp.devel.lyx.org:/pub/incoming, and
+ notify larsbj@lyx.org.
Problems
N_("Insert hyphenation point"), Noop },
{ LFUN_INDEX_CREATE, "index-insert",
N_("Insert index item"), Noop },
- { LFUN_INDEX_CREATE_LAST, "index-insert-last",
+ { LFUN_INDEX_INSERT_LAST, "index-insert-last",
N_("Insert last index item"), Noop },
{ LFUN_INDEX_PRINT, "index-print", N_("Insert index list"),
Noop },
if (pp.first) {
params.textclass = pp.second;
} else {
- lex.printError("Unknown textclass `$$Token'");
+ lex.printError("Unknown textclass `$$Token'");
params.textclass = 0;
}
if (!textclasslist.Load(params.textclass)) {
par->InsertInset(pos, inset, font);
++pos;
} else if (tmptok == "Include") {
- Inset * inset = new InsetInclude(string(), this);
+ InsetCommandParams p( "Include" );
+ Inset * inset = new InsetInclude(p, this);
inset->Read(this, lex);
par->InsertInset(pos, inset, font);
++pos;
par->InsertInset(pos, inset, font);
++pos;
} else if (tmptok == "LatexCommand") {
- InsetCommand inscmd;
- inscmd.Read(this, lex);
+ InsetCommandParams inscmd;
+ inscmd.Read(lex);
Inset * inset = 0;
if (inscmd.getCmdName() == "cite") {
- inset = new InsetCitation(inscmd.params());
+ inset = new InsetCitation(inscmd);
} else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem");
- inset = inscmd.Clone();
+ inset = new InsetBibKey(inscmd);
} else if (inscmd.getCmdName() == "BibTeX") {
- inset = new InsetBibtex(inscmd.getContents(), inscmd.getOptions(), this);
+ inset = new InsetBibtex(inscmd, this);
} else if (inscmd.getCmdName() == "index") {
- inset = new InsetIndex(inscmd.params());
+ inset = new InsetIndex(inscmd);
} else if (inscmd.getCmdName() == "include") {
- inset = new InsetInclude(inscmd.getContents(), this);
+ inset = new InsetInclude(inscmd, this);
} else if (inscmd.getCmdName() == "label") {
- inset = new InsetLabel(inscmd.getCommand());
+ inset = new InsetLabel(inscmd);
} else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") {
- inset = new InsetUrl(inscmd.params());
+ inset = new InsetUrl(inscmd);
} else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref"
|| inscmd.getCmdName() == "listofalgorithms"
|| inscmd.getCmdName() == "listoffigures"
|| inscmd.getCmdName() == "listoftables") {
- inset = new InsetTOC(inscmd.params());
+ inset = new InsetTOC(inscmd);
} else if (inscmd.getCmdName() == "printindex") {
- inset = new InsetPrintIndex(inscmd.params());
+ inset = new InsetPrintIndex(inscmd);
} else if (inscmd.getCmdName() == "lyxparent") {
- inset = new InsetParent(inscmd.getContents(), this);
+ inset = new InsetParent(inscmd, this);
}
if (inset) {
}
++pos;
} else if (token == "\\bibitem") { // ale970302
- if (!par->bibkey)
- par->bibkey = new InsetBibKey;
+ if (!par->bibkey) {
+ InsetCommandParams p( "bibitem" );
+ par->bibkey = new InsetBibKey(p);
+ }
par->bibkey->Read(this, lex);
}else if (token == "\\backslash") {
par->InsertChar(pos, '\\', font);
par->InsertInset(pos, inset, font);
++pos;
} else if (tmptok == "Include") {
- Inset * inset = new InsetInclude(string(), this);
+ InsetCommandParams p( "Include" );
+ Inset * inset = new InsetInclude(p, this);
inset->Read(this, lex);
par->InsertInset(pos, inset, font);
++pos;
//inset->Read(this, lex);
par->InsertInset(pos, inset, font);
} else if (tmptok == "LatexCommand") {
- InsetCommand inscmd;
- inscmd.Read(this, lex);
+ InsetCommandParams inscmd;
+ inscmd.Read(lex);
Inset * inset = 0;
if (inscmd.getCmdName() == "cite") {
- inset = new InsetCitation(inscmd.params());
+ inset = new InsetCitation(inscmd);
} else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem");
- inset = inscmd.Clone();
+ inset = new InsetBibKey(inscmd);
} else if (inscmd.getCmdName() == "BibTeX") {
- inset = new InsetBibtex(inscmd.getContents(),
- inscmd.getOptions(), this);
+ inset = new InsetBibtex(inscmd, this);
} else if (inscmd.getCmdName() == "index") {
- inset = new InsetIndex(inscmd.params());
+ inset = new InsetIndex(inscmd);
} else if (inscmd.getCmdName() == "include") {
- inset = new InsetInclude(inscmd.getContents(), this);
+ inset = new InsetInclude(inscmd, this);
} else if (inscmd.getCmdName() == "label") {
- inset = new InsetLabel(inscmd.getCommand());
+ inset = new InsetLabel(inscmd);
} else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") {
- inset = new InsetUrl(inscmd.params());
+ inset = new InsetUrl(inscmd);
} else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref"
|| inscmd.getCmdName() == "listofalgorithms"
|| inscmd.getCmdName() == "listoffigures"
|| inscmd.getCmdName() == "listoftables") {
- inset = new InsetTOC(inscmd.params());
+ inset = new InsetTOC(inscmd);
} else if (inscmd.getCmdName() == "printindex") {
- inset = new InsetPrintIndex(inscmd.params());
+ inset = new InsetPrintIndex(inscmd);
} else if (inscmd.getCmdName() == "lyxparent") {
- inset = new InsetParent(inscmd.getContents(), this);
+ inset = new InsetParent(inscmd, this);
}
if (inset) {
LFUN_CITATION_INSERT, // AAS 97-02-23
LFUN_INSERT_BIBTEX, // AAS 97-02-23
LFUN_INDEX_CREATE, // Lgb 97-02-27
- LFUN_INDEX_CREATE_LAST, // 180 // Reh 98-09-17
+ LFUN_INDEX_INSERT_LAST, // 180 // Reh 98-09-17
LFUN_INDEX_PRINT, // Lgb 97-02-27
LFUN_APROPOS, // Asger 1997-02-27
LFUN_LATEX_LOG, // Lgb 97-04-05
using std::min;
using std::find;
-static vector<string> citekeys;
-static vector<string> bibkeys;
-static vector<string> bibkeysInfo;
-
FormCitation::FormCitation(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Citation")), dialog_(0)
{
FL_FORM * const FormCitation::form() const
{
- if( dialog_ && dialog_->form_citation )
+ if( dialog_ ) // no need to test for dialog_->citation
return dialog_->form_citation;
else
return 0;
keys = frontStrip( split(keys, tmp, ',') );
}
- fl_freeze_form( dialog_->form_citation );
-
updateBrowser( dialog_->bibBrsr, bibkeys );
updateBrowser( dialog_->citeBrsr, citekeys );
fl_clear_browser( dialog_->infoBrsr );
setSize( size, bibPresent );
fl_set_input( dialog_->textAftr, params.getOptions().c_str() );
-
- fl_unfreeze_form( dialog_->form_citation );
}
if( inset_ != 0 )
{
// Only update if contents have changed
- if( params.getCmdName() != inset_->getCmdName() ||
- params.getContents() != inset_->getContents() ||
- params.getOptions() != inset_->getOptions() ) {
+ if( params != inset_->params() ) {
inset_->setParams( params );
lv_->view()->updateInset( inset_, true );
}
*/
class FormCitation : public FormCommand {
public:
+ /**@name Constructors and Destructors */
+ //@{
+ ///
+ FormCitation(LyXView *, Dialogs *);
+ ///
+ ~FormCitation();
+ //@}
+
+private:
///
enum State {
DOWN,
ON,
OFF
};
- /**@name Constructors and Destructors */
- //@{
- /// #FormCitation x(LyXFunc ..., Dialogs ...);#
- FormCitation(LyXView *, Dialogs *);
- ///
- ~FormCitation();
- //@}
-
-private:
/// Build the dialog
virtual void build();
/// Filter the inputs
/// Real GUI implementation.
FD_form_citation * dialog_;
+ ///
+ std::vector<string> citekeys;
+ ///
+ std::vector<string> bibkeys;
+ ///
+ std::vector<string> bibkeysInfo;
};
#endif
void FormIndex::build()
{
dialog_ = build_index();
+
+ int w = form()->w;
+ int h = form()->h;
+
+ fl_set_form_minsize(form(), w, h);
+ fl_set_form_maxsize(form(), 2*w, h);
}
FL_FORM * const FormIndex::form() const
{
- if( dialog_ && dialog_->form_index )
+ if( dialog_ ) // no need to test for dialog_->form_index
return dialog_->form_index;
else
return 0;
void FormIndex::update()
{
- static int ow = -1, oh;
-
- if (ow < 0) {
- ow = dialog_->form_index->w;
- oh = dialog_->form_index->h;
-
- fl_set_form_minsize(dialog_->form_index, ow, oh);
- fl_set_form_maxsize(dialog_->form_index, 2*ow, oh);
- }
-
- fl_freeze_form( dialog_->form_index );
-
fl_set_input(dialog_->key, params.getContents().c_str());
if( lv_->buffer()->isReadonly() ) {
fl_activate_object( dialog_->ok );
fl_set_object_lcol( dialog_->ok, FL_BLACK );
}
-
- fl_unfreeze_form( dialog_->form_index );
}
if( inset_ != 0 )
{
// Only update if contents have changed
- if( params.getContents() != inset_->getContents() ) {
+ if( params != inset_->params() ) {
inset_->setParams( params );
lv_->view()->updateInset( inset_, true );
}
#include "Dialogs.h"
#include "FormToc.h"
#include "LyXView.h"
-#include "buffer.h"
#include "form_toc.h"
#include "lyxtext.h"
-static vector<Buffer::TocItem> toclist;
-
FormToc::FormToc(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Table of Contents")), dialog_(0)
{
dialog_ = build_toc();
fl_addto_choice(dialog_->type,
_(" TOC | LOF | LOT | LOA "));
+
+ // Don't need to limit size of this dialog
}
FL_FORM * const FormToc::form() const
{
- if( dialog_ && dialog_->form_toc )
+ if( dialog_ ) // no need to test for dialog_->form_toc
return dialog_->form_toc;
else
return 0;
void FormToc::update()
{
- static int ow = -1, oh;
-
- if (ow < 0) {
- ow = form()->w;
- oh = form()->h;
-
- fl_set_form_minsize(form(), ow, oh);
- fl_set_form_maxsize(form(), 2*ow, oh);
- }
-
Buffer::TocType type;
if( params.getCmdName() == "tableofcontents" )
#endif
#include "FormCommand.h"
+#include "buffer.h"
struct FD_form_toc;
/** This class provides an XForms implementation of the FormToc Dialog.
/// Real GUI implementation.
FD_form_toc * dialog_;
+ ///
+ std::vector<Buffer::TocItem> toclist;
};
#endif
void FormUrl::build()
{
dialog_ = build_url();
+
+ int w = form()->w;
+ int h = form()->h;
+
+ fl_set_form_minsize(form(), w, h);
+ fl_set_form_maxsize(form(), 2*w, h);
}
FL_FORM * const FormUrl::form() const
{
- if( dialog_ && dialog_->form_url )
+ if( dialog_ ) // no need to test for dialog_->form_url
return dialog_->form_url;
else
return 0;
void FormUrl::update()
{
- 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);
- }
-
- fl_freeze_form( dialog_->form_url );
-
fl_set_input(dialog_->url, params.getContents().c_str());
fl_set_input(dialog_->name, params.getOptions().c_str());
fl_activate_object( dialog_->ok );
fl_set_object_lcol( dialog_->ok, FL_BLACK );
}
-
- fl_unfreeze_form( dialog_->form_url );
}
if( inset_ != 0 )
{
// Only update if contents have changed
- if( params.getCmdName() != inset_->getCmdName() ||
- params.getContents() != inset_->getContents() ||
- params.getOptions() != inset_->getOptions() ) {
+ if( params != inset_->params() ) {
inset_->setParams( params );
lv_->view()->updateInset( inset_, true );
}
}
-InsetBibKey::InsetBibKey(string const & key, string const & label)
- : InsetCommand("bibitem", key, label)
+InsetBibKey::InsetBibKey(InsetCommandParams const & p)
+ : InsetCommand(p)
{
counter = 1;
- if (key.empty())
- setCmdName(" ");
-}
-
-
-InsetBibKey::InsetBibKey(InsetBibKey const * b)
- : InsetCommand("bibitem", b->getContents(), b->getOptions())
-{
- counter = b->counter;
}
}
+Inset * InsetBibKey::Clone() const
+{
+ InsetBibKey * b = new InsetBibKey(params());
+ b->setCounter(counter);
+ return b;
+}
+
+
void InsetBibKey::callback( FD_bibitem_form * form, long data )
{
switch (data) {
}
-InsetBibtex::InsetBibtex(string const & dbase, string const & style,
- Buffer * o)
- : InsetCommand("BibTeX", dbase, style), owner(o)
+InsetBibtex::InsetBibtex(InsetCommandParams const & p, Buffer * o)
+ : InsetCommand(p), owner(o)
{}
#pragma interface
#endif
-#include "insetcommand.h"
#include <vector>
+#include "insetcommand.h"
class Buffer;
struct FD_bibitem_form;
class InsetBibKey : public InsetCommand {
public:
///
- InsetBibKey() : InsetCommand("bibitem") { counter = 1; }
- ///
- explicit
- InsetBibKey(string const & key, string const & label = string());
- ///
- explicit
- InsetBibKey(InsetBibKey const *);
+ InsetBibKey(InsetCommandParams const &);
///
~InsetBibKey();
///
- Inset * Clone() const { return new InsetBibKey(this); }
+ Inset * Clone() const;
/** Currently \bibitem is used as a LyX2.x command,
so we need this method.
*/
*/
class InsetBibtex : public InsetCommand {
public:
- ///
- InsetBibtex() : InsetCommand("BibTeX") { owner = 0; }
///
- InsetBibtex(string const & dbase, string const & style,
- Buffer *);
+ InsetBibtex(InsetCommandParams const &, Buffer *);
///
~InsetBibtex();
-
- ///
- Inset * Clone() const {
- return new InsetBibtex(getContents(), getOptions(), owner);
- }
///
- Inset::Code LyxCode() const
- {
- return Inset::BIBTEX_CODE;
- }
+ Inset * Clone() const { return new InsetBibtex(params(), owner); }
///
string getScreenLabel() const;
///
+ EDITABLE Editable() const { return IS_EDITABLE; }
+ ///
+ Inset::Code LyxCode() const { return Inset::BIBTEX_CODE; }
+ ///
void Edit(BufferView *, int x, int y, unsigned int button);
///
int Latex(Buffer const *, std::ostream &,
bool fragile, bool freespace) const;
///
std::vector<std::pair<string,string> > getKeys() const;
- ///
- EDITABLE Editable() const {
- return IS_EDITABLE;
- }
///
bool addDatabase(string const &);
///
#endif
#include "insetcommand.h"
-#include "support/utility.hpp"
/** Used to insert citations
*/
-class InsetCitation : public InsetCommand, public noncopyable {
+class InsetCitation : public InsetCommand {
public:
///
InsetCitation(InsetCommandParams const &);
}
-InsetCommand::InsetCommand()
-{}
-
-
-InsetCommand::InsetCommand( string const & n,
- string const & c,
- 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 )
+bool InsetCommandParams::operator==(InsetCommandParams const & o) const
{
- p_.setCmdName( p.getCmdName() );
- p_.setContents( p.getContents() );
- p_.setOptions( p.getOptions() );
+ if( cmdname != o.cmdname ) return false;
+ if( contents != o.contents ) return false;
+ if( options != o.options ) return false;
+ return true;
}
-// In lyxf3 this will be just LaTeX
-void InsetCommand::Write(Buffer const *, ostream & os) const
+bool InsetCommandParams::operator!=(InsetCommandParams const & o) const
{
- os << "LatexCommand " << getCommand() << "\n";
+ if( cmdname != o.cmdname ) return true;
+ if( contents != o.contents ) return true;
+ if( options != o.options ) return true;
+ return false;
}
-void InsetCommand::scanCommand(string const & cmd)
+void InsetCommandParams::scanCommand(string const & cmd)
{
string tcmdname, toptions, tcontents;
// This function will not be necessary when lyx3
-void InsetCommand::Read(Buffer const *, LyXLex & lex)
+void InsetCommandParams::Read(LyXLex & lex)
{
string token;
}
+void InsetCommandParams::Write(ostream & os) const
+{
+ os << "LatexCommand " << getCommand() << "\n";
+}
+
+
+string InsetCommandParams::getCommand() const
+{
+ string s;
+ if (!getCmdName().empty()) s += "\\"+getCmdName();
+ if (!getOptions().empty()) s += "["+getOptions()+']';
+ s += "{"+getContents()+'}';
+ return s;
+}
+
+
+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() );
+}
+
+
int InsetCommand::Latex(Buffer const *, ostream & os,
bool /*fragile*/, bool/*fs*/) const
{
{
return 0;
}
-
-
-Inset * InsetCommand::Clone() const
-{
- return new InsetCommand(getCmdName(), getContents(), getOptions());
-}
-
-
-string InsetCommand::getCommand() const
-{
- string s;
- if (!getCmdName().empty()) s += "\\"+getCmdName();
- if (!getOptions().empty()) s += "["+getOptions()+']';
- s += "{"+getContents()+'}';
- return s;
-}
#include "insetbutton.h"
#include <sigc++/signal_system.h>
+#include "support/utility.hpp"
#ifdef SIGC_CXX_NAMESPACES
using SigC::Signal0;
string const & c = string(),
string const & o = string());
///
+ bool operator==(InsetCommandParams const &) const;
+ ///
+ bool operator!=(InsetCommandParams const &) const;
+ ///
+ void Read(LyXLex &);
+ /// Parse the command
+ void scanCommand(string const &);
+ ///
+ void Write(std::ostream &) const;
+ /// Build the complete LaTeX command
+ string getCommand() const;
+ ///
string const & getCmdName() const { return cmdname; }
///
string const & getOptions() const { return options; }
string getAsString() const;
///
void setFromString( string const & );
-
private:
///
string cmdname;
};
-class InsetCommand : public InsetButton {
+class InsetCommand : public InsetButton, public noncopyable {
public:
- ///
- InsetCommand();
- ///
- explicit
- InsetCommand(string const & n,
- string const & c = string(),
- string const & o = string());
- ///
explicit
InsetCommand(InsetCommandParams const &);
///
virtual ~InsetCommand() { hide(); };
///
- void Write(Buffer const *, std::ostream &) const;
-
- /// Parse the command.
- void scanCommand(string const & cmd);
+ void Write(Buffer const *, std::ostream & os) const
+ { p_.Write( os ); }
///
- virtual void Read(Buffer const *, LyXLex & lex);
+ virtual void Read(Buffer const *, LyXLex & lex)
+ { p_.Read( lex ); }
+ /// Can remove one InsetBibKey is modified
+ void scanCommand(string const & c) { p_.scanCommand( c ); };
///
virtual int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
///
virtual int DocBook(Buffer const *, std::ostream &) const;
///
- Inset * Clone() const;
- ///
- Inset::Code LyxCode() const
- {
- return Inset::NO_CODE;
- }
+ Inset::Code LyxCode() const { return Inset::NO_CODE; }
/** Get the label that appears at screen.
confusion with lyxinset::getLabel(int), but I've seen that
it wasn't. I hope you never confuse again both methods. (ale)
*/
- virtual string getScreenLabel() const { return getCommand(); }
- /// Build the complete LaTeX command
- string getCommand() const;
+ virtual string getScreenLabel() const = 0;
+ ///
+ string getCommand() const { return p_.getCommand(); }
///
string const & getCmdName() const { return p_.getCmdName(); }
///
}
-InsetInclude::InsetInclude(string const & fname, Buffer * bf)
- : InsetCommand("include")
+InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer * bf)
+ : InsetCommand(p), master(bf)
{
- master = bf;
- setContents(fname);
flag = InsetInclude::INCLUDE;
noload = false;
include_label = unique_id();
Inset * InsetInclude::Clone() const
{
- InsetInclude * ii = new InsetInclude (getContents(), master);
+ InsetInclude * ii = new InsetInclude (params(), master);
ii->setNoLoad(isNoLoad());
// By default, the newly created inset is of `include' type,
// so we do not test this case.
*/
class InsetInclude: public InsetCommand {
public:
-#if 0
///
- InsetInclude(): InsetCommand("include")
- {
- flag = InsetInclude::INCLUDE;
- }
-#endif
- ///
- InsetInclude(string const &, Buffer *);
+ InsetInclude(InsetCommandParams const &, Buffer *);
///
~InsetInclude();
///
#endif
#include "insetcommand.h"
-#include "support/utility.hpp"
struct LaTeXFeatures;
/** Used to insert index labels
*/
-class InsetIndex : public InsetCommand, public noncopyable {
+class InsetIndex : public InsetCommand {
public:
///
InsetIndex(InsetCommandParams const &);
};
-class InsetPrintIndex : public InsetCommand, public noncopyable {
+class InsetPrintIndex : public InsetCommand {
public:
///
InsetPrintIndex(InsetCommandParams const &);
/* Label. Used to insert a label automatically */
-InsetLabel::InsetLabel(string const & cmd)
-{
- scanCommand(cmd);
-}
-
-
-Inset * InsetLabel::Clone() const
-{
- return new InsetLabel(getCommand());
-}
+InsetLabel::InsetLabel(InsetCommandParams const & p)
+ : InsetCommand(p)
+{}
vector<string> InsetLabel::getLabelList() const
#endif
#include "insetcommand.h"
-#include "LString.h"
-///
class InsetLabel : public InsetCommand {
public:
///
- explicit
- InsetLabel(string const & cmd);
+ InsetLabel(InsetCommandParams const &);
///
- InsetLabel() : InsetCommand("label") {}
- ///
- Inset * Clone() const;
- ///
- Inset::Code LyxCode() const { return Inset::LABEL_CODE; }
- ///
- std::vector<string> getLabelList() const;
+ Inset * Clone() const { return new InsetLabel(params()); }
///
string getScreenLabel() const { return getContents(); }
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
+ Inset::Code LyxCode() const { return Inset::LABEL_CODE; }
+ ///
void Edit(BufferView *, int, int, unsigned int);
///
+ std::vector<string> getLabelList() const;
+ ///
int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
///
using std::ostream;
-InsetParent::InsetParent(string const & fn, Buffer * owner)
- : InsetCommand("lyxparent")
+InsetParent::InsetParent(InsetCommandParams const & p, Buffer * bf)
+ : InsetCommand(p)
{
- if (owner)
- setContents(MakeAbsPath(fn, OnlyPath(owner->fileName())));
+ string fn = p.getContents();
+ if (bf)
+ setContents(MakeAbsPath(fn, OnlyPath(bf->fileName())));
else
setContents(fn);
}
*/
class InsetParent : public InsetCommand {
public:
- /// Non-standard LyX macro
- InsetParent() : InsetCommand("lyxparent") {}
///
- explicit
- InsetParent(string const & fn, Buffer * owner = 0);
- ///
- int Latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
- ///
- Inset * Clone() const { return new InsetParent(getContents()); }
+ InsetParent(InsetCommandParams const &, Buffer * owner = 0);
+ ///
+ Inset * Clone() const { return new InsetParent(params()); }
///
string getScreenLabel() const;
///
- void Edit(BufferView *, int, int, unsigned int);
- ///
- EDITABLE Editable() const {
- return IS_EDITABLE;
- }
+ EDITABLE Editable() const { return IS_EDITABLE; }
///
Inset::Code LyxCode() const { return Inset::PARENT_CODE; }
///
+ void Edit(BufferView *, int, int, unsigned int);
+ ///
+ int Latex(Buffer const *, std::ostream &,
+ bool fragile, bool free_spc) const;
+ ///
void setParent(string fn) { setContents(fn); }
};
#endif
extern BufferView * current_view;
-InsetRef::InsetRef(string const & cmd, Buffer * bf)
- : master(bf)
+InsetRef::InsetRef(InsetCommandParams const & p, Buffer * bf)
+ : InsetCommand(p), master(bf)
{
- scanCommand(cmd);
GenerateFlag();
}
-
-InsetRef::InsetRef(InsetCommand const & inscmd, Buffer * bf)
- : master(bf)
-{
- setCmdName(inscmd.getCmdName());
- setContents(inscmd.getContents());
- setOptions(inscmd.getOptions());
- GenerateFlag();
-}
-
-
void InsetRef::GenerateFlag()
{
if (getCmdName() == "ref")
if(getOptions().empty())
os << escape(getCommand());
else {
- string ns;
- InsetCommand clone(getCmdName(),
- getContents(), ns);
- os << escape(clone.getCommand());
+ InsetCommandParams p( getCmdName(), getContents(), "" );
+ os << escape(p.getCommand());
}
return 0;
}
break;
}
}
+
+
+void InsetRef::gotoLabel()
+{
+ if (master) {
+ master->getUser()->gotoLabel(getContents());
+ }
+}
#endif
#include "insetcommand.h"
-#include "buffer.h"
+class Buffer;
struct LaTeXFeatures;
/** The reference inset
};
///
- InsetRef() : InsetCommand("ref") { flag = InsetRef::REF; }
+ InsetRef(InsetCommandParams const &, Buffer *);
///
- InsetRef(string const &, Buffer *);
+ Inset * Clone() const { return new InsetRef(params(), master); }
///
- InsetRef(InsetCommand const &, Buffer *);
- ///
- Inset * Clone() const {
- return new InsetRef (getCommand(), master);
- }
+ string getScreenLabel() const;
+ ///
+ EDITABLE Editable() const { return IS_EDITABLE; }
///
Inset::Code LyxCode() const { return Inset::REF_CODE; }
///
void Edit(BufferView *, int, int, unsigned int);
- ///
- EDITABLE Editable() const {
- return IS_EDITABLE;
- }
///
bool display() const { return false; }
///
- string getScreenLabel() const;
- ///
void Toggle();
///
void gotoLabel();
///
Buffer * master;
};
-
-
-inline
-void InsetRef::gotoLabel()
-{
- if (master) {
- master->getUser()->gotoLabel(getContents());
- }
-}
#endif
#endif
#include "insetcommand.h"
-#include "support/utility.hpp"
/** Used to insert table of contents
*/
-class InsetTOC : public InsetCommand, public noncopyable {
+class InsetTOC : public InsetCommand {
public:
///
InsetTOC(InsetCommandParams const & p) : InsetCommand(p) {}
#endif
#include "insetcommand.h"
-#include "support/utility.hpp"
struct LaTeXFeatures;
/** The url inset
*/
-class InsetUrl : public InsetCommand, public noncopyable {
+class InsetUrl : public InsetCommand {
public:
///
explicit
}
}
if (!label.empty()) {
- InsetLabel * new_inset = new InsetLabel;
- new_inset->setContents(label);
- current_view->insertInset(new_inset);
+ InsetCommandParams p( "label", label );
+ InsetLabel * inset = new InsetLabel( p );
+ current_view->insertInset( inset );
}
AllowInput(current_view);
}
return;
}
- static string const commands[5]
- = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
- "\\prettyref"};
- string t = commands[data];
-
+ static string const cmdname[5]
+ = { "ref", "pageref", "vref", "vpageref", "prettyref"};
+ InsetCommandParams p( cmdname[data] );
+ p.setContents( s );
+
if (current_view->buffer()->isSGML())
- t += "[" + u + "]" + "{" + s + "}";
- else
- t += "{" + s + "}";
+ p.setOptions( u );
- Inset * new_inset =
- new InsetRef(t, current_view->buffer());
- current_view->insertInset(new_inset);
+ Inset * inset = new InsetRef( p, current_view->buffer() );
+ current_view->insertInset( inset );
}
// ale970405+lasgoutt970425
// The argument can be up to two tokens separated
// by a space. The first one is the bibstyle.
- string lsarg(argument);
- string bibstyle = token(lsarg, ' ', 1);
+ string db = token(argument, ' ', 0);
+ string bibstyle = token(argument, ' ', 1);
if (bibstyle.empty())
bibstyle = "plain";
- InsetBibtex * new_inset
- = new InsetBibtex(token(lsarg, ' ', 0),
- bibstyle,
- owner->buffer());
+
+ InsetCommandParams p( "BibTeX", db, bibstyle );
+ InsetBibtex * inset = new InsetBibtex(p, owner->buffer());
- if (owner->view()->insertInset(new_inset)) {
- if (lsarg.empty())
- new_inset->Edit(owner->view(), 0, 0, 0);
+ if (owner->view()->insertInset(inset)) {
+ if (argument.empty())
+ inset->Edit(owner->view(), 0, 0, 0);
} else
- delete new_inset;
+ delete inset;
}
break;
break;
case LFUN_INDEX_CREATE:
- case LFUN_INDEX_CREATE_LAST:
{
- // Can't do that at the beginning of a paragraph.
- if (owner->view()->text->cursor.pos() - 1 < 0)
- break;
-
InsetCommandParams p( "index" );
- if (!argument.empty()) {
- p.setContents( argument );
- } else {
- //get the current word for an argument
- LyXParagraph::size_type lastpos =
+ if( argument.empty() ) {
+ // Get the word immediately preceding the cursor
+ LyXParagraph::size_type curpos =
owner->view()->text->cursor.pos() - 1;
- // Get the current word. note that this must be done
- // before inserting the inset, or the inset will
- // break the word
- string curstring(owner->view()
- ->text->cursor.par()->GetWord(lastpos));
- //make the new inset and write the current word into it
+ string curstring;
+ if( curpos >= 0 )
+ curstring = owner->view()->text
+ ->cursor.par()->GetWord(curpos);
+
p.setContents( curstring );
+ } else {
+ p.setContents( argument );
}
owner->getDialogs()->createIndex( p.getAsString() );
{
InsetCommandParams p;
p.setFromString( argument );
+ InsetIndex * inset = new InsetIndex( p );
+
+ if (!owner->view()->insertInset(inset))
+ delete inset;
+ else
+ owner->view()->updateInset( inset, true );
+ }
+ break;
+
+ case LFUN_INDEX_INSERT_LAST:
+ {
+ // Get word immediately preceding the cursor
+ LyXParagraph::size_type curpos =
+ owner->view()->text->cursor.pos() - 1;
+ // Can't do that at the beginning of a paragraph
+ if( curpos < 0 ) break;
+
+ string curstring( owner->view()->text
+ ->cursor.par()->GetWord(curpos) );
+ InsetCommandParams p( "index", curstring );
InsetIndex * inset = new InsetIndex( p );
+
if (!owner->view()->insertInset(inset))
delete inset;
else
case LFUN_INDEX_PRINT:
{
- InsetCommandParams p("printindex");
+ InsetCommandParams p( "printindex" );
Inset * inset = new InsetPrintIndex(p);
if (!owner->view()->insertInset(inset, "Standard", true))
delete inset;
case LFUN_PARENTINSERT:
{
lyxerr << "arg " << argument << endl;
- Inset * new_inset = new InsetParent(argument, owner->buffer());
- if (!owner->view()->insertInset(new_inset, "Standard", true))
- delete new_inset;
+ InsetCommandParams p( "lyxparent", argument );
+ Inset * inset = new InsetParent(p, owner->buffer());
+ if (!owner->view()->insertInset(inset, "Standard", true))
+ delete inset;
}
break;
case LFUN_CHILDINSERT:
{
- Inset * new_inset = new InsetInclude(argument,
- owner->buffer());
- if (owner->view()->insertInset(new_inset, "Standard", true))
- new_inset->Edit(owner->view(), 0, 0, 0);
+ InsetCommandParams p( "Include", argument );
+ Inset * inset = new InsetInclude(p, owner->buffer());
+ if (owner->view()->insertInset(inset, "Standard", true))
+ inset->Edit(owner->view(), 0, 0, 0);
else
- delete new_inset;
+ delete inset;
}
break;
men->_view->getLyXFunc()->Dispatch(LFUN_REFGOTO,
label_list[num].c_str());
else {
- static string const commands[5]
- = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
- "\\prettyref"};
- string t = commands[type] + "{" + label_list[num] + "}";
- men->currentView()->insertInset(new InsetRef(t, buffer));
+ static string const cmdname[5]
+ = { "ref", "pageref", "vref", "vpageref", "prettyref"};
+ InsetCommandParams p( cmdname[type] );
+ p.setContents( label_list[num] );
+ men->currentView()->insertInset(new InsetRef(p, buffer));
}
}
case 14: tmpfunc->Dispatch(LFUN_INSERT_REF); break;
case 15: tmpfunc->Dispatch(LFUN_CITATION_CREATE); break;
case 16: tmpfunc->Dispatch(LFUN_INDEX_CREATE); break;
- case 17: tmpfunc->Dispatch(LFUN_INDEX_CREATE_LAST); break;
+ case 17: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
case 18: tmpfunc->Dispatch(LFUN_URL); break;
}
}
result->inset_owner = inset_owner;
// ale970302
- result->bibkey = (bibkey) ? new InsetBibKey(bibkey): 0;
-
+ if (bibkey)
+ result->bibkey = static_cast<InsetBibKey *>(bibkey->Clone());
+ else
+ result->bibkey = 0;
// copy everything behind the break-position to the new paragraph
#include <config.h>
-// $Id: strerror.c,v 1.2 1999/10/02 16:21:10 larsbj Exp $
+/* $Id: strerror.c,v 1.3 2000/08/04 13:12:30 lasgouttes Exp $ */
#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: strerror.c,v 1.2 1999/10/02 16:21:10 larsbj Exp $";
+static char vcid[] = "$Id: strerror.c,v 1.3 2000/08/04 13:12:30 lasgouttes Exp $";
#endif /* lint */
extern int sys_nerr ;
void TexRow::getIdFromRow(int row, int & id, int & pos) const
{
- RowList::const_iterator cit = rowlist.begin();
- RowList::const_iterator end = rowlist.end();
+ RowList::iterator cit = rowlist.begin();
+ RowList::iterator end = rowlist.end();
for (; cit != end; ++cit) {
if ((*cit).rownumber() == row) break;
}
int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth;
par->incCounter(i);
int number = par->getCounter(i);
- if (!par->bibkey)
- par->bibkey = new InsetBibKey();
+ if (!par->bibkey) {
+ InsetCommandParams p( "bibitem" );
+ par->bibkey = new InsetBibKey(p);
+ }
par->bibkey->setCounter(number);
par->labelstring = layout.labelstring();