1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of*
|
1999-11-15 10:58:38 +00:00
|
|
|
* ======================================================
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-02-10 17:53:36 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 10:58:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef INSET_LATEXCOMMAND_H
|
|
|
|
#define INSET_LATEXCOMMAND_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "insetbutton.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Created by Alejandro 970222
|
|
|
|
/** Used to insert a LaTeX command automatically
|
|
|
|
*
|
|
|
|
* Similar to InsetLaTeX but having control of the basic structure of a
|
|
|
|
* LaTeX command: \name[options]{contents}.
|
|
|
|
*/
|
2000-07-15 23:51:46 +00:00
|
|
|
class InsetCommand : public InsetButton {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetCommand();
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
explicit
|
1999-10-02 16:21:10 +00:00
|
|
|
InsetCommand(string const & name, string const & arg = string(),
|
|
|
|
string const & opt = string());
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void Write(Buffer const *, std::ostream &) const;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Parse the command.
|
1999-11-04 01:40:20 +00:00
|
|
|
void scanCommand(string const & cmd);
|
2000-07-13 09:38:34 +00:00
|
|
|
///
|
|
|
|
virtual void Read(Buffer const *, LyXLex & lex);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
virtual int Latex(Buffer const *, std::ostream &,
|
2000-04-19 01:42:55 +00:00
|
|
|
bool fragile, bool free_spc) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int Ascii(Buffer const *, std::ostream &) const;
|
2000-04-24 20:58:23 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
virtual int Linuxdoc(Buffer const *, std::ostream &) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
virtual int DocBook(Buffer const *, std::ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-24 22:14:46 +00:00
|
|
|
Inset * Clone() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
Inset::Code LyxCode() const
|
|
|
|
{
|
|
|
|
return Inset::NO_CODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the label that appears at screen.
|
|
|
|
|
|
|
|
I thought it was enough to eliminate the argument to avoid
|
|
|
|
confusion with lyxinset::getLabel(int), but I've seen that
|
|
|
|
it wasn't. I hope you never confuse again both methods. (ale)
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string getScreenLabel() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return getCommand();
|
|
|
|
}
|
2000-06-07 08:53:40 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Build the complete LaTeX command
|
1999-10-02 16:21:10 +00:00
|
|
|
string getCommand() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
string const & getCmdName() const {
|
2000-06-07 08:53:40 +00:00
|
|
|
return cmdname;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
string const & getOptions() const {
|
1999-09-27 18:44:28 +00:00
|
|
|
return options;
|
|
|
|
}
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
string const & getContents() const {
|
1999-09-27 18:44:28 +00:00
|
|
|
return contents;
|
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void setCmdName(string const & n) {
|
2000-06-07 08:53:40 +00:00
|
|
|
cmdname = n;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void setOptions(string const & o) {
|
1999-09-27 18:44:28 +00:00
|
|
|
options = o;
|
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual void setContents(string const & c) {
|
1999-09-27 18:44:28 +00:00
|
|
|
contents = c;
|
|
|
|
}
|
2000-06-07 08:53:40 +00:00
|
|
|
///
|
|
|
|
void addContents(string const & c) {
|
|
|
|
contents += c;
|
|
|
|
}
|
|
|
|
private:
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-07 08:53:40 +00:00
|
|
|
string cmdname;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string options;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string contents;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|