Move the findInfo() and defaultCommand() routines out of InsetCommand and into its subclasses, so that the subclasses know what parameters they want, etc. Also, introduce an "isCompatibleCommand()" routine, so the subclasses can tell us which commands they are prepared to accept.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21194 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2007-10-25 04:13:56 +00:00
parent e52c1ed1f9
commit 07b6198f4c
27 changed files with 472 additions and 162 deletions

View File

@ -47,6 +47,15 @@ InsetBibitem::InsetBibitem(InsetCommandParams const & p)
}
CommandInfo const * InsetBibitem::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"label", "key", ""};
static const bool isoptional[] = {true, false};
static const CommandInfo info = {2, paramnames, isoptional};
return &info;
}
Inset * InsetBibitem::clone() const
{
InsetBibitem * b = new InsetBibitem(params());

View File

@ -45,7 +45,13 @@ public:
BiblioInfo &, InsetIterator const &) const;
/// Update the counter of this inset
virtual void updateLabels(Buffer const &, ParIterator const &);
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "bibitem"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "bibitem"; }
protected:
///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);

View File

@ -78,6 +78,16 @@ InsetBibtex::InsetBibtex(InsetCommandParams const & p)
{}
CommandInfo const * InsetBibtex::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] =
{"options", "btprint", "bibfiles", ""};
static const bool isoptional[] = {true, true, false};
static const CommandInfo info = {3, paramnames, isoptional};
return &info;
}
Inset * InsetBibtex::clone() const
{
return new InsetBibtex(*this);

View File

@ -48,6 +48,13 @@ public:
bool delDatabase(std::string const &);
///
void validate(LaTeXFeatures &) const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "bibtex"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "bibtex"; }
protected:
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
private:

View File

@ -75,14 +75,7 @@ vector<string> const & possible_cite_commands()
}
bool is_possible_cite_command(string const & input)
{
vector<string> const & possibles = possible_cite_commands();
vector<string>::const_iterator const end = possibles.end();
return std::find(possibles.begin(), end, input) != end;
}
//FIXME See the header for the issue.
string const default_cite_command(biblio::CiteEngine engine)
{
string str;
@ -108,7 +101,7 @@ string const
asValidLatexCommand(string const & input, biblio::CiteEngine const engine)
{
string const default_str = default_cite_command(engine);
if (!is_possible_cite_command(input))
if (!InsetCitation::isCompatibleCommand(input))
return default_str;
string output;
@ -395,6 +388,28 @@ InsetCitation::InsetCitation(InsetCommandParams const & p)
{}
CommandInfo const * InsetCitation::findInfo(std::string const & /* cmdName */)
{
// standard cite does only take one argument if jurabib is
// not used, but jurabib extends this to two arguments, so
// we have to allow both here. InsetCitation takes care that
// LaTeX output is nevertheless correct.
static const char * const paramnames[] =
{"after", "before", "key", ""};
static const bool isoptional[] = {true, true, false};
static const CommandInfo info = {3, paramnames, isoptional};
return &info;
}
bool InsetCitation::isCompatibleCommand(std::string const & cmd)
{
vector<string> const & possibles = possible_cite_commands();
vector<string>::const_iterator const end = possibles.end();
return std::find(possibles.begin(), end, cmd) != end;
}
docstring const InsetCitation::generateLabel(Buffer const & buffer) const
{
docstring const before = getParam("before");

View File

@ -49,7 +49,16 @@ public:
OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
///
static CommandInfo const * findInfo(std::string const &);
//FIXME This is the locus of the design problem we have.
//It really ought to do what default_cite_command() does,
//but to do that it needs to know what CiteEngine we are
//using.
///
static std::string defaultCommand() { return "cite"; };
///
static bool isCompatibleCommand(std::string const & cmd);
private:
virtual Inset * clone() const
{

View File

@ -58,8 +58,7 @@ public:
InsetCommandParams const & params() const { return p_; }
/// FIXME Remove
docstring const getFirstNonOptParam() const { return p_.getFirstNonOptParam(); }
public:
/// tell that the button label should be recomputed.
/// Whether the button label should be recomputed.
void refresh() { updateButtonLabel_ = true; }
///
void setParam(std::string const & name, docstring const & value)
@ -78,6 +77,15 @@ public:
RenderButton & button() const { return button_; }
///
bool setMouseHover(bool mouse_hover);
/// Return parameter information for command cmdName.
/// Not implemented here. Must be implemented in derived class.
static CommandInfo const * findInfo(std::string const & cmdName);
/// Return default command for this inset.
/// Not implemented here. Must be implemented in derived class.
static std::string defaultCommand();
/// Whether this is a command this inset can represent.
/// Not implemented here. Must be implemented in derived class.
static bool isCompatibleCommand(std::string const & cmd);
protected:
///

View File

@ -5,6 +5,7 @@
*
* \author Angus Leeming
* \author Georg Baum
* \author Richard Heck
*
* Full author contact details are available in file CREDITS.
*/
@ -13,6 +14,19 @@
#include "InsetCommandParams.h"
#include "InsetBibitem.h"
#include "InsetBibtex.h"
#include "InsetCitation.h"
#include "InsetFloatList.h"
#include "InsetHFill.h"
#include "InsetHyperlink.h"
#include "InsetInclude.h"
#include "InsetIndex.h"
#include "InsetLabel.h"
#include "InsetNomencl.h"
#include "InsetRef.h"
#include "InsetTOC.h"
#include "debug.h"
#include "gettext.h"
#include "Lexer.h"
@ -34,6 +48,26 @@ using std::ostream;
using support::ExceptionMessage;
using support::WarningException;
ICPInfo::ICPInfo(std::string const & s, bool b)
: paramName(s), optional(b)
{}
void ICPList::addParam(std::string const & s, bool b) {
plist_.push_back(ICPInfo(s, b));
}
bool ICPList::hasParam(std::string const & s) {
PList::const_iterator it = begin();
PList::const_iterator et = end();
for (; it != et; ++it) {
if (it->paramName == s)
return true;
}
return false;
}
InsetCommandParams::InsetCommandParams(InsetCode code)
: insetCode_(code), preview_(false)
@ -55,101 +89,38 @@ InsetCommandParams::InsetCommandParams(InsetCode code,
}
//FIXME This should go into the Insets themselves...so they will tell
//us what parameters they want.
//Should this just vanish in favor of the two arg version, or is there
//a reason to use it in some cases? What should happen in the single
//arg case, then? Maybe use the default? or leave that up to the inset?
InsetCommandParams::CommandInfo const *
InsetCommandParams::findInfo(InsetCode code)
CommandInfo const * InsetCommandParams::findInfo(
InsetCode code, std::string const & cmdName)
{
// No parameter may be named "preview", because that is a required
// flag for all commands.
switch (code) {
case BIBITEM_CODE: {
static const char * const paramnames[] = {"label", "key", ""};
static const bool isoptional[] = {true, false};
static const CommandInfo info = {2, paramnames, isoptional};
return &info;
}
case BIBTEX_CODE: {
static const char * const paramnames[] =
{"options", "btprint", "bibfiles", ""};
static const bool isoptional[] = {true, true, false};
static const CommandInfo info = {3, paramnames, isoptional};
return &info;
}
case CITE_CODE: {
// standard cite does only take one argument if jurabib is
// not used, but jurabib extends this to two arguments, so
// we have to allow both here. InsetCitation takes care that
// LaTeX output is nevertheless correct.
static const char * const paramnames[] =
{"after", "before", "key", ""};
static const bool isoptional[] = {true, true, false};
static const CommandInfo info = {3, paramnames, isoptional};
return &info;
}
case FLOAT_LIST_CODE: {
static const char * const paramnames[] = {"type", ""};
static const bool isoptional[] = {false};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
case HFILL_CODE: {
static const char * const paramnames[] = {""};
static const CommandInfo info = {0, paramnames, 0};
return &info;
}
case HYPERLINK_CODE: {
static const char * const paramnames[] =
{"name", "target", ""};
static const bool isoptional[] = {true, false};
static const CommandInfo info = {2, paramnames, isoptional};
return &info;
}
case INCLUDE_CODE: {
//This is only correct for the case of listings, but it'll do for now.
//In the other cases, this second parameter should just be empty.
static const char * const paramnames[] = {"filename", "lstparams", ""};
static const bool isoptional[] = {false, true};
static const CommandInfo info = {2, paramnames, isoptional};
return &info;
}
case BIBITEM_CODE:
return InsetBibitem::findInfo(cmdName);
case BIBTEX_CODE:
return InsetBibtex::findInfo(cmdName);
case CITE_CODE:
return InsetCitation::findInfo(cmdName);
case FLOAT_LIST_CODE:
return InsetFloatList::findInfo(cmdName);
case HFILL_CODE:
return InsetHFill::findInfo(cmdName);
case HYPERLINK_CODE:
return InsetHyperlink::findInfo(cmdName);
case INCLUDE_CODE:
return InsetInclude::findInfo(cmdName);
case INDEX_CODE:
return InsetIndex::findInfo(cmdName);
case INDEX_PRINT_CODE:
case LABEL_CODE: {
static const char * const paramnames[] = {"name", ""};
static const bool isoptional[] = {false};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
case NOMENCL_CODE: {
static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
static const bool isoptional[] = {true, false, false};
static const CommandInfo info = {3, paramnames, isoptional};
return &info;
}
case NOMENCL_PRINT_CODE: {
static const char * const paramnames[] = {"labelwidth", ""};
static const bool isoptional[] = {true};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
case REF_CODE: {
static const char * const paramnames[] =
{"name", "reference", ""};
static const bool isoptional[] = {true, false};
static const CommandInfo info = {2, paramnames, isoptional};
return &info;
}
case TOC_CODE: {
static const char * const paramnames[] = {"type", ""};
static const bool isoptional[] = {false};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
return InsetPrintIndex::findInfo(cmdName);
case LABEL_CODE:
return InsetLabel::findInfo(cmdName);
case NOMENCL_CODE:
return InsetNomencl::findInfo(cmdName);
case NOMENCL_PRINT_CODE:
return InsetPrintNomencl::findInfo(cmdName);
case REF_CODE:
return InsetRef::findInfo(cmdName);
case TOC_CODE:
return InsetTOC::findInfo(cmdName);
default:
BOOST_ASSERT(false);
}
@ -157,56 +128,91 @@ InsetCommandParams::CommandInfo const *
}
//FIXME Will eventually call a static method, etc.
InsetCommandParams::CommandInfo const *
InsetCommandParams::findInfo(InsetCode code,
std::string const &/* cmdName*/)
{
return findInfo(code);
}
//FIXME Should call InsetBibitem::getDefaultCmd(), eg
std::string InsetCommandParams::getDefaultCmd(InsetCode code) {
switch (code) {
case BIBITEM_CODE:
return "bibitem";
return InsetBibitem::defaultCommand();
case BIBTEX_CODE:
return "bibtex"; //this is an unused dummy
return InsetBibtex::defaultCommand();
case CITE_CODE:
return "cite";
return InsetCitation::defaultCommand();
case FLOAT_LIST_CODE:
return "listoftables";
return InsetFloatList::defaultCommand();
case HFILL_CODE:
return "hfill";
return InsetHFill::defaultCommand();
case HYPERLINK_CODE:
return "href";
return InsetHyperlink::defaultCommand();
case INCLUDE_CODE:
return "include";
return InsetInclude::defaultCommand();
case INDEX_CODE:
return "index";
return InsetIndex::defaultCommand();
case INDEX_PRINT_CODE:
return "printindex";
return InsetPrintIndex::defaultCommand();
case LABEL_CODE:
return "label";
return InsetLabel::defaultCommand();
case NOMENCL_CODE:
return "nomenclature";
return InsetNomencl::defaultCommand();
case NOMENCL_PRINT_CODE:
return "printnomenclature";
return InsetPrintNomencl::defaultCommand();
case REF_CODE:
return "ref";
return InsetRef::defaultCommand();
case TOC_CODE:
return "tableofcontents";
return InsetTOC::defaultCommand();
default:
BOOST_ASSERT(false);
}
return "";
return string(); //silence the warning
}
bool InsetCommandParams::isCompatibleCommand(
InsetCode code, std::string const & s)
{
switch (code) {
case BIBITEM_CODE:
return InsetBibitem::isCompatibleCommand(s);
case BIBTEX_CODE:
return InsetBibtex::isCompatibleCommand(s);
case CITE_CODE:
return InsetCitation::isCompatibleCommand(s);
case FLOAT_LIST_CODE:
return InsetFloatList::isCompatibleCommand(s);
case HFILL_CODE:
return InsetHFill::isCompatibleCommand(s);
case HYPERLINK_CODE:
return InsetHyperlink::isCompatibleCommand(s);
case INCLUDE_CODE:
return InsetInclude::isCompatibleCommand(s);
case INDEX_CODE:
return InsetIndex::isCompatibleCommand(s);
case INDEX_PRINT_CODE:
return InsetPrintIndex::isCompatibleCommand(s);
case LABEL_CODE:
return InsetLabel::isCompatibleCommand(s);
case NOMENCL_CODE:
return InsetNomencl::isCompatibleCommand(s);
case NOMENCL_PRINT_CODE:
return InsetPrintNomencl::isCompatibleCommand(s);
case REF_CODE:
return InsetRef::isCompatibleCommand(s);
case TOC_CODE:
return InsetTOC::isCompatibleCommand(s);
default:
BOOST_ASSERT(false);
}
return false; //silence the warning
}
void InsetCommandParams::setCmdName(string const & name)
{
//FIXME Check command compatibility
if (!isCompatibleCommand(insetCode_, cmdName_)){
lyxerr << "InsetCommand: Incompatible command name " <<
name << "." << std::endl;
throw ExceptionMessage(WarningException, _("InsetCommand Error: "),
from_utf8("Incompatible command name."));
}
cmdName_ = name;
CommandInfo const * const info = findInfo(insetCode_, cmdName_);
if (!info) {
@ -250,12 +256,12 @@ void InsetCommandParams::read(Lexer & lex)
}
lex.next();
cmdName_ = lex.getString();
//FIXME
//check that this command is ok with the inset...
//so that'll be some kind of static call, depending
//upon what insetType_ is.
//it's possible that should go into InsetCommand.cpp,
//or maybe it's a standalone function.
if (!isCompatibleCommand(insetCode_, cmdName_)){
lex.printError("InsetCommand: Incompatible command name " + cmdName_ + ".");
throw ExceptionMessage(WarningException, _("InsetCommand Error: "),
from_utf8("Incompatible command name."));
}
info_ = findInfo(insetCode_, cmdName_);
if (!info_) {
lex.printError("InsetCommand: Unknown inset name `$$Token'");

View File

@ -6,6 +6,7 @@
*
* \author Angus Leeming
* \author Georg Baum
* \author Richard Heck
*
* Full author contact details are available in file CREDITS.
*/
@ -17,6 +18,8 @@
#include "support/docstring.h"
#include <iosfwd>
#include <list>
#include <string>
#include <vector>
@ -24,6 +27,48 @@ namespace lyx {
class Lexer;
// No parameter may be named "preview", because that is a required
// flag for all commands.
struct CommandInfo {
/// Number of parameters
size_t n;
/// Parameter names. paramnames[n] must be "".
char const * const * paramnames;
/// Tells whether a parameter is optional
bool const * optional;
};
///
struct ICPInfo {
///
ICPInfo(std::string const & s, bool b);
/// Parameter name.
std::string paramName;
/// Whether it is optional.
bool optional;
};
///
typedef std::list<ICPInfo> PList;
///
class ICPList {
public:
///
PList::const_iterator begin() { return plist_.begin(); }
///
PList::const_iterator end() { return plist_.end(); }
///
void clear() { plist_.clear(); }
///
void addParam(std::string const & s, bool b = false);
///
bool hasParam(std::string const & s);
private:
///
PList plist_;
};
class InsetCommandParams {
public:
/// Construct parameters for inset of type \p code.
@ -65,14 +110,6 @@ public:
private:
///
struct CommandInfo {
/// Number of parameters
size_t n;
/// Parameter names. paramnames[n] must be "".
char const * const * paramnames;
/// Tells whether a parameter is optional
bool const * optional;
};
/// Get information for inset type \p code.
/// Returns 0 if the inset is not known.
static CommandInfo const * findInfo(InsetCode code);
@ -83,6 +120,8 @@ private:
static CommandInfo const * findInfo(InsetCode code,
std::string const & cmdName);
///
static bool isCompatibleCommand(InsetCode code, std::string const & s);
///
std::string getDefaultCmd(InsetCode);
/// Description of all command properties
CommandInfo const * info_;

View File

@ -49,6 +49,22 @@ InsetFloatList::InsetFloatList(string const & type)
}
CommandInfo const * InsetFloatList::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"type", ""};
static const bool isoptional[] = {false};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
//HACK
bool InsetFloatList::isCompatibleCommand(std::string const & s) {
std::string str = s.substr(0, 6);
return str == "listof";
}
docstring const InsetFloatList::getScreenLabel(Buffer const & buf) const
{
FloatList const & floats = buf.params().getTextClass().floats();

View File

@ -49,6 +49,12 @@ public:
OutputParams const & runparams) const;
///
void validate(LaTeXFeatures & features) const;
///
static CommandInfo const * findInfo(std::string const & cmdName = "");
///
static std::string defaultCommand() { return "listoftables"; };
///
static bool isCompatibleCommand(std::string const & s);
private:
virtual Inset * clone() const
{

View File

@ -24,6 +24,14 @@ InsetHFill::InsetHFill()
{}
CommandInfo const * InsetHFill::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {""};
static const CommandInfo info = {0, paramnames, 0};
return &info;
}
Inset * InsetHFill::clone() const
{
return new InsetHFill;

View File

@ -41,6 +41,13 @@ public:
/// is this equivalent to a space (which is BTW different from
// a line separator)?
bool isSpace() const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "hfill"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "hfill"; }
private:
virtual Inset * clone() const;
};

View File

@ -44,6 +44,16 @@ InsetHyperlink::InsetHyperlink(InsetCommandParams const & p)
{}
CommandInfo const * InsetHyperlink::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] =
{"name", "target", ""};
static const bool isoptional[] = {true, false};
static const CommandInfo info = {2, paramnames, isoptional};
return &info;
}
docstring const InsetHyperlink::getScreenLabel(Buffer const &) const
{
docstring const temp = from_ascii("Hyperlink: ");

View File

@ -49,6 +49,13 @@ public:
/// the string that is passed to the TOC
virtual int textString(Buffer const &, odocstream &,
OutputParams const &) const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "href"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "href"; }
private:
virtual Inset * clone() const {
return new InsetHyperlink(params());

View File

@ -96,27 +96,29 @@ docstring const uniqueID()
/// the type of inclusion
enum Types {
INCLUDE = 0,
VERB = 1,
INPUT = 2,
VERBAST = 3,
LISTINGS = 4,
INCLUDE, VERB, INPUT, VERBAST, LISTINGS, NONE
};
Types type(std::string const & s) {
if (s == "input")
return INPUT;
if (s == "verbatiminput")
return VERB;
if (s == "verbatiminput*")
return VERBAST;
if (s == "lstinputlisting")
return LISTINGS;
if (s == "include")
return INCLUDE;
return NONE;
}
Types type(InsetCommandParams const & params)
{
string const command_name = params.getCmdName();
if (command_name == "input")
return INPUT;
if (command_name == "verbatiminput")
return VERB;
if (command_name == "verbatiminput*")
return VERBAST;
if (command_name == "lstinputlisting")
return LISTINGS;
return INCLUDE;
return type(command_name);
}
@ -158,6 +160,22 @@ InsetInclude::InsetInclude(InsetInclude const & other)
}
CommandInfo const * InsetInclude::findInfo(std::string const & /* cmdName */)
{
//This is only correct for the case of listings, but it'll do for now.
//In the other cases, this second parameter should just be empty.
static const char * const paramnames[] = {"filename", "lstparams", ""};
static const bool isoptional[] = {false, true};
static const CommandInfo info = {2, paramnames, isoptional};
return &info;
}
bool InsetInclude::isCompatibleCommand(std::string const & s) {
return type(s) != NONE;
}
void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
@ -255,9 +273,10 @@ docstring const InsetInclude::getScreenLabel(Buffer const & buf) const
case INCLUDE:
temp = buf.B_("Include");
break;
case LISTINGS: {
case LISTINGS:
temp = listings_label_;
}
case NONE:
BOOST_ASSERT(false);
}
temp += ": ";

View File

@ -96,6 +96,12 @@ public:
void updateLabels(Buffer const & buffer, ParIterator const &);
/// child document can be embedded
void registerEmbeddedFiles(Buffer const &, EmbeddedFiles &) const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "include"; };
///
static bool isCompatibleCommand(std::string const & s);
protected:
InsetInclude(InsetInclude const &);
///

View File

@ -40,6 +40,15 @@ InsetIndex::InsetIndex(InsetIndex const & in)
{}
CommandInfo const * InsetIndex::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"name", ""};
static const bool isoptional[] = {false};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
int InsetIndex::docbook(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
@ -112,6 +121,15 @@ InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
{}
CommandInfo const * InsetPrintIndex::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"name", ""};
static const bool isoptional[] = {false};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
{
return _("Index");

View File

@ -49,7 +49,13 @@ public:
OutputParams const &) const;
/// should paragraph indendation be omitted in any case?
bool neverIndent(Buffer const &) const { return true; }
///
static CommandInfo const * findInfo(std::string const & cmdName = "");
///
static std::string defaultCommand() { return "index"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "index"; }
private:
///
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
@ -72,6 +78,13 @@ public:
DisplayType display() const { return AlignCenter; }
///
docstring const getScreenLabel(Buffer const &) const;
///
static CommandInfo const * findInfo(std::string const & cmdName = "");
///
static std::string defaultCommand() { return "printindex"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "printindex"; }
private:
virtual Inset * clone() const {
return new InsetPrintIndex(params());

View File

@ -31,6 +31,15 @@ InsetLabel::InsetLabel(InsetCommandParams const & p)
{}
CommandInfo const * InsetLabel::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"name", ""};
static const bool isoptional[] = {false};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
Inset * InsetLabel::clone() const
{
return new InsetLabel(params());

View File

@ -35,6 +35,13 @@ public:
int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
///
int docbook(Buffer const &, odocstream &, OutputParams const &) const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "label"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "label"; }
protected:
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
private:

View File

@ -34,6 +34,15 @@ InsetNomencl::InsetNomencl(InsetCommandParams const & p)
{}
CommandInfo const * InsetNomencl::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
static const bool isoptional[] = {true, false, false};
static const CommandInfo info = {3, paramnames, isoptional};
return &info;
}
docstring const InsetNomencl::getScreenLabel(Buffer const &) const
{
return _("Nom");
@ -75,6 +84,15 @@ InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
{}
CommandInfo const * InsetPrintNomencl::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"labelwidth", ""};
static const bool isoptional[] = {true};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
docstring const InsetPrintNomencl::getScreenLabel(Buffer const &) const
{
return _("Nomenclature");

View File

@ -40,6 +40,13 @@ public:
OutputParams const &) const;
///
int docbookGlossary(odocstream &) const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "nomenclature"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "nomenclature"; }
private:
virtual Inset * clone() const {
return new InsetNomencl(params());
@ -70,6 +77,13 @@ public:
DisplayType display() const { return AlignCenter; }
///
docstring const getScreenLabel(Buffer const &) const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "printnomenclature"; };
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "printnomenclature"; }
private:
virtual Inset * clone() const {
return new InsetPrintNomencl(params());

View File

@ -42,6 +42,27 @@ InsetRef::InsetRef(InsetRef const & ir)
{}
bool InsetRef::isCompatibleCommand(std::string const & s) {
//FIXME This is likely not the best way to handle this.
//But this stuff is hardcoded elsewhere already.
return s == "ref"
|| s == "pageref"
|| s == "vref"
|| s == "vpageref"
|| s == "prettyref"
|| s == "eqref";
}
CommandInfo const * InsetRef::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"name", "reference", ""};
static const bool isoptional[] = {true, false};
static const CommandInfo info = {2, paramnames, isoptional};
return &info;
}
void InsetRef::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {

View File

@ -57,6 +57,12 @@ public:
OutputParams const &) const;
///
void validate(LaTeXFeatures & features) const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "ref"; };
///
static bool isCompatibleCommand(std::string const & s);
protected:
InsetRef(InsetRef const &);

View File

@ -34,6 +34,15 @@ InsetTOC::InsetTOC(InsetCommandParams const & p)
{}
CommandInfo const * InsetTOC::findInfo(std::string const & /* cmdName */)
{
static const char * const paramnames[] = {"type", ""};
static const bool isoptional[] = {false};
static const CommandInfo info = {1, paramnames, isoptional};
return &info;
}
Inset * InsetTOC::clone() const
{
return new InsetTOC(*this);

View File

@ -37,6 +37,13 @@ public:
///
int docbook(Buffer const &, odocstream &,
OutputParams const &) const;
///
static CommandInfo const * findInfo(std::string const &);
///
static std::string defaultCommand() { return "tableofcontents"; };
///
static bool isCompatibleCommand(std::string const & cmd)
{return cmd == defaultCommand(); }
private:
virtual Inset * clone() const;
};